/// <summary> /// Get Polycurve from Polybeam /// </summary> /// <param name="polyBeam"> Advance Steel polybeam</param> /// <returns name="polyCurve">The PolyCurve from the beam</returns> public static Autodesk.DesignScript.Geometry.PolyCurve GetPolyCurve(PolyBeam polyBeam) { List <Autodesk.DesignScript.Geometry.Curve> intRet = new List <Autodesk.DesignScript.Geometry.Curve>() { }; Autodesk.DesignScript.Geometry.PolyCurve ret = null; using (var ctx = new SteelServices.DocContext()) { if (polyBeam != null) { FilerObject filerObj = Utils.GetObject(polyBeam.Handle); if (filerObj != null) { if (filerObj.IsKindOf(FilerObject.eObjectType.kPolyBeam)) { Autodesk.AdvanceSteel.Modelling.PolyBeam selectedObj = filerObj as Autodesk.AdvanceSteel.Modelling.PolyBeam; Polyline3d poly = selectedObj.GetPolyline(); intRet = Utils.ToDynPolyCurves(poly, true); ret = Autodesk.DesignScript.Geometry.PolyCurve.ByJoinedCurves(intRet); } throw new System.Exception("Wrong type of Steel Object found, must be a Polybeam"); } } else { throw new System.Exception("No Steel Object found or Line Object is null"); } } return(ret); }
/// <summary> /// Sets the Polycurve in an Advance Steel Polybeam /// </summary> /// <param name="polyBeam"> Advance Steel polyBeam</param> /// <param name="polyCurve"> Input Dynamo Polycurve</param> /// <returns></returns> public static void SetPolyCurve(PolyBeam polyBeam, Autodesk.DesignScript.Geometry.PolyCurve polyCurve) { using (var ctx = new SteelServices.DocContext()) { if (polyBeam != null) { FilerObject filerObj = Utils.GetObject(polyBeam.Handle); if (filerObj != null) { if (filerObj.IsKindOf(FilerObject.eObjectType.kPolyBeam)) { Autodesk.AdvanceSteel.Modelling.PolyBeam selectedObj = filerObj as Autodesk.AdvanceSteel.Modelling.PolyBeam; selectedObj.SetPolyline(Utils.ToAstPolyline3d(polyCurve, true)); } throw new System.Exception("Wrong type of Steel Object found, must be a Polybeam"); } } else { throw new System.Exception("No Steel Object found or Line Object is null"); } } }
internal PolyBeam(Polyline3d poly, Autodesk.DesignScript.Geometry.Vector vOrientation, List <Property> beamProperties) { lock (access_obj) { using (var ctx = new SteelServices.DocContext()) { List <Property> defaultData = beamProperties.Where(x => x.Level == ".").ToList <Property>(); List <Property> postWriteDBData = beamProperties.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>(); Property foundProfName = beamProperties.FirstOrDefault <Property>(x => x.Name == "ProfName"); string sectionName = ""; if (foundProfName != null) { sectionName = (string)foundProfName.InternalValue; } string handle = SteelServices.ElementBinder.GetHandleFromTrace(); if (string.IsNullOrEmpty(sectionName)) { ProfileName profName = new ProfileName(); ProfilesManager.GetProfTypeAsDefault("I", out profName); sectionName = profName.Name; } Vector3d refVect = Utils.ToAstVector3d(vOrientation, true); Autodesk.AdvanceSteel.Modelling.PolyBeam beam = null; if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null) { beam = new Autodesk.AdvanceSteel.Modelling.PolyBeam(sectionName, poly, refVect); if (defaultData != null) { Utils.SetParameters(beam, defaultData); } beam.WriteToDb(); if (postWriteDBData != null) { Utils.SetParameters(beam, postWriteDBData); } } else { beam = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.PolyBeam; if (beam != null && beam.IsKindOf(FilerObject.eObjectType.kPolyBeam)) { beam.SetPolyline(poly); if (defaultData != null) { Utils.SetParameters(beam, defaultData); } Utils.SetOrientation(beam, refVect); if (postWriteDBData != null) { Utils.SetParameters(beam, postWriteDBData); } } else { throw new System.Exception("Not an UnFolded Straight Beam"); } } Handle = beam.Handle; SteelServices.ElementBinder.CleanupAndSetElementForTrace(beam); } } }