public override IEnumerable <Autodesk.DesignScript.Interfaces.IGraphicItem> GetDynGeometry() { IList <Autodesk.DesignScript.Interfaces.IGraphicItem> ret = new List <Autodesk.DesignScript.Interfaces.IGraphicItem>(); lock (access_obj) { using (var ctx = new SteelServices.DocContext()) { var myGrid = Utils.GetObject(Handle) as Autodesk.AdvanceSteel.Modelling.Grid; Matrix3d gridCS = myGrid.CS; Vector3d xVect = null; Vector3d yVect = null; Vector3d ZVect = null; Point3d origin = null; gridCS.GetCoordSystem(out origin, out xVect, out yVect, out ZVect); Autodesk.AdvanceSteel.Modelling.GridElement[] gridEles = null; myGrid.GetAllElements(out gridEles); foreach (var item in gridEles) { Curve3d curve = null; item.GetCurve(ref curve, gridCS); if (curve != null) { Point3d sp = null; Point3d ep = null; if (curve.HasStartPoint(out sp)) { if (curve.HasEndPoint(out ep)) { var line1 = Autodesk.DesignScript.Geometry.Line.ByStartPointEndPoint(Utils.ToDynPoint(sp, true), Utils.ToDynPoint(ep, true)); ret.Add(line1); } } } } } } return(ret); }
public override Autodesk.DesignScript.Geometry.Curve GetDynCurve() { lock (access_obj) { using (var ctx = new SteelServices.DocContext()) { var camera = Utils.GetObject(Handle) as Autodesk.AdvanceSteel.Modelling.SpecialPart; Matrix3d cameraCS = camera.CS; Vector3d xVect = null; Vector3d yVect = null; Vector3d ZVect = null; Point3d origin = null; cameraCS.GetCoordSystem(out origin, out xVect, out yVect, out ZVect); using (var dynPoint = Utils.ToDynPoint(origin, true)) { return(Autodesk.DesignScript.Geometry.Circle.ByCenterPointRadius(dynPoint, 0.01)); } } } }
public override Autodesk.DesignScript.Geometry.Curve GetDynCurve() { lock (access_obj) { using (var ctx = new SteelServices.DocContext()) { var camera = Utils.GetObject(Handle) as Autodesk.AdvanceSteel.ConstructionHelper.Camera; Matrix3d cameraCS = camera.CameraCS; Vector3d xVect = null; Vector3d yVect = null; Vector3d ZVect = null; Point3d origin = null; cameraCS.GetCoordSystem(out origin, out xVect, out yVect, out ZVect); var cameraPoint = Utils.ToDynPoint(origin, true); var p1 = origin + (xVect * -100); p1 = p1 + (yVect * 100); var p2 = p1 + (xVect * 200); var p4 = p1 + (yVect * -200); var p3 = p4 + (xVect * 200); List <Point3d> lstPoints = new List <Point3d>() { p1, p2, p3, p4 }; IEnumerable <Autodesk.DesignScript.Geometry.Point> dynPoints = Utils.ToDynPoints(lstPoints.ToArray(), true); var poly = Autodesk.DesignScript.Geometry.Polygon.ByPoints(dynPoints, true); foreach (var pt in dynPoints) { pt.Dispose(); } return(poly); } } }
internal BeamPolycut(AdvanceSteel.Nodes.SteelDbObject element, int cutShapeRectCircle, Autodesk.AdvanceSteel.Geometry.Point3d insertPoint, Autodesk.AdvanceSteel.Geometry.Vector3d normal, Autodesk.AdvanceSteel.Geometry.Vector3d lengthVector, int corner, List <Property> beamFeatureProperties) { lock (access_obj) { using (var ctx = new SteelServices.DocContext()) { List <Property> defaultData = beamFeatureProperties.Where(x => x.Level == ".").ToList <Property>(); List <Property> postWriteDBData = beamFeatureProperties.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>(); double length = 0; double width = 0; double radius = 0; if (defaultData.FirstOrDefault <Property>(x => x.Name == "Length") != null) { length = (double)defaultData.FirstOrDefault <Property>(x => x.Name == "Length").InternalValue; } if (defaultData.FirstOrDefault <Property>(x => x.Name == "Width") != null) { width = (double)defaultData.FirstOrDefault <Property>(x => x.Name == "Width").InternalValue; } if (defaultData.FirstOrDefault <Property>(x => x.Name == "Radius") != null) { radius = (double)defaultData.FirstOrDefault <Property>(x => x.Name == "Radius").InternalValue; } string existingFeatureHandle = SteelServices.ElementBinder.GetHandleFromTrace(); string elementHandle = element.Handle; FilerObject obj = Utils.GetObject(elementHandle); BeamMultiContourNotch beamFeat = null; if (obj != null && obj.IsKindOf(FilerObject.eObjectType.kBeam)) { if (string.IsNullOrEmpty(existingFeatureHandle) || Utils.GetObject(existingFeatureHandle) == null) { Beam bmObj = obj as Beam; switch (cutShapeRectCircle) { case 0: beamFeat = new BeamMultiContourNotch(bmObj, (Beam.eEnd) 1, insertPoint, normal, lengthVector, length, width); break; case 1: beamFeat = new BeamMultiContourNotch(bmObj, (Beam.eEnd) 1, insertPoint, normal, lengthVector, radius); break; } Vector2d offset; switch (corner) { case 0: //Top Left offset = new Vector2d(-1, 1); break; case 1: //Top Right offset = new Vector2d(1, 1); break; case 2: //Bottom Right offset = new Vector2d(1, -1); break; case 3: //Bottom left offset = new Vector2d(-1, -1); break; default: //Anything else ignore offset = new Vector2d(0, 0); break; } beamFeat.Offset = offset; if (defaultData != null) { Utils.SetParameters(beamFeat, defaultData); } bmObj.AddFeature(beamFeat); if (postWriteDBData != null) { Utils.SetParameters(beamFeat, postWriteDBData); } } else { beamFeat = Utils.GetObject(existingFeatureHandle) as BeamMultiContourNotch; if (beamFeat != null && beamFeat.IsKindOf(FilerObject.eObjectType.kBeamMultiContourNotch)) { beamFeat.End = (Beam.eEnd) 0; Matrix3d cutMatrix = beamFeat.CS; Point3d orgin = null; Vector3d xVec = null; Vector3d yVec = null; Vector3d zVec = null; cutMatrix.GetCoordSystem(out orgin, out xVec, out yVec, out zVec); xVec = new Vector3d(lengthVector); yVec = xVec.CrossProduct(normal); zVec = xVec.CrossProduct(yVec); cutMatrix.SetCoordSystem(insertPoint, xVec, yVec, zVec); beamFeat.CS = cutMatrix; Vector2d offset; switch (corner) { case 0: //Top Left offset = new Vector2d(-1, 1); break; case 1: //Top Right offset = new Vector2d(1, 1); break; case 2: //Bottom Right offset = new Vector2d(1, -1); break; case 3: //Bottom left offset = new Vector2d(-1, -1); break; default: //Anything else ignore offset = new Vector2d(0, 0); break; } beamFeat.Offset = offset; if (defaultData != null) { Utils.SetParameters(beamFeat, defaultData); } if (postWriteDBData != null) { Utils.SetParameters(beamFeat, postWriteDBData); } } else { throw new System.Exception("Not a Beam Feature"); } } } else { throw new System.Exception("No Input Element found"); } Handle = beamFeat.Handle; SteelServices.ElementBinder.CleanupAndSetElementForTrace(beamFeat); } } }
internal BeamPlaneCut(AdvanceSteel.Nodes.SteelDbObject element, int end, double shorteningLength, List <Property> beamFeatureProperties) { lock (access_obj) { using (var ctx = new SteelServices.DocContext()) { List <Property> defaultData = beamFeatureProperties.Where(x => x.Level == ".").ToList <Property>(); List <Property> postWriteDBData = beamFeatureProperties.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>(); string existingFeatureHandle = SteelServices.ElementBinder.GetHandleFromTrace(); string elementHandle = element.Handle; FilerObject obj = Utils.GetObject(elementHandle); BeamShortening beamFeat = null; if (obj != null && (obj.IsKindOf(FilerObject.eObjectType.kBeam))) { Matrix3d matrixAtPointOnBeam = null; Point3d shortPt = null; Point3d cutPoint = null; Vector3d normal = null; if (obj.IsKindOf(FilerObject.eObjectType.kBentBeam)) { BentBeam actObj = obj as BentBeam; switch (end) { case 0: //Start shortPt = actObj.GetPointAtStart(shorteningLength); break; case 1: //End shortPt = actObj.GetPointAtEnd(shorteningLength); break; } matrixAtPointOnBeam = actObj.GetCSAtPoint(shortPt); } else { Beam actObj = obj as Beam; switch (end) { case 0: //Start shortPt = actObj.GetPointAtStart(shorteningLength); break; case 1: //End shortPt = actObj.GetPointAtEnd(shorteningLength); break; } matrixAtPointOnBeam = actObj.GetCSAtPoint(shortPt); } Point3d orgin = null; Vector3d xV = null; Vector3d xY = null; Vector3d xZ = null; matrixAtPointOnBeam.GetCoordSystem(out orgin, out xV, out xY, out xZ); cutPoint = orgin; normal = (end == 0 ? xV : xV.Negate()); if (string.IsNullOrEmpty(existingFeatureHandle) || Utils.GetObject(existingFeatureHandle) == null) { AtomicElement atomic = obj as AtomicElement; beamFeat = new BeamShortening(); atomic.AddFeature(beamFeat); beamFeat.Set(cutPoint, normal); if (defaultData != null) { Utils.SetParameters(beamFeat, defaultData); } atomic.AddFeature(beamFeat); if (postWriteDBData != null) { Utils.SetParameters(beamFeat, postWriteDBData); } } else { beamFeat = Utils.GetObject(existingFeatureHandle) as BeamShortening; if (beamFeat != null && beamFeat.IsKindOf(FilerObject.eObjectType.kBeamShortening)) { beamFeat.Set(cutPoint, normal); if (defaultData != null) { Utils.SetParameters(beamFeat, defaultData); } if (postWriteDBData != null) { Utils.SetParameters(beamFeat, postWriteDBData); } } else { throw new System.Exception("Not a Beam Shorting Feature"); } } } else { throw new System.Exception("No Input Element found"); } Handle = beamFeat.Handle; SteelServices.ElementBinder.CleanupAndSetElementForTrace(beamFeat); } } }