Esempio n. 1
0
        /// <summary>
        /// Get Plane on top of Grating Object
        /// </summary>
        /// <param name="steelObject">Advance Steel element</param>
        /// <returns name="plane"> plane on the top side of the grating</returns>
        public static Autodesk.DesignScript.Geometry.Plane GetTopPlane(AdvanceSteel.Nodes.SteelDbObject steelObject)
        {
            Autodesk.DesignScript.Geometry.Plane ret;
            //lock the document and start transaction
            using (var ctx = new SteelServices.DocContext())
            {
                string handle = steelObject.Handle;

                FilerObject obj = Utils.GetObject(handle);

                if (obj != null && obj.IsKindOf(FilerObject.eObjectType.kGrating))
                {
                    Autodesk.AdvanceSteel.Modelling.Grating grating = obj as Autodesk.AdvanceSteel.Modelling.Grating;
                    Autodesk.AdvanceSteel.Geometry.Plane    plane   = grating.GetTopPlane();
                    ret = Utils.ToDynPlane(plane, true);
                }
                else
                {
                    throw new System.Exception("Not a Grating Object");
                }
            }
            return(ret);
        }
Esempio n. 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);
                }
            }
        }
Esempio n. 3
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);
                }
            }
        }