Connect Revit to the Web
A cookbook made from The 3D Web Coder website by Jeremy Tammik
How to use Node and NPM without installation or admin rights - Shravan Kumar Kasagoni
Ingredients:
Brackets open source text editor. Live preview on browser.
Node.js open source, cross-platform JavaScript runtime environment. Use it to build a web server.
Tutorials and Workshops:
$ npm install -g learnyounode
$ npm install -g introtowebgl
Installation
How to use Node and NPM without installation or admin rights - Shravan Kumar Kasagoni
- Get node binary (node.exe) from nodejs.org site
- Get the NPM
- Copy npm.cmd beside the node.exe
- Configure the PATH
- Verify the setup. Go to command line then type node -v then npm -v.
Miniconda installation
set the .condarc file to:
channels:
- anaconda-fusion
- conda
- conda-forge
- r
- defaults
show_channel_urls: true
proxy_servers:
http: http://username:password@proxy.ha.arup.com:80
https: http://username:password@proxy.ha.arup.com:80
ssl_verify: 'True'
Add all the channels to the list.
not working:
- Pipenv
- pip install –user nodejs
Recipes
The Node.js Server Platform
nodejs Hello World
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
Run the server
% node example.js
Server running at http://127.0.0.1:1337/
Http-server
One of the very easiest ways to create a web server with no code whatsoever is to make use of http-server, a simple zero-configuration command-line HTTP server.
- Set up Node.js http-server server:
npm install http-server -g
- Put your files in your folder
- Start your local node http-server server:
[sudo] http-server <myfolder>
Implementing a Word Jumbling JavaScript Driven HTML Form
- Add the javascript function to the html
- create a form in the html <body>
<html>
<head>
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script>
function jumble(word) {
// Cache word length for easy looping
var n = word.length;
// Rand function will return 2-part array
// [0] -> Index of rand, [1] -> random found value (from args)
var rand = function(){
var myRand = Math.floor(Math.random() * arguments.length);
return [myRand, arguments[myRand]];
};
// Split passed word into array
word = word.split('');
// Prepate empty string for jumbled word
jumbled = '';
// Get array full of all available indexes:
// (Reverse while loops are quickest: http://reque.st/1382)
arrIndexes = [];
var i = n;
while (i--) {
arrIndexes.push(i);
}
i = n;
while (i--) {
// Get a random number, must be one of
// those found in arrIndexes
var rnd = rand.apply(null,arrIndexes);
// Append random character to jumbled
jumbled += word[rnd[1]];
// Remove character from arrIndexes
// so that it is not selected again:
arrIndexes.splice(rnd[0],1);
}
// Return the jumbled word
return jumbled;
}
function jumble_one(word) {
var n = word.length;
if( 2 < n )
{
word = word[0] + jumble(word.slice(1,n-1)) + word[n-1];
}
return word;
}
function jumble_many_map(words) {
jumbled = words.split(' ').map(jumble_one);
return jumbled.join(' ');
}
function jumble_form(f)
{
f.output.value = jumble_many_map(f.input.value);
}
</script>
</head>
<body>
<form onSubmit="submit()">
<p>Input words to jumble (no punctuation):</p>
<textarea name="input" rows="5" cols="30">Type text here</textarea>
<br/>
<input value="Jumble words" type="button" onClick="jumble_form(this.form)" />
<p>Output jumbled words:</p>
<textarea name="output" rows="5" cols="30" readonly="readonly">Result text here</textarea>
</form>
</body>
</html>
https://github.com/hummingburd/aecSpace
- Install miniconda
- Create an environment
- Activate the environment
source activate pythonocc
- Install pythonocc
conda install -c conda-forge -c dlr-sc -c pythonocc -c oce pythonocc-core==0.18.1
- Install sympy
conda install -c anaconda sympy
- Navigate to the script folder and type
python aecSpaceTowerExample.py
Written on February 26, 2018