/***************************************************/ /**** Private Methods ****/ /***************************************************/ private bool CreateObject(IMaterialFragment material) { bool success = true; eMatType matType = material.GetMaterialType(); string bhName = material.DescriptionOrName(); int color = 0; string guid = null; string notes = ""; string name = ""; SAP2000Id sap2000id = new SAP2000Id(); if (m_model.PropMaterial.AddMaterial(ref name, matType, "United States", bhName, bhName, guid) == 0) //try to get the material from a dataset { sap2000id.Id = name; } else if (m_model.PropMaterial.SetMaterial(bhName, matType, color, notes, guid) == 0) //create the material { sap2000id.Id = bhName; SetObject(material); } else { CreateElementError("Material", bhName); } SetAdapterId(material, sap2000id); return(success); }
/***************************************************/ /**** Private methods ****/ /***************************************************/ private List <IMaterialFragment> ReadMaterials(List <string> ids = null) { List <IMaterialFragment> materialList = new List <IMaterialFragment>(); if (ids == null) { foreach (rf.Material rfMaterial in modelData.GetMaterials()) { IMaterialFragment material = rfMaterial.FromRFEM(); materialList.Add(material); int matId = rfMaterial.No;// get proper conversion from the 'material.TextID' if (!m_materialDict.ContainsKey(matId)) { m_materialDict.Add(matId, material); } } } else { foreach (string id in ids) { materialList.Add(modelData.GetMaterial(Int32.Parse(id), rf.ItemAt.AtNo).GetData().FromRFEM()); } } return(materialList); }
/***************************************************/ public static void CopyCharacteristics(this IMaterialFragment toMaterial, Material fromMaterial) { if (fromMaterial == null) { toMaterial.NullRevitElementWarning(); return; } ElementId elementID = fromMaterial.StructuralAssetId; if (elementID == null || elementID == ElementId.InvalidElementId) { toMaterial.NullStructuralAssetWarning(); return; } PropertySetElement propertySetElement = fromMaterial.Document.GetElement(elementID) as PropertySetElement; StructuralAsset structuralAsset = propertySetElement?.GetStructuralAsset(); if (structuralAsset == null) { Compute.NullStructuralAssetWarning(toMaterial); return; } toMaterial.CopyCharacteristics(structuralAsset); }
/***************************************************/ public static void SetMaterial(cSapModel model, IMaterialFragment material) { eMatType matType = eMatType.NoDesign; int colour = 0; string guid = ""; string notes = ""; string name = ""; if (model.PropMaterial.GetMaterial(material.Name, ref matType, ref colour, ref notes, ref guid) != 0) { model.PropMaterial.AddMaterial(ref name, GetMaterialType(material), "", "", ""); model.PropMaterial.ChangeName(name, material.Name); if (material is IIsotropic) { IIsotropic isotropic = material as IIsotropic; model.PropMaterial.SetMPIsotropic(material.Name, isotropic.YoungsModulus, isotropic.PoissonsRatio, isotropic.ThermalExpansionCoeff); } else if (material is IOrthotropic) { IOrthotropic orthoTropic = material as IOrthotropic; double[] e = orthoTropic.YoungsModulus.ToDoubleArray(); double[] v = orthoTropic.PoissonsRatio.ToDoubleArray(); double[] a = orthoTropic.ThermalExpansionCoeff.ToDoubleArray(); double[] g = orthoTropic.ShearModulus.ToDoubleArray(); model.PropMaterial.SetMPOrthotropic(material.Name, ref e, ref v, ref a, ref g); } model.PropMaterial.SetWeightAndMass(material.Name, 0, material.Density); } }
private bool SetObject(IMaterialFragment material) { bool success = true; if (material is IIsotropic) { IIsotropic isotropic = material as IIsotropic; success &= m_model.PropMaterial.SetMPIsotropic(material.DescriptionOrName(), isotropic.YoungsModulus, isotropic.PoissonsRatio, isotropic.ThermalExpansionCoeff) == 0; } else if (material is IOrthotropic) { IOrthotropic orthoTropic = material as IOrthotropic; if (CheckPropertyWarning(orthoTropic, x => x.YoungsModulus) && CheckPropertyWarning(orthoTropic, x => x.PoissonsRatio) && CheckPropertyWarning(orthoTropic, x => x.ThermalExpansionCoeff) && CheckPropertyWarning(orthoTropic, x => x.ShearModulus)) { double[] e = orthoTropic.YoungsModulus.ToDoubleArray(); double[] v = orthoTropic.PoissonsRatio.ToDoubleArray(); double[] a = orthoTropic.ThermalExpansionCoeff.ToDoubleArray(); double[] g = orthoTropic.ShearModulus.ToDoubleArray(); success &= m_model.PropMaterial.SetMPOrthotropic(material.DescriptionOrName(), ref e, ref v, ref a, ref g) == 0; } else { success = false; } } success &= m_model.PropMaterial.SetWeightAndMass(material.DescriptionOrName(), 2, material.Density) == 0; SetAdapterId(material, material.Name); return(success); }
private IMaterialFragment GetBrickPropertyMaterial(int brickProp) { int err = 0; IMaterialFragment material = null; double[] materialArray = new double[8]; int materialType = 0; StringBuilder materialName = new StringBuilder(St7.kMaxStrLen); err = St7.St7GetBrickPropertyType(1, brickProp, ref materialType); if (materialType != St7.mtIsotropic) { return(material); // !!! ISOTROPIC ONLY !!! } err = St7.St7GetBrickIsotropicMaterial(1, brickProp, materialArray); if (!St7Error(err)) { return(material); } err = St7.St7GetMaterialName(1, St7.ptBRICKPROP, brickProp, materialName, St7.kMaxStrLen); // !!!! Materials are set based on Poisson Ratio !!!! if (materialArray[St7.ipBeamPoisson] <= 0.2) { material = BH.Engine.Structure.Create.Concrete(materialName.ToString(), materialArray[St7.ipBrickIsoModulus], materialArray[St7.ipBrickIsoPoisson], materialArray[St7.ipBrickIsoAlpha], materialArray[St7.ipBrickIsoDensity]); } else { material = BH.Engine.Structure.Create.Steel(materialName.ToString(), materialArray[St7.ipBrickIsoModulus], materialArray[St7.ipBrickIsoPoisson], materialArray[St7.ipBrickIsoAlpha], materialArray[St7.ipBrickIsoDensity]); } return(material); }
public static string GetMaterialType(IMaterialFragment material) { Type materialType = material.GetType(); if (materialType == typeof(Aluminium)) { return("TypeID|ALUMINIUM"); } if (materialType == typeof(Steel)) { return("TypeID|STEEL"); } if (materialType == typeof(Concrete)) { return("TypeID|CONCRETE"); } if (materialType == typeof(Timber)) { return("TypeID|TIMBER"); } else { return(null); } }
private IMaterialFragment GetPlateIsotropicMaterial(int platePropNumber) { int uID = 1; int err = 0; IMaterialFragment material = null; double[] materialArray = new double[8]; StringBuilder materialName = new StringBuilder(St7.kMaxStrLen); err = St7.St7GetPlateIsotropicMaterial(uID, platePropNumber, materialArray); if (!St7Error(err)) { return(material); } err = St7.St7GetMaterialName(uID, St7.ptPLATEPROP, platePropNumber, materialName, St7.kMaxStrLen); if (!St7Error(err)) { return(material); } // !!!! Materials are set based on Poisson Ratio !!!! if (materialArray[St7.ipPlateIsoPoisson] <= 0.2) { material = BH.Engine.Structure.Create.Concrete(materialName.ToString(), materialArray[St7.ipPlateIsoModulus], materialArray[St7.ipPlateIsoPoisson], materialArray[St7.ipPlateIsoAlpha], materialArray[St7.ipPlateIsoDensity], materialArray[St7.ipPlateIsoDampingRatio]); } else { material = BH.Engine.Structure.Create.Steel(materialName.ToString(), materialArray[St7.ipPlateIsoModulus], materialArray[St7.ipPlateIsoPoisson], materialArray[St7.ipPlateIsoAlpha], materialArray[St7.ipPlateIsoDensity], materialArray[St7.ipPlateIsoDampingRatio]); } return(material); }
private IMaterialFragment GetBeamPropertyMaterial(int beamProp) { int err = 0; IMaterialFragment material = null; double[] materialArray = new double[9]; StringBuilder materialName = new StringBuilder(St7.kMaxStrLen); err = St7.St7GetBeamMaterialData(1, beamProp, materialArray); if (!St7Error(err)) { return(material); } err = St7.St7GetMaterialName(1, St7.ptBEAMPROP, beamProp, materialName, St7.kMaxStrLen); if (!St7Error(err)) { return(material); } // !!!! Materials are set based on Poisson Ratio !!!! if (materialArray[St7.ipBeamPoisson] <= 0.2) { material = BH.Engine.Structure.Create.Concrete(materialName.ToString(), materialArray[St7.ipBeamModulus], materialArray[St7.ipBeamPoisson], materialArray[St7.ipBeamAlpha], materialArray[St7.ipBeamDensity]); } else { material = BH.Engine.Structure.Create.Steel(materialName.ToString(), materialArray[St7.ipBeamModulus], materialArray[St7.ipBeamPoisson], materialArray[St7.ipBeamAlpha], materialArray[St7.ipBeamDensity]); } return(material); }
/***************************************************/ private bool CreateObject(IMaterialFragment material) { bool success = true; Helper.SetMaterial(m_model, material); //TODO: this is only halfway done - should be moved away from engine to adapter as much as possible return(success); }
/***************************************************/ private bool SetProfile(FabricatedBoxProfile profile, string sectionName, IMaterialFragment material) { if (profile.TopFlangeThickness != profile.BotFlangeThickness) { Engine.Base.Compute.RecordWarning($"Different thickness of top and bottom flange is not supported in ETABS. Section named {sectionName} pushed to ETABS is using the top thickness for both flanges."); } return(m_model.PropFrame.SetTube(sectionName, material?.DescriptionOrName() ?? "", profile.Height, profile.Width, profile.TopFlangeThickness, profile.WebThickness) == 0); }
/***************************************************/ public static void CopyCharacteristics(this IMaterialFragment toMaterial, StructuralAsset fromAsset) { double density = fromAsset.Density.ToSI(UnitType.UT_MassDensity); #if (REVIT2020 || REVIT2021) #else double dampingRatio = fromAsset.DampingRatio; #endif oM.Geometry.Vector youngsModulus = BH.Engine.Geometry.Create.Vector(fromAsset.YoungModulus.X.ToSI(UnitType.UT_Stress), fromAsset.YoungModulus.Y.ToSI(UnitType.UT_Stress), fromAsset.YoungModulus.Z.ToSI(UnitType.UT_Stress)); oM.Geometry.Vector thermalExpansionCoeff = BH.Engine.Geometry.Create.Vector(fromAsset.ThermalExpansionCoefficient.X.ToSI(UnitType.UT_ThermalExpansion), fromAsset.ThermalExpansionCoefficient.Y.ToSI(UnitType.UT_ThermalExpansion), fromAsset.ThermalExpansionCoefficient.Z.ToSI(UnitType.UT_ThermalExpansion)); oM.Geometry.Vector poissonsRatio = BH.Engine.Geometry.Create.Vector(fromAsset.PoissonRatio.X, fromAsset.PoissonRatio.Y, fromAsset.PoissonRatio.Z); oM.Geometry.Vector shearModulus = BH.Engine.Geometry.Create.Vector(fromAsset.ShearModulus.X.ToSI(UnitType.UT_Stress), fromAsset.ShearModulus.Y.ToSI(UnitType.UT_Stress), fromAsset.ShearModulus.Z.ToSI(UnitType.UT_Stress)); toMaterial.Density = density; #if (REVIT2020 || REVIT2021) #else toMaterial.DampingRatio = dampingRatio; #endif if (toMaterial is Aluminium) { Aluminium material = toMaterial as Aluminium; material.YoungsModulus = youngsModulus.X; material.ThermalExpansionCoeff = thermalExpansionCoeff.X; material.PoissonsRatio = poissonsRatio.X; } else if (toMaterial is Concrete) { Concrete material = toMaterial as Concrete; material.YoungsModulus = youngsModulus.X; material.ThermalExpansionCoeff = thermalExpansionCoeff.X; material.PoissonsRatio = poissonsRatio.X; } else if (toMaterial is Steel) { Steel material = toMaterial as Steel; material.YoungsModulus = youngsModulus.X; material.ThermalExpansionCoeff = thermalExpansionCoeff.X; material.PoissonsRatio = poissonsRatio.X; } else if (toMaterial is Timber) { Timber material = toMaterial as Timber; material.YoungsModulus = youngsModulus; material.ThermalExpansionCoeff = thermalExpansionCoeff; material.PoissonsRatio = poissonsRatio; } else if (toMaterial is GenericIsotropicMaterial) { GenericIsotropicMaterial material = toMaterial as GenericIsotropicMaterial; material.YoungsModulus = youngsModulus.X; material.ThermalExpansionCoeff = thermalExpansionCoeff.X; material.PoissonsRatio = poissonsRatio.X; } }
/***************************************************/ private bool SetProfile(ChannelProfile profile, string sectionName, IMaterialFragment material) { bool success = m_model.PropFrame.SetChannel(sectionName, material?.DescriptionOrName() ?? "", profile.Height, profile.FlangeWidth, profile.FlangeThickness, profile.WebThickness) == 0; if (success && profile.MirrorAboutLocalZ) { RecordFlippingError(sectionName); } return(success); }
public static bool IsNull(this IMaterialFragment material, string msg = "", [CallerMemberName] string methodName = "Method") { if (material == null) { ErrorMessage(methodName, "MaterialFragment", msg); return(true); } return(false); }
/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static IMaterialFragment FromRFEM(this rf.Material material) { IMaterialFragment bhMaterial = null; string[] stringArr = material.TextID.Split('@'); MaterialType matType = material.GetMaterialType();// Engine.Adapters.RFEM.Query.GetMaterialType(material); string matName = Engine.Adapters.RFEM.Query.GetMaterialName(material); switch (matType) { case MaterialType.Aluminium: bhMaterial = Engine.Structure.Create.Aluminium(matName); break; case MaterialType.Steel: bhMaterial = Engine.Structure.Create.Steel(matName); break; case MaterialType.Concrete: bhMaterial = Engine.Structure.Create.Concrete(matName); break; case MaterialType.Timber: //TODO: as this uses vector over double assumption is the the below turns Timber into an incorrect Isotropic material !!! BH.oM.Geometry.Vector young = new oM.Geometry.Vector() { X = material.ElasticityModulus, Y = material.ElasticityModulus, Z = material.ElasticityModulus }; BH.oM.Geometry.Vector poissons = new oM.Geometry.Vector() { X = material.PoissonRatio, Y = material.PoissonRatio, Z = material.PoissonRatio }; BH.oM.Geometry.Vector shear = new oM.Geometry.Vector() { X = material.ShearModulus, Y = material.ShearModulus, Z = material.ShearModulus }; BH.oM.Geometry.Vector thermal = new oM.Geometry.Vector() { X = material.ThermalExpansion, Y = material.ThermalExpansion, Z = material.ThermalExpansion }; bhMaterial = Engine.Structure.Create.Timber(matName, young, poissons, shear, thermal, material.SpecificWeight, 0.05); break; case MaterialType.Rebar: case MaterialType.Tendon: case MaterialType.Glass: case MaterialType.Cable: case MaterialType.Undefined: default: break; } bhMaterial.SetAdapterId(typeof(RFEMId), material.No); return(bhMaterial); }
/***************************************************/ /**** Constructors ****/ /***************************************************/ //Main constructor setting all of the properties of the object public CableSection( IMaterialFragment material, int numberOfCables, double cableDiameter, CableType cableType, double breakingLoad, double area, double rgy, double rgz, double j, double iy, double iz, double iw, double wely, double welz, double wply, double wplz, double centreZ, double centreY, double vz, double vpz, double vy, double vpy, double asy, double asz) { Material = material; CableDiameter = cableDiameter; NumberOfCables = numberOfCables; CableType = cableType; BreakingLoad = breakingLoad; Area = area; Rgy = rgy; Rgz = rgz; J = j; Iy = iy; Iz = iz; Iw = iw; Wely = wely; Welz = welz; Wply = wply; Wplz = wplz; CentreZ = centreZ; CentreY = centreY; Vz = vz; Vpz = vpz; Vy = vy; Vpy = vpy; Asy = asy; Asz = asz; }
/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static ISectionProperty FromRFEM(this rf.ICrossSection rfISectionProperty, rf.Material rfMaterial) { rf.CrossSection rfSectionProperty = rfISectionProperty.GetData(); string sectionName = rfSectionProperty.Description; rf3.DB_CRSC_PROPERTY[] sectionDBProps = null; object libraryObj = null; if (sectionName != "") { try { libraryObj = rfISectionProperty.GetDatabaseCrossSection(); rf3.IrfCrossSectionDB sectionFromDB = libraryObj as rf3.IrfCrossSectionDB; int propCount = sectionFromDB.rfGetPropertyCount(); sectionDBProps = new rf3.DB_CRSC_PROPERTY[propCount]; sectionFromDB.rfGetPropertyArrAll(propCount, sectionDBProps); } catch { Engine.Base.Compute.RecordWarning("Could not create section named " + sectionName + " from library parameters. Best guess on name will be used"); } } IMaterialFragment materialFragment = rfMaterial.FromRFEM(); IProfile profile = Engine.Adapters.RFEM.Compute.GetSectionProfile(sectionName, sectionDBProps); if (profile != null) { IGeometricalSection geoSection = BH.Engine.Structure.Create.SectionPropertyFromProfile(profile, materialFragment, rfSectionProperty.TextID);// this creates the right property if the right material is provided geoSection.SetAdapterId(typeof(RFEMId), rfSectionProperty.No); geoSection.Name = rfSectionProperty.TextID; return(geoSection); } else { ExplicitSection expSection = new ExplicitSection(); expSection.Material = materialFragment; expSection.Area = rfSectionProperty.AxialArea; expSection.J = rfSectionProperty.TorsionMoment; expSection.Asy = rfSectionProperty.ShearAreaY; expSection.Asz = rfSectionProperty.ShearAreaZ; expSection.Iy = rfSectionProperty.BendingMomentY; expSection.Iz = rfSectionProperty.BendingMomentZ; expSection.SetAdapterId(typeof(RFEMId), rfSectionProperty.No); expSection.Name = rfSectionProperty.TextID; return(expSection); } }
/***************************************************/ /**** Private methods ****/ /***************************************************/ private List <IMaterialFragment> ReadMaterials(List <string> ids = null) { //TODO: Implement code for reading materials from RAM if not handled per element List <IMaterialFragment> Materials = new List <IMaterialFragment>(); IMaterialFragment defaultMat = Engine.Structure.Create.Steel("Default"); Materials.Add(defaultMat); return(Materials); }
private static T PostProcessSectionCreate <T>(T section, string name, IMaterialFragment material, MaterialType materialType) where T : ISectionProperty { name = name ?? ""; section.Name = name; if (material == null && materialType != MaterialType.Undefined) { material = Query.Default(materialType); } section.Material = material; return(section); }
/***************************************************/ private static string CheckGetMaterialName(IMaterialFragment material) { if (material == null) { return("No material"); } if (string.IsNullOrEmpty(material.Name)) { return("Unnamed Material"); } return(material.Name); }
public static Bar SetMaterial(this Bar bar, IMaterialFragment material) { Bar clone = bar.GetShallowClone() as Bar; if (bar.SectionProperty == null) { Engine.Reflection.Compute.RecordError("The section property parameter is null - material has not been assigned"); return(clone); } ISectionProperty sectionClone = bar.SectionProperty.GetShallowClone() as ISectionProperty; sectionClone.Material = material; clone.SectionProperty = sectionClone; return(clone); }
public static GenericSection GenericSectionFromProfile(IProfile profile, IMaterialFragment material = null, string name = "") { //Run pre-process for section create. Calculates all section constants and checks name of profile var preProcessValues = PreProcessSectionCreate(name, profile); name = preProcessValues.Item1; profile = preProcessValues.Item2; Dictionary <string, double> constants = preProcessValues.Item3; GenericSection section = new GenericSection(profile, constants["Area"], constants["Rgy"], constants["Rgz"], constants["J"], constants["Iy"], constants["Iz"], constants["Iw"], constants["Wely"], constants["Welz"], constants["Wply"], constants["Wplz"], constants["CentreZ"], constants["CentreY"], constants["Vz"], constants["Vpz"], constants["Vy"], constants["Vpy"], constants["Asy"], constants["Asz"]); return(PostProcessSectionCreate(section, name, material, MaterialType.Undefined)); }
public static Material SetStructuralFragment(this Material material, IMaterialFragment structuralFragment) { //Clone the object Material clone = material.GetShallowClone() as Material; //null check for the list clone.Properties = clone.Properties ?? new List <IMaterialProperties>(); //Remove any reference to old structural material fragment. Only one is allowed clone.Properties = clone.Properties.Where(x => !(x is IMaterialFragment)).ToList(); //Assign the new fragment clone.Properties.Add(structuralFragment); return(clone); }
/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static IMaterialFragment ToMaterial(this IFAttribute lusasAttribute) { string attributeName = GetName(lusasAttribute); IMaterialFragment material = null; if (lusasAttribute is IFMaterialIsotropic) { material = new GenericIsotropicMaterial() { Name = attributeName, YoungsModulus = lusasAttribute.getValue("E"), PoissonsRatio = lusasAttribute.getValue("nu"), ThermalExpansionCoeff = lusasAttribute.getValue("alpha"), Density = lusasAttribute.getValue("rho") }; } else if (lusasAttribute is IFMaterialOrthotropic) { material = Engine.Structure.Create.Timber( attributeName, new Vector() { X = lusasAttribute.getValue("Ex"), Y = lusasAttribute.getValue("Ey"), Z = lusasAttribute.getValue("Ez") }, new Vector() { X = lusasAttribute.getValue("nuxy"), Y = lusasAttribute.getValue("nuyz"), Z = lusasAttribute.getValue("nuzx") }, new Vector() { X = lusasAttribute.getValue("Gxy"), Y = 0.0, Z = 0.0 }, new Vector() { X = lusasAttribute.getValue("ax"), Y = lusasAttribute.getValue("ay"), Z = lusasAttribute.getValue("az") }, lusasAttribute.getValue("rho"), 0); } int adapterNameId = lusasAttribute.getID(); material.SetAdapterId(typeof(LusasId), adapterNameId); return(material); }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ private List <IMaterialFragment> ReadMaterials(List <string> ids = null) { object[] lusasMaterials = d_LusasData.getAttributes("Material"); List <IMaterialFragment> materials = new List <IMaterialFragment>(); for (int i = 0; i < lusasMaterials.Count(); i++) { IFAttribute lusasMaterial = (IFAttribute)lusasMaterials[i]; IMaterialFragment material = Adapters.Lusas.Convert.ToMaterial(lusasMaterial); if (material != null) { materials.Add(material); } } return(materials); }
/***************************************************/ public static EMATERIALTYPES ToRAM(this IMaterialFragment material) { EMATERIALTYPES Material = new EMATERIALTYPES(); if (material.IMaterialType() == MaterialType.Concrete) { Material = EMATERIALTYPES.EConcreteMat; } else if (material.IMaterialType() == MaterialType.Steel) { Material = EMATERIALTYPES.ESteelMat; } else { Material = EMATERIALTYPES.ESteelMat; } return(Material); }
/***************************************************/ private bool SetProfile(TSectionProfile profile, string sectionName, IMaterialFragment material) { if (material is Steel || material is Aluminium) { return(m_model.PropFrame.SetSteelTee(sectionName, material?.DescriptionOrName() ?? "", profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness, profile.RootRadius, profile.MirrorAboutLocalY) == 0); } else if (material is Concrete) { return(m_model.PropFrame.SetConcreteTee(sectionName, material?.DescriptionOrName() ?? "", profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness, profile.WebThickness, profile.MirrorAboutLocalY) == 0); } else { bool success = m_model.PropFrame.SetTee(sectionName, material?.DescriptionOrName() ?? "", profile.Height, profile.Width, profile.FlangeThickness, profile.WebThickness) == 0; if (success && profile.MirrorAboutLocalY) { RecordFlippingError(sectionName); } return(success); } }
public static Material SetStructuralFragment(this Material material, IMaterialFragment structuralFragment) { if (material == null) { Reflection.Compute.RecordError("Physical Material provided is null and therefore SetStructuralFragment cannot be evaluated."); return(null); } //Clone the object Material clone = material.ShallowClone(); //null check for the list clone.Properties = clone.Properties ?? new List <IMaterialProperties>(); //Remove any reference to old structural material fragment. Only one is allowed clone.Properties = clone.Properties.Where(x => !(x is IMaterialFragment)).ToList(); //Assign the new fragment clone.Properties.Add(structuralFragment); return(clone); }
/***************************************************/ /*** Create Methods ***/ /***************************************************/ private bool CreateObject(IMaterialFragment material) { bool success = true; eMatType matType = eMatType.NoDesign; int colour = 0; string guid = null; string notes = ""; string name = ""; if (m_model.PropMaterial.GetMaterial(material.DescriptionOrName(), ref matType, ref colour, ref notes, ref guid) != 0) { m_model.PropMaterial.AddMaterial(ref name, MaterialTypeToCSI(material.IMaterialType()), "", "", ""); m_model.PropMaterial.ChangeName(name, material.DescriptionOrName()); success &= SetObject(material); } if (!success) { Engine.Base.Compute.RecordWarning($"Failed to assign material: {material.DescriptionOrName()}, ETABS may have overwritten some properties with default values"); } return(success); }
/***************************************************/ private bool SetProfile(TaperedProfile profile, string sectionName, IMaterialFragment material) { //Map Position domain to [0,1] profile.MapPositionDomain(); // Create a section for each sub profile IProfile[] profiles = profile.Profiles.Values.ToArray(); for (int i = 0; i < profiles.Length; i++) { ISetProfile(profiles[i], sectionName + "_SubSection" + i.ToString(), material); } // Declare some variables int num = profile.Profiles.Count - 1; string[] segmentStartProfile = new string[num]; string[] segmentEndProfile = new string[num]; double[] length = new double[num]; // Formatt section names and positions to ETABS standard double[] positions = profile.Profiles.Keys.ToArray(); for (int i = 0; i < num; i++) { segmentStartProfile[i] = sectionName + "_SubSection" + (i).ToString(); // Etabs reads this in mm, and multiplying strictly does not matter (since they're relative values), but is easier on the eyes in ETBAS later length[i] = System.Convert.ToDouble(positions[i + 1] - positions[i]) * 1000; segmentEndProfile[i] = sectionName + "_SubSection" + (i + 1).ToString(); } // Some array settings int[] type = length.Select(x => 1).ToArray <int>(); // Relative Length values, (No idea what happens or why someone would mix thease) int[] eI33 = length.Select(x => 1).ToArray <int>(); // Linear variation of EI33 int[] eI22 = length.Select(x => 1).ToArray <int>(); // Linear variation of EI22 Engine.Base.Compute.RecordNote("Tapered Sections Properties are set to vary linearly along the element in ETABS."); return(m_model.PropFrame.SetNonPrismatic(sectionName, num, ref segmentStartProfile, ref segmentEndProfile, ref length, ref type, ref eI33, ref eI22) == 0); }