示例#1
0
        internal Walls(SteelGeometry.Point3d ptCenter,
                       double dLength, double dHeight, double thickness,
                       SteelGeometry.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>();

                    SteelGeometry.Plane plane = new SteelGeometry.Plane(ptCenter, vNormal);
                    Autodesk.AdvanceSteel.Modelling.Wall wallObject = null;
                    string handle = SteelServices.ElementBinder.GetHandleFromTrace();

                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        wallObject           = new Autodesk.AdvanceSteel.Modelling.Wall(plane, ptCenter, dLength, dHeight);
                        wallObject.Thickness = thickness;
                        if (defaultData != null)
                        {
                            Utils.SetParameters(wallObject, defaultData);
                        }

                        wallObject.WriteToDb();

                        if (postWriteDBData != null)
                        {
                            Utils.SetParameters(wallObject, postWriteDBData);
                        }
                    }
                    else
                    {
                        wallObject = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.Wall;
                        if (wallObject != null && wallObject.IsKindOf(FilerObject.eObjectType.kWall))
                        {
                            wallObject.DefinitionPlane = plane;
                            wallObject.Thickness       = thickness;
                            wallObject.SetLength(dLength, true);
                            wallObject.SetWidth(dHeight, true);

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

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

                    Handle = wallObject.Handle;
                    SteelServices.ElementBinder.CleanupAndSetElementForTrace(wallObject);
                }
            }
        }
示例#2
0
        internal Walls(SteelGeometry.Matrix3d matrix,
                       double dLength, double dHeight, double thickness,
                       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>();

                    SteelGeometry.Point3d  baseOrigin = new SteelGeometry.Point3d();
                    SteelGeometry.Vector3d xAxis      = new SteelGeometry.Vector3d();
                    SteelGeometry.Vector3d yAxis      = new SteelGeometry.Vector3d();
                    SteelGeometry.Vector3d zAxis      = new SteelGeometry.Vector3d();
                    matrix.GetCoordSystem(out baseOrigin, out xAxis, out yAxis, out zAxis);

                    SteelGeometry.Vector3d lengthVec = xAxis * dLength;
                    SteelGeometry.Vector3d heightVec = zAxis * dHeight;

                    SteelGeometry.Point3d brPnt = new SteelGeometry.Point3d(baseOrigin).Add(lengthVec);
                    SteelGeometry.Point3d trPnt = new SteelGeometry.Point3d(brPnt).Add(heightVec);
                    SteelGeometry.Point3d tlPnt = new SteelGeometry.Point3d(baseOrigin).Add(heightVec);

                    SteelGeometry.Point3d centerWallPnt = baseOrigin.GetMidPointBetween(trPnt);

                    SteelGeometry.Point3d[] wallPoints = { baseOrigin, brPnt, trPnt, tlPnt };
                    double[] cornerRadii = (double[])System.Collections.ArrayList.Repeat(0.0, wallPoints.Length).ToArray(typeof(double));

                    SteelGeometry.Plane plane = new SteelGeometry.Plane(centerWallPnt, yAxis);

                    Autodesk.AdvanceSteel.Modelling.Wall wallObject = null;
                    string handle = SteelServices.ElementBinder.GetHandleFromTrace();

                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        wallObject           = new Autodesk.AdvanceSteel.Modelling.Wall(plane, wallPoints);
                        wallObject.Thickness = thickness;
                        Polyline3d             outerPoly          = new Polyline3d(wallPoints, cornerRadii, true, yAxis, false, 0, true, true);
                        IEnumerable <ObjectId> deletedFeaturesIds = null;
                        IEnumerable <ObjectId> newFeaturesIds     = null;
                        wallObject.SetOuterContour(outerPoly, out deletedFeaturesIds, out newFeaturesIds);

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

                        wallObject.WriteToDb();

                        if (postWriteDBData != null)
                        {
                            Utils.SetParameters(wallObject, postWriteDBData);
                        }
                    }
                    else
                    {
                        wallObject = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.Wall;
                        if (wallObject != null && wallObject.IsKindOf(FilerObject.eObjectType.kWall))
                        {
                            //TODO - Missing SetPolygon
                            wallObject.DefinitionPlane = plane;
                            wallObject.Thickness       = thickness;
                            Polyline3d             outerPoly          = new Polyline3d(wallPoints, cornerRadii, true, yAxis, false, 0, true, true);
                            IEnumerable <ObjectId> deletedFeaturesIds = null;
                            IEnumerable <ObjectId> newFeaturesIds     = null;

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

                            wallObject.SetOuterContour(outerPoly, out deletedFeaturesIds, out newFeaturesIds);

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

                    Handle = wallObject.Handle;
                    SteelServices.ElementBinder.CleanupAndSetElementForTrace(wallObject);
                }
            }
        }
示例#3
0
        internal Walls(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.Wall wallObject = null;
                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        wallObject           = new Autodesk.AdvanceSteel.Modelling.Wall(polyPlane, astPoints);
                        wallObject.Thickness = thickness;
                        Polyline3d             outerPoly          = new Polyline3d(astPoints, cornerRadii, true, astPoly.Normal, false, 0, true, true);
                        IEnumerable <ObjectId> deletedFeaturesIds = null;
                        IEnumerable <ObjectId> newFeaturesIds     = null;
                        wallObject.SetOuterContour(outerPoly, out deletedFeaturesIds, out newFeaturesIds);

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

                        wallObject.WriteToDb();

                        if (postWriteDBData != null)
                        {
                            Utils.SetParameters(wallObject, postWriteDBData);
                        }
                    }
                    else
                    {
                        wallObject = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.Wall;

                        if (wallObject != null && wallObject.IsKindOf(FilerObject.eObjectType.kWall))
                        {
                            wallObject.DefinitionPlane = polyPlane;
                            wallObject.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(wallObject, defaultData);
                            }

                            wallObject.SetOuterContour(outerPoly, out deletedFeaturesIds, out newFeaturesIds);

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

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