Exemple #1
0
        internal BarGrating(Vector3d vNormal, Point3d ptCenter, double dLength, List <Property> additionalGratingParameters)
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    List <Property> defaultData     = additionalGratingParameters.Where(x => x.Level == ".").ToList <Property>();
                    List <Property> postWriteDBData = additionalGratingParameters.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>();

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

                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        gratings = new Autodesk.AdvanceSteel.Modelling.Grating("ADT", 11, 2, "3 / 16 inch", "10", "3/16", plane, ptCenter, dLength);

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

                        gratings.WriteToDb();

                        if (postWriteDBData != null)
                        {
                            Utils.SetParameters(gratings, postWriteDBData);
                        }
                    }
                    else
                    {
                        gratings = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.Grating;
                        if (gratings != null && gratings.IsKindOf(FilerObject.eObjectType.kGrating))
                        {
                            gratings.DefinitionPlane = plane;
                            gratings.SetLength(dLength, true);

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

                            if (postWriteDBData != null)
                            {
                                Utils.SetParameters(gratings, postWriteDBData);
                            }
                        }
                        else
                        {
                            throw new System.Exception("Not a Bar Grating pattern");
                        }
                    }
                    Handle = gratings.Handle;
                    SteelServices.ElementBinder.CleanupAndSetElementForTrace(gratings);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Get Bar Grating Top Normal Vector
        /// </summary>
        /// <param name="steelObject">Advance Steel element</param>
        /// <returns name="gratingNormal"> normal direction as a vector on the top side of the grating</returns>
        public static Autodesk.DesignScript.Geometry.Vector GetTopNormal(AdvanceSteel.Nodes.SteelDbObject steelObject)
        {
            Autodesk.DesignScript.Geometry.Vector 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.Vector3d vec     = grating.GetTopNormal();
                    ret = Utils.ToDynVector(vec, true);
                }
                else
                {
                    throw new System.Exception("Not a Grating Object");
                }
            }
            return(ret);
        }
Exemple #3
0
        /// <summary>
        /// Get Bar Grating Product Name
        /// </summary>
        /// <param name="steelObject">Advance Steel element</param>
        /// <returns name="barGratingProductName"> product name as a string of the Bar Grating from Advance Steel Grating Database</returns>
        public static string GetBarGratingProductName(AdvanceSteel.Nodes.SteelDbObject steelObject)
        {
            string 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;
                    ret = grating.GetBarGratingProductName();
                }
                else
                {
                    throw new System.Exception("Not a Grating Object");
                }
            }
            return(ret);
        }
Exemple #4
0
        public static List <DynGeometry.Point> GetPointsToDraw(Autodesk.AdvanceSteel.Modelling.Grating grating)
        {
            var coordSystem = grating.CS;

            coordSystem.GetCoordSystem(out var origPt, out var vX, out var vY, out var vZ);

            var temp1 = vY * grating.Width / 2.0;
            var temp2 = vX * grating.Length / 2.0;

            var pt1 = new SteelGeometry.Point3d(grating.CenterPoint);

            pt1.Add(temp1 + temp2);

            var pt2 = new SteelGeometry.Point3d(grating.CenterPoint);

            pt2.Add(temp1 - temp2);

            var pt3 = new SteelGeometry.Point3d(grating.CenterPoint);

            pt3.Add(-temp1 - temp2);

            var pt4 = new SteelGeometry.Point3d(grating.CenterPoint);

            pt4.Add(-temp1 + temp2);


            List <DynGeometry.Point> polyPoints = new List <DynGeometry.Point>
            {
                Utils.ToDynPoint(pt1, true),
                Utils.ToDynPoint(pt2, true),
                Utils.ToDynPoint(pt3, true),
                Utils.ToDynPoint(pt4, true)
            };

            return(polyPoints);
        }
Exemple #5
0
        internal VariableGrating(Autodesk.DesignScript.Geometry.Polygon poly,
                                 Vector3d vNormal,
                                 List <Property> additionalGratingParameters)
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    List <Property> defaultData     = additionalGratingParameters.Where(x => x.Level == ".").ToList <Property>();
                    List <Property> postWriteDBData = additionalGratingParameters.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>();

                    string strClass = (string)defaultData.FirstOrDefault <Property>(x => x.Name == "GratingClass").InternalValue;
                    string strName  = (string)defaultData.FirstOrDefault <Property>(x => x.Name == "GratingSize").InternalValue;

                    Autodesk.AdvanceSteel.Geometry.Plane    plane    = new Plane(Utils.ToAstPoint(poly.Center(), true), vNormal);
                    Autodesk.AdvanceSteel.Modelling.Grating gratings = null;
                    string    handle    = SteelServices.ElementBinder.GetHandleFromTrace();
                    Point3d[] astPoints = Utils.ToAstPoints(poly.Points, true);

                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        gratings = new Autodesk.AdvanceSteel.Modelling.Grating(strClass, strName, plane, astPoints);

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

                        gratings.WriteToDb();

                        if (postWriteDBData != null)
                        {
                            Utils.SetParameters(gratings, postWriteDBData);
                        }
                    }
                    else
                    {
                        gratings = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.Grating;
                        if (gratings != null && gratings.IsKindOf(FilerObject.eObjectType.kGrating))
                        {
                            gratings.GratingClass    = strClass;
                            gratings.GratingSize     = strName;
                            gratings.DefinitionPlane = plane;
                            gratings.SetPolygonContour(astPoints);

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

                            if (postWriteDBData != null)
                            {
                                Utils.SetParameters(gratings, postWriteDBData);
                            }
                        }
                        else
                        {
                            throw new System.Exception("Not a Variable Grating pattern");
                        }
                    }

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