Skip to content

Instantly share code, notes, and snippets.

View danielherrerohernando's full-sized avatar
🍌

Daniel Herrero Hernando danielherrerohernando

🍌
View GitHub Profile
@danielherrerohernando
danielherrerohernando / DynamoNewFloor.py
Created July 6, 2020 20:05
Dynamo Python script example of how we can create a new floor calling the Revit API method
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 November 30, 2023 11:04
Example of multiple floors creation for a given list of levels
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitNodes')
import Revit
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 15:39
Gauss-Jordan method implementation for solving systems of equations
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 14:24
Set of functions used for building polynomial regression models
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)));