Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍🍳

Daniel Herrero Hernando danielherrerohernando

👨‍🍳
View GitHub Profile
@danielherrerohernando
danielherrerohernando / DynamoNewFloor.py
Created Jul 6, 2020
Dynamo Python script example of how we can create a new floor calling the Revit API method
View DynamoNewFloor.py
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitNodes')
import Revit
@danielherrerohernando
danielherrerohernando / DynamoNewFloorByLevels.py
Last active Jul 6, 2020
Example of multiple floors creation for a given list of levels
View DynamoNewFloorByLevels.py
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitNodes')
import Revit
View polynomialRegression.js
const { writeFileSync, readFileSync } = require('fs');
const { buildSystem } = require('./systemBuilder');
const { solve } = require('./systemSolver');
const { getExpression } = require('./helpers');
const createModel = () => {
let params = {};
const fit = (data,degrees) => {
@danielherrerohernando
danielherrerohernando / systemSolver.js
Last active May 22, 2020
Gauss-Jordan method implementation for solving systems of equations
View systemSolver.js
const buildAugmentedMatrix = (leftMatrix, rightMatrix) => leftMatrix.map((row,i)=>row.concat(rightMatrix[i]));
const triangularize = (augmentedMatrix) => {
const n = augmentedMatrix.length;
for (let i=0; i<n-1; i++) {
for (let j=i+1; j<n; j++) {
const c = augmentedMatrix[j][i]/augmentedMatrix[i][i];
for (let k=i+1; k<n+1; k++) {
augmentedMatrix[j][k] = augmentedMatrix[j][k] - c*augmentedMatrix[i][k];
}
@danielherrerohernando
danielherrerohernando / buildSystem.js
Last active May 22, 2020
Set of functions used for building polynomial regression models
View buildSystem.js
const buildArray = size => new Array(size).fill('');
const buildBase = degree => buildArray(degree+1).map((_,i) => x => x**i);
const buildGramMatrix = (data, base) => buildArray(base.length)
.map((_,i) => buildArray(base.length)
.map((_,j) => data.reduce((acc,[x]) => acc + base[i](x)*base[j](x),0)));
const buildIndependentTerm = (data, base) => buildArray(base.length)
.map((_,i) => [].concat(data.reduce((acc,[x,y]) => acc + base[i](x)*y,0)));