Connect Revit to the Web

A cookbook made from The 3D Web Coder website by Jeremy Tammik

Index here

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

  1. Get node binary (node.exe) from nodejs.org site
  2. Get the NPM
  3. Copy npm.cmd beside the node.exe
  4. Configure the PATH
  5. 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.

  1. Set up Node.js http-server server:
    npm install http-server -g
    
  2. Put your files in your folder
  3. 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

  1. Install miniconda
  2. Create an environment
  3. Activate the environment source activate pythonocc
  4. Install pythonocc conda install -c conda-forge -c dlr-sc -c pythonocc -c oce pythonocc-core==0.18.1
  5. Install sympy conda install -c anaconda sympy
  6. Navigate to the script folder and type python aecSpaceTowerExample.py
Written on February 26, 2018