示例#1
0
        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);
                }
            }
        }
示例#2
0
        internal Slabs(Point3d ptCenter,
                       double dRadius, double thickness,
                       Vector3d vNormal,
                       List <Property> concreteProperties)
        {
            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>();

                    Autodesk.AdvanceSteel.Geometry.Plane plane     = new Plane(ptCenter, vNormal);
                    Autodesk.AdvanceSteel.Modelling.Slab floorSlab = null;
                    string handle = SteelServices.ElementBinder.GetHandleFromTrace();

                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        floorSlab = new Autodesk.AdvanceSteel.Modelling.Slab(plane, ptCenter, dRadius, 0);
                        floorSlab.setRadius(dRadius, true); //Not Working
                        floorSlab.Thickness = thickness;
                        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 = plane;
                            floorSlab.setRadius(dRadius, true); //Not Working
                            floorSlab.Thickness = thickness;

                            if (defaultData != null)
                            {
                                Utils.SetParameters(floorSlab, defaultData);
                            }

                            if (postWriteDBData != null)
                            {
                                Utils.SetParameters(floorSlab, postWriteDBData);
                            }
                        }
                        else
                        {
                            throw new System.Exception("Not a Slab");
                        }
                    }

                    Handle = floorSlab.Handle;
                    SteelServices.ElementBinder.CleanupAndSetElementForTrace(floorSlab);
                }
            }
        }