protected override void SolveInstance(IGH_DataAccess DA) { GsaMaterial material = new GsaMaterial(); GH_Integer gh_anal = new GH_Integer(); if (DA.GetData(0, ref gh_anal)) { int anal = 0; GH_Convert.ToInt32(gh_anal, out anal, GH_Conversion.Both); material.AnalysisProperty = anal; } GH_Integer gh_grade = new GH_Integer(); if (DA.GetData(1, ref gh_grade)) { int grade = 1; GH_Convert.ToInt32(gh_grade, out grade, GH_Conversion.Both); material.Grade = grade; } // element type (picked in dropdown) if (_mode == FoldMode.Generic) { material.Type = GsaMaterial.MatType.GENERIC; } if (_mode == FoldMode.Steel) { material.Type = GsaMaterial.MatType.STEEL; } if (_mode == FoldMode.Concrete) { material.Type = GsaMaterial.MatType.CONCRETE; } if (_mode == FoldMode.Timber) { material.Type = GsaMaterial.MatType.TIMBER; } if (_mode == FoldMode.Aluminium) { material.Type = GsaMaterial.MatType.ALUMINIUM; } if (_mode == FoldMode.FRP) { material.Type = GsaMaterial.MatType.FRP; } if (_mode == FoldMode.Glass) { material.Type = GsaMaterial.MatType.GLASS; } if (_mode == FoldMode.Fabric) { material.Type = GsaMaterial.MatType.FABRIC; } DA.SetData(0, new GsaMaterialGoo(material)); }
protected override void SolveInstance(IGH_DataAccess DA) { GsaSection sect = new GsaSection(); GsaSection gsaSection = new GsaSection(); if (DA.GetData(0, ref sect)) { gsaSection = sect.Clone(); } if (gsaSection != null) { // #### input #### // 1 ID GH_Integer ghID = new GH_Integer(); if (DA.GetData(1, ref ghID)) { if (GH_Convert.ToInt32(ghID, out int id, GH_Conversion.Both)) { gsaSection.ID = id; } } // 2 profile string profile = ""; if (DA.GetData(2, ref profile)) { gsaSection.Section.Profile = profile; } // 3 Material GH_ObjectWrapper gh_typ = new GH_ObjectWrapper(); if (DA.GetData(3, ref gh_typ)) { GsaMaterial material = new GsaMaterial(); if (gh_typ.Value is GsaMaterialGoo) { gh_typ.CastTo(ref material); gsaSection.Material = material; } else { if (GH_Convert.ToInt32(gh_typ.Value, out int idd, GH_Conversion.Both)) { gsaSection.Section.MaterialAnalysisProperty = idd; } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert PB input to a Section Property of reference integer"); return; } } }
protected override void SolveInstance(IGH_DataAccess DA) { GsaProp2d gsaProp2d = new GsaProp2d(); GsaProp2d prop = new GsaProp2d(); if (DA.GetData(0, ref gsaProp2d)) { prop = gsaProp2d.Clone(); } // #### inputs #### // 1 ID GH_Integer ghID = new GH_Integer(); if (DA.GetData(1, ref ghID)) { if (GH_Convert.ToInt32(ghID, out int id, GH_Conversion.Both)) { prop.ID = id; } } // 2 Material GH_ObjectWrapper gh_typ = new GH_ObjectWrapper(); if (DA.GetData(2, ref gh_typ)) { GsaMaterial material = new GsaMaterial(); if (gh_typ.Value is GsaMaterialGoo) { gh_typ.CastTo(ref material); prop.Material = material; } else { if (GH_Convert.ToInt32(gh_typ.Value, out int idd, GH_Conversion.Both)) { prop.Prop2d.MaterialAnalysisProperty = idd; } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert PB input to a Section Property of reference integer"); return; } }
protected override void SolveInstance(IGH_DataAccess DA) { GsaSection gsaSection = new GsaSection(); //profile GH_String gh_profile = new GH_String(); if (DA.GetData(0, ref gh_profile)) { if (GH_Convert.ToString(gh_profile, out string profile, GH_Conversion.Both)) { gsaSection.Section = new Section(); gsaSection.Section.Profile = profile; // 3 Material GH_ObjectWrapper gh_typ = new GH_ObjectWrapper(); if (DA.GetData(1, ref gh_typ)) { GsaMaterial material = new GsaMaterial(); if (gh_typ.Value is GsaMaterialGoo) { gh_typ.CastTo(ref material); gsaSection.Material = material; } else { if (GH_Convert.ToInt32(gh_typ.Value, out int idd, GH_Conversion.Both)) { gsaSection.Material = new GsaMaterial(idd); } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert PB input to a Section Property of reference integer"); return; } } } else { gsaSection.Material = new GsaMaterial(7); } }
public static MaterialType ConvertType(GsaMaterial material) { MaterialType matType = GsaAPI.MaterialType.NONE; int typ = (int)material.Type; if (typ == 1) { matType = MaterialType.STEEL; } if (typ == 2) { matType = MaterialType.CONCRETE; } if (typ == 5) { matType = MaterialType.FRP; } if (typ == 3) { matType = MaterialType.ALUMINIUM; } if (typ == 7) { matType = MaterialType.TIMBER; } if (typ == 4) { matType = MaterialType.GLASS; } if (typ == 8) { matType = MaterialType.FABRIC; } if (typ == 0) { matType = MaterialType.GENERIC; } return(matType); }
protected override void SolveInstance(IGH_DataAccess DA) { GsaProp2d prop = new GsaProp2d(); prop.Prop2d = new Prop2D(); prop.ID = 0; // element type (picked in dropdown) prop.Prop2d.Type = Property2D_Type.UNDEF; if (_mode == FoldMode.PlaneStress) prop.Prop2d.Type = Property2D_Type.PL_STRESS; if (_mode == FoldMode.Fabric) prop.Prop2d.Type = Property2D_Type.FABRIC; if (_mode == FoldMode.FlatPlate) prop.Prop2d.Type = Property2D_Type.PLATE; if (_mode == FoldMode.Shell) prop.Prop2d.Type = Property2D_Type.SHELL; if (_mode == FoldMode.CurvedShell) prop.Prop2d.Type = Property2D_Type.CURVED_SHELL; if (_mode == FoldMode.LoadPanel) prop.Prop2d.Type = Property2D_Type.LOAD; if (_mode != FoldMode.LoadPanel) { prop.Prop2d.AxisProperty = 0; if (_mode != FoldMode.Fabric) { // 0 Material GH_ObjectWrapper gh_typ = new GH_ObjectWrapper(); if (DA.GetData(0, ref gh_typ)) { GsaMaterial material = new GsaMaterial(); if (gh_typ.Value is GsaMaterialGoo) { gh_typ.CastTo(ref material); prop.Material = material; } else { if (GH_Convert.ToInt32(gh_typ.Value, out int idd, GH_Conversion.Both)) { prop.Material = new GsaMaterial(idd); } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert PB input to a Section Property of reference integer"); return; } } } else prop.Material = new GsaMaterial(2); // 1 thickness //GH_String gh_THK = new GH_String(); //string thickness = "0.2"; //if (DA.GetData(1, ref gh_THK)) // GH_Convert.ToString(gh_THK, out thickness, GH_Conversion.Both); //prop.Prop2d.Description = thickness; GH_Number gh_THK = new GH_Number(); double thickness = 200; if (DA.GetData(1, ref gh_THK)) GH_Convert.ToDouble(gh_THK, out thickness, GH_Conversion.Both); prop.Thickness = thickness; }
protected override void SolveInstance(IGH_DataAccess DA) { GsaMaterial gsaMaterial = new GsaMaterial(); GsaMaterial material = new GsaMaterial(); if (DA.GetData(0, ref gsaMaterial)) { material = gsaMaterial.Duplicate(); } // #### inputs #### // 1 Analysis Property GH_Integer ghID = new GH_Integer(); if (DA.GetData(1, ref ghID)) { if (GH_Convert.ToInt32(ghID, out int id, GH_Conversion.Both)) { material.AnalysisProperty = id; } } // 2 Material type MaterialType matType = MaterialType.CONCRETE; GH_ObjectWrapper gh_typ = new GH_ObjectWrapper(); if (DA.GetData(2, ref gh_typ)) { if (gh_typ.Value is MaterialType) { gh_typ.CastTo(ref matType); } if (gh_typ.Value is GH_Integer) { int typ = 2; GH_Convert.ToInt32(gh_typ, out typ, GH_Conversion.Both); if (typ == 1) { material.Type = GsaMaterial.MatType.STEEL; } if (typ == 2) { material.Type = GsaMaterial.MatType.CONCRETE; } if (typ == 5) { material.Type = GsaMaterial.MatType.FRP; } if (typ == 3) { material.Type = GsaMaterial.MatType.ALUMINIUM; } if (typ == 7) { material.Type = GsaMaterial.MatType.TIMBER; } if (typ == 4) { material.Type = GsaMaterial.MatType.GLASS; } if (typ == 8) { material.Type = GsaMaterial.MatType.FABRIC; } if (typ == 0) { material.Type = GsaMaterial.MatType.GENERIC; } } else if (gh_typ.Value is GH_String) { string typ = "CONCRETE"; GH_Convert.ToString(gh_typ, out typ, GH_Conversion.Both); if (typ.ToUpper() == "STEEL") { material.Type = GsaMaterial.MatType.STEEL; } if (typ.ToUpper() == "CONCRETE") { material.Type = GsaMaterial.MatType.CONCRETE; } if (typ.ToUpper() == "FRP") { material.Type = GsaMaterial.MatType.FRP; } if (typ.ToUpper() == "ALUMINIUM") { material.Type = GsaMaterial.MatType.ALUMINIUM; } if (typ.ToUpper() == "TIMBER") { material.Type = GsaMaterial.MatType.TIMBER; } if (typ.ToUpper() == "GLASS") { material.Type = GsaMaterial.MatType.GLASS; } if (typ.ToUpper() == "FABRIC") { material.Type = GsaMaterial.MatType.FABRIC; } if (typ.ToUpper() == "GENERIC") { material.Type = GsaMaterial.MatType.GENERIC; } } else { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to convert Material Type input"); return; } } // 3 grade int grd = 0; if (DA.GetData(3, ref grd)) { material.Grade = grd; } //#### outputs #### DA.SetData(0, new GsaMaterialGoo(material)); DA.SetData(1, material.AnalysisProperty); string mate = material.Type.ToString(); mate = Char.ToUpper(mate[0]) + mate.Substring(1).ToLower().Replace("_", " "); DA.SetData(2, mate); DA.SetData(3, material.Grade); }