public static object sSystemSettings(string systemName, string defaultLoadCase = "DEAD", int defaultCheckType = 0, double StressThreshold_ksi = 25.0, double DeflectionThreshold_in = 6.0, double mergeTolerance_in = 0.05, double colorMeshSegSize_ft = 1.5) { sSystemSetting set = new sSystemSetting(); set.systemName = systemName; set.currentCase = defaultLoadCase; if (defaultCheckType == 1) { set.currentCheckType = eSystemCheckType.StiffnessCheck; } else { set.currentCheckType = eSystemCheckType.StrengthCheck; } set.currentStressThreshold_pascal = StressThreshold_ksi * 6894757.28; set.currentDeflectionThreshold_mm = DeflectionThreshold_in * 25.4; set.mergeTolerance_m = mergeTolerance_in * 0.0254; set.meshDensity_m = colorMeshSegSize_ft * 0.3048; return(new Dictionary <string, object> { { "sSystemSettings", set } }); }
public static object Build_sSystem(List <object> sElements, object systemSettings = null) { sSystemSetting sysSet = null; if (systemSettings == null) { sysSet = new sSystemSetting(); sysSet.systemOriUnit = "Feet"; sysSet.systemName = "DefaultSetting"; sysSet.currentCase = "DEAD"; sysSet.currentCheckType = eSystemCheckType.StrengthCheck; sysSet.currentStressThreshold_pascal = 25 * 6894757.28; sysSet.currentDeflectionThreshold_mm = 100; sysSet.mergeTolerance_m = 0.005; sysSet.meshDensity_m = 0.5; } else { sysSet = systemSettings as sSystemSetting; } sSystem jsys = new sSystem(); jsys.systemSettings = sysSet; List <IsObject> sobjs = new List <IsObject>(); sDynamoConverter dycon = new sDynamoConverter(); jsys.loadPatterns.Add("DEAD"); int supCount = 0; int nodeID = 0; foreach (object so in sElements) { sFrameSet sb = so as sFrameSet; if (sb != null) { jsys.frameSets.Add(sb); sobjs.Add(sb); if (sb.lineLoads != null) { foreach (sLineLoad ll in sb.lineLoads) { jsys.AwarePatternNames(ll.loadPatternName); } } continue; } sPointSupport psup = so as sPointSupport; if (psup != null) { if (jsys.UpdateNodeFromPointElement(psup, nodeID)) { nodeID++; } supCount++; continue; } sPointLoad pl = so as sPointLoad; if (pl != null) { if (jsys.UpdateNodeFromPointElement(pl, nodeID)) { nodeID++; jsys.AwarePatternNames(pl.loadPatternName); } continue; } sLoadCombination com = so as sLoadCombination; if (com != null) { jsys.SetLoadCombination(com); } } if (supCount > 0) { //jsys.geometrySettings.systemBoundingBox = dycon.TosBoundingBox(sobjs); //jsys.SystemName = sysSet.systemName; return(new Dictionary <string, object> { { "sSystem", jsys } }); } else { return(new Dictionary <string, object> { { "sSystem", null } }); } }
protected override void SolveInstance(IGH_DataAccess DA) { string name = ""; string loadcase = ""; int type = 0; double st = 0.0; double def = 0.0; double merge = 0.0; double mSeg = 0.0; if (!DA.GetData(0, ref name)) { return; } if (!DA.GetData(1, ref loadcase)) { return; } if (!DA.GetData(2, ref type)) { return; } if (!DA.GetData(3, ref st)) { return; } if (!DA.GetData(4, ref def)) { return; } if (!DA.GetData(5, ref merge)) { return; } if (!DA.GetData(6, ref mSeg)) { return; } sSystemSetting set = new sSystemSetting(); set.systemName = name; set.currentCase = loadcase; if (type == 1) { set.currentCheckType = eSystemCheckType.StiffnessCheck; } else { set.currentCheckType = eSystemCheckType.StrengthCheck; } string currentUnit = Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString(); set.systemOriUnit = currentUnit; if (st > 0) { if (currentUnit == "Meters") { //MPa to Pa set.currentStressThreshold_pascal = st * 1000000; } else { //ksi to Pa set.currentStressThreshold_pascal = st * 6894757.28; } } else { set.currentStressThreshold_pascal = 25 * 6894757.28; } if (def > 0) { if (currentUnit == "Meters") { set.currentDeflectionThreshold_mm = def; } else { set.currentDeflectionThreshold_mm = def * 25.4; } } else { set.currentDeflectionThreshold_mm = 100; } if (merge > 0) { if (currentUnit == "Meters") { //mm to m set.mergeTolerance_m = merge * 0.001; } else { //in to m set.mergeTolerance_m = merge * 0.0254; } } else { set.mergeTolerance_m = 0.005; } if (mSeg > 0) { if (currentUnit == "Meters") { //m to m set.meshDensity_m = mSeg; } else { //ft to m set.meshDensity_m = mSeg * 0.3048; } } else { set.meshDensity_m = 0.5; } DA.SetData(0, set); }
protected override void SolveInstance(IGH_DataAccess DA) { sSystemSetting sysSetting = null; List <object> sElement = new List <object>(); DA.GetData(0, ref sysSetting); if (!DA.GetDataList(1, sElement)) { return; } sRhinoConverter rhcon = new sRhinoConverter(); string currentUnit = Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString(); if (sysSetting == null) { sysSetting = new sSystemSetting(); sysSetting.systemOriUnit = currentUnit; sysSetting.systemName = "DefaultSetting"; sysSetting.currentCase = "DEAD"; sysSetting.currentCheckType = eSystemCheckType.StrengthCheck; sysSetting.currentStressThreshold_pascal = 25 * 6894757.28; sysSetting.currentDeflectionThreshold_mm = 100; sysSetting.mergeTolerance_m = 0.005; sysSetting.meshDensity_m = 0.5; } if (currentUnit == "Meters" || currentUnit == "Feet") { ISystem jsys = InitiateISystem(sElement); jsys.systemSettings = sysSetting; List <IsObject> sObjs = new List <IsObject>(); jsys.loadPatterns.Add("DEAD"); int supCount = 0; int nodeID = 0; try { foreach (object so in sElement) { GH_ObjectWrapper wap = new GH_ObjectWrapper(so); IFrameSet bs = wap.Value as IFrameSet; if (bs != null) { //jsys.beamSets.Add(bs); jsys.AddsBeamSet(bs); //?? sObjs.Add(bs); if (bs.lineLoads != null) { foreach (sLineLoad ll in bs.lineLoads) { jsys.AwarePatternNames(ll.loadPatternName); } } } sPointLoad pl = wap.Value as sPointLoad; if (pl != null) { if (jsys.UpdateNodeFromPointElement(pl, nodeID)) { nodeID++; jsys.AwarePatternNames(pl.loadPatternName); } } sLoadCombination com = wap.Value as sLoadCombination; if (com != null) { jsys.SetLoadCombination(com); } } foreach (object so in sElement) { GH_ObjectWrapper wap = new GH_ObjectWrapper(so); sPointSupport psup = wap.Value as sPointSupport; if (psup != null) { if (jsys.UpdateNodeFromPointElement(psup, nodeID)) { nodeID++; } supCount++; } } foreach (sMesh am in jsys.meshes) { // sObjs.Add(am); } if (supCount > 0) { this.Message = "System : " + sysSetting.systemName + "\nis instantiated"; jsys.systemSettings.systemBoundingBox = rhcon.TosBoundingBox(sObjs); //jsys.SystemName = sysSetting.systemName; DA.SetData(0, jsys); } else { this.Message = "System : " + sysSetting.systemName + "\nneeds supports"; //jsys.SystemName = sysSetting.systemName; this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, this.Message); DA.SetData(0, null); } } catch (Exception e) { this.Message = "System : " + sysSetting.systemName + "\ninstantiation failed"; this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.Message); DA.SetData(0, null); } } else { this.Message = "ASKSGH.Bridgify only works in\n Meters or Feet"; this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, this.Message); DA.SetData(0, null); } }