internal Plate(Autodesk.DesignScript.Geometry.Polygon poly) { if (poly.IsPlanar == false) { throw new System.Exception("Polygon is not planar"); } //use lock just to be safe //AutoCAD does not support multithreaded access lock (myLock) { //lock the document and start transaction using (var _CADAccess = new AdvanceSteel.Services.ObjectAccess.CADContext()) { string handle = AdvanceSteel.Services.ElementBinder.GetHandleFromTrace(); Point3d[] astPoints = Utils.ToAstPoints(poly.Points, true); var astPoly = new Autodesk.AdvanceSteel.Geometry.Polyline3d(astPoints, null, poly.IsClosed, true); var polyPlane = new Plane(astPoints[0], astPoly.Normal); if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null) { var myPlate = new Autodesk.AdvanceSteel.Modelling.Plate(polyPlane, astPoints); myPlate.WriteToDb(); handle = myPlate.Handle; } Autodesk.AdvanceSteel.Modelling.Plate plate = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.Plate; if (plate != null && plate.IsKindOf(FilerObject.eObjectType.kPlate)) { plate.DefinitionPlane = polyPlane; plate.SetPolygonContour(astPoints); } else { throw new System.Exception("Not a Plate"); } this.Handle = handle; AdvanceSteel.Services.ElementBinder.CleanupAndSetElementForTrace(plate); } } }
internal Plate(Autodesk.DesignScript.Geometry.Polygon poly) { if (poly.IsPlanar == false) { throw new System.Exception("Polygon is not planar"); } lock (access_obj) { using (var ctx = new SteelServices.DocContext()) { string handle = SteelServices.ElementBinder.GetHandleFromTrace(); Point3d[] astPoints = Utils.ToAstPoints(poly.Points, true); var astPoly = new Autodesk.AdvanceSteel.Geometry.Polyline3d(astPoints, null, poly.IsClosed, true); var polyPlane = new Plane(astPoints[0], astPoly.Normal); Autodesk.AdvanceSteel.Modelling.Plate plate = null; if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null) { plate = new Autodesk.AdvanceSteel.Modelling.Plate(polyPlane, astPoints); plate.WriteToDb(); } else { plate = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.Plate; if (plate != null && plate.IsKindOf(FilerObject.eObjectType.kPlate)) { plate.DefinitionPlane = polyPlane; plate.SetPolygonContour(astPoints); } else { throw new System.Exception("Not a Plate"); } } Handle = plate.Handle; SteelServices.ElementBinder.CleanupAndSetElementForTrace(plate); } } }
internal Plate(Point3d planePoint, Vector3d normal, double length, double width, int corner, List <Property> plateProperties) { lock (access_obj) { using (var ctx = new SteelServices.DocContext()) { List <Property> defaultData = plateProperties.Where(x => x.Level == ".").ToList <Property>(); List <Property> postWriteDBData = plateProperties.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>(); string handle = SteelServices.ElementBinder.GetHandleFromTrace(); var polyPlane = new Plane(planePoint, normal); Autodesk.AdvanceSteel.Modelling.Plate plate = null; if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null) { plate = new Autodesk.AdvanceSteel.Modelling.Plate(polyPlane, planePoint, length, width); plate.SetLengthAndWidth(length, width, 1); 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; } plate.Offset = offset; if (defaultData != null) { Utils.SetParameters(plate, defaultData); } plate.WriteToDb(); if (postWriteDBData != null) { Utils.SetParameters(plate, postWriteDBData); } } else { plate = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.Plate; if (plate != null && plate.IsKindOf(FilerObject.eObjectType.kPlate)) { plate.DefinitionPlane = polyPlane; plate.SetLengthAndWidth(length, width, 1); 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; } if (defaultData != null) { Utils.SetParameters(plate, defaultData); } plate.Offset = offset; if (postWriteDBData != null) { Utils.SetParameters(plate, postWriteDBData); } } else { throw new System.Exception("Not a Plate"); } } Handle = plate.Handle; SteelServices.ElementBinder.CleanupAndSetElementForTrace(plate); } } }
internal Plate(Point3d[] astPoints, Vector3d normal, List <Property> plateProperties) { //if (poly.IsPlanar == false) // throw new System.Exception("Polygon is not planar"); lock (access_obj) { using (var ctx = new SteelServices.DocContext()) { List <Property> defaultData = plateProperties.Where(x => x.Level == ".").ToList <Property>(); List <Property> postWriteDBData = plateProperties.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>(); string handle = SteelServices.ElementBinder.GetHandleFromTrace(); //Point3d[] astPoints = Utils.ToAstPoints(poly.Points, true); var astPoly = new Autodesk.AdvanceSteel.Geometry.Polyline3d(astPoints, null, true, true); if (astPoly.IsPlanar == false) { throw new System.Exception("Polygon is not planar"); } var polyPlane = new Plane(astPoints[0], normal); // astPoly.Normal); Autodesk.AdvanceSteel.Modelling.Plate plate = null; if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null) { plate = new Autodesk.AdvanceSteel.Modelling.Plate(polyPlane, astPoints); if (defaultData != null) { Utils.SetParameters(plate, defaultData); } plate.WriteToDb(); if (postWriteDBData != null) { Utils.SetParameters(plate, postWriteDBData); } } else { plate = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.Plate; if (plate != null && plate.IsKindOf(FilerObject.eObjectType.kPlate)) { plate.DefinitionPlane = polyPlane; if (defaultData != null) { Utils.SetParameters(plate, defaultData); } plate.SetPolygonContour(astPoints); if (postWriteDBData != null) { Utils.SetParameters(plate, postWriteDBData); } } else { throw new System.Exception("Not a Plate"); } } Handle = plate.Handle; SteelServices.ElementBinder.CleanupAndSetElementForTrace(plate); } } }