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); } } }
public override Autodesk.DesignScript.Geometry.Curve GetDynCurve() { lock (access_obj) { using (var ctx = new SteelServices.DocContext()) { var walls = Utils.GetObject(Handle) as Autodesk.AdvanceSteel.Modelling.Wall; SteelGeometry.Polyline3d astPoly = null; walls.GetBaseContourPolygon(0.0, out astPoly); var dynPoints = Utils.ToDynPoints(astPoly.Vertices, true); var poly = Autodesk.DesignScript.Geometry.Polygon.ByPoints(dynPoints, astPoly.IsClosed); foreach (var pt in dynPoints) { pt.Dispose(); } return(poly); } } }
internal Slabs(Autodesk.DesignScript.Geometry.Polygon poly, double thickness, List <Property> concreteProperties) { if (poly.IsPlanar == false) { throw new System.Exception("Polygon is not planar"); } lock (access_obj) { using (var ctx = new SteelServices.DocContext()) { List <Property> defaultData = concreteProperties.Where(x => x.Level == ".").ToList <Property>(); List <Property> postWriteDBData = concreteProperties.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>(); string handle = SteelServices.ElementBinder.GetHandleFromTrace(); Point3d[] astPoints = Utils.ToAstPoints(poly.Points, true); double[] cornerRadii = (double[])System.Collections.ArrayList.Repeat(0.0, poly.Points.Length).ToArray(typeof(double)); var astPoly = new Autodesk.AdvanceSteel.Geometry.Polyline3d(astPoints, null, poly.IsClosed, true); var polyPlane = new Plane(astPoints[0], astPoly.Normal); Autodesk.AdvanceSteel.Modelling.Slab floorSlab = null; if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null) { floorSlab = new Autodesk.AdvanceSteel.Modelling.Slab(polyPlane, astPoints); floorSlab.Thickness = thickness; Polyline3d outerPoly = new Polyline3d(astPoints, cornerRadii, true, astPoly.Normal, false, 0, true, true); IEnumerable <ObjectId> deletedFeaturesIds = null; IEnumerable <ObjectId> newFeaturesIds = null; floorSlab.SetOuterContour(outerPoly, out deletedFeaturesIds, out newFeaturesIds); if (defaultData != null) { Utils.SetParameters(floorSlab, defaultData); } floorSlab.WriteToDb(); if (postWriteDBData != null) { Utils.SetParameters(floorSlab, postWriteDBData); } } else { floorSlab = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.Slab; if (floorSlab != null && floorSlab.IsKindOf(FilerObject.eObjectType.kSlab)) { floorSlab.DefinitionPlane = polyPlane; floorSlab.Thickness = thickness; Polyline3d outerPoly = new Polyline3d(astPoints, cornerRadii, true, astPoly.Normal, false, 0, true, true); IEnumerable <ObjectId> deletedFeaturesIds = null; IEnumerable <ObjectId> newFeaturesIds = null; if (defaultData != null) { Utils.SetParameters(floorSlab, defaultData); } floorSlab.SetOuterContour(outerPoly, out deletedFeaturesIds, out newFeaturesIds); if (postWriteDBData != null) { Utils.SetParameters(floorSlab, postWriteDBData); } } else { throw new System.Exception("Not a Slab"); } } Handle = floorSlab.Handle; SteelServices.ElementBinder.CleanupAndSetElementForTrace(floorSlab); } } }
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); } } }