/* Dynamic library items for QCAD - Open Source 2D CAD (www.qcad.org) * * Structural steel sections (I) according to DIN 1025-1:2009-04 */ include("scripts/library.js"); function StructuralSteelSectionsI() { }; StructuralSteelSectionsI.init = function(formWidget) { if (!isNull(formWidget)) { StructuralSteelSectionsI.widgets = getWidgets(formWidget); } }; StructuralSteelSectionsI.generate = function(documentInterface, file) { StructuralSteelSectionsI.hi = parseInt(StructuralSteelSectionsI.widgets["SectionHeight"].currentText, 10); if (isNaN(StructuralSteelSectionsI.hi)) { StructuralSteelSectionsI.hi = 80; } return StructuralSteelSectionsI.createSection(documentInterface); }; StructuralSteelSectionsI.generatePreview = function(documentInterface, iconSize) { StructuralSteelSectionsI.hi = 16; return StructuralSteelSectionsI.createSection(documentInterface); }; StructuralSteelSectionsI.createSection = function(documentInterface) { //define size parameter according to DIN 1025-1:2009-04 (additional first item only for icon preview) var ha = new Array(16,80,100,120,140,160,180,200,220,240,260,280,300,320,340,360,380,400,450,500,550); var ba = new Array(8.4,42,50,58,66,74,82,90,98,106,113,119,125,131,137,143,149,155,170,185,200); var sa = new Array(0.8,3.9,4.5,5.1,5.7,6.3,6.9,7.5,8.1,8.7,9.4,10.1,10.8,11.5,12.2,13.0,13.7,14.4,16.2,18.0,19.0); var ta = new Array(1.2,5.9,6.8,7.7,8.6,9.5,10.4,11.3,12.2,13.1,14.1,15.2,16.2,17.3,18.3,19.5,20.5,21.6,24.3,27.0,30.0); var r1a = sa ; var r2a = new Array(0.4,2.3,2.7,3.1,3.4,3.8,4.1,4.5,4.9,5.2,5.6,6.1,6.5,6.9,7.3,7.8,8.2,8.6,9.7,10.8,11.9); //flange angle according to DIN 1025-1:2009-04 var alpha = Math.atan(14/100); //choose actual size and calculate additional parameters var n = ha.indexOf(StructuralSteelSectionsI.hi); var x_s = sa[n]/2; var x_r1 = sa[n]/2 + r1a[n]; var x_t = ba[n]/4; var x_r2 = ba[n]/2 - r2a[n]; var x_b = ba[n]/2; var x_k1 = ba[n]/4 + 100/14 * ta[n]; var x_l1 = x_r1 - r1a[n] * Math.sin(alpha); var x_l2 = x_r2 + r2a[n] * Math.sin(alpha); var y_h = ha[n]/2; var y_k2 = y_h - 14/100 * (x_k1 - x_r2); var y_k3 = y_h - 14/100 * (x_k1 - x_r1); var y_r2 = y_k2 + r2a[n] / Math.cos(alpha); var y_r1 = y_k3 - r1a[n] / Math.cos(alpha); var y_l1 = y_r1 + r1a[n] * Math.cos(alpha); var y_l2 = y_r2 - r2a[n] * Math.cos(alpha); var segments = [new RLine( new RVector(x_b, y_h), new RVector(x_b, y_r2) ), new RArc( new RVector(x_r2, y_r2), r2a[n], RMath.deg2rad(360), RMath.deg2rad(270) + alpha, true), new RLine( new RVector(x_l2, y_l2), new RVector(x_l1, y_l1) ), new RArc( new RVector(x_r1, y_r1), r1a[n], RMath.deg2rad(90) + alpha, RMath.deg2rad(180), false), new RLine( new RVector(x_s, y_r1), new RVector(x_s,-y_r1) ), new RArc( new RVector(x_r1, -y_r1), r1a[n], RMath.deg2rad(180), RMath.deg2rad(270) - alpha, false), new RLine( new RVector(x_l1, -y_l1), new RVector(x_l2, -y_l2) ), new RArc( new RVector(x_r2, -y_r2), r2a[n], RMath.deg2rad(90) - alpha, RMath.deg2rad(0), true), new RLine( new RVector(x_b, -y_r2), new RVector(x_b, -y_h) ), new RLine( new RVector(x_b, -y_h), new RVector(-x_b, -y_h) ), new RLine( new RVector(-x_b, -y_h), new RVector(-x_b, -y_r2) ), new RArc( new RVector(-x_r2, -y_r2), r2a[n], RMath.deg2rad(180), RMath.deg2rad(90) + alpha, true), new RLine( new RVector(-x_l2, -y_l2), new RVector(-x_l1, -y_l1) ), new RArc( new RVector(-x_r1, -y_r1), r1a[n], RMath.deg2rad(270) + alpha, RMath.deg2rad(360), false), new RLine( new RVector(-x_s, -y_r1), new RVector(-x_s, y_r1) ), new RArc( new RVector(-x_r1, y_r1), r1a[n], RMath.deg2rad(0), RMath.deg2rad(90) - alpha, false), new RLine( new RVector(-x_l1, y_l1), new RVector(-x_l2, y_l2) ), new RArc( new RVector(-x_r2, y_r2), r2a[n], RMath.deg2rad(270) - alpha, RMath.deg2rad(180), true), new RLine( new RVector(-x_b, y_r2), new RVector(-x_b, y_h) ), new RLine( new RVector(-x_b, y_h), new RVector(x_b, y_h) ) ]; var polyline = new RPolyline(segments); var polylineEntity = shapeToEntity(documentInterface.getDocument(), polyline); //set custom property for designation var des = "Type: DIN 1025-1" + " — " + "I " + StructuralSteelSectionsI.hi + " — "; polylineEntity.setCustomProperty("Structural Steel Section","0001_1000", des); polylineEntity.setCustomProperty("Structural Steel Section","0002_1000", "Material: DIN EN 10025-2 — 1.0038"); //apply changes var addOperation = new RAddObjectsOperation(false); addOperation.addObject(polylineEntity, false); return addOperation; };