Exemple #1
0
        /// <summary>
        /// Get Quantity in Model
        /// </summary>
        /// <param name="steelObject">Advance Steel element</param>
        /// <returns name="objectQuantity"> steelobject total quantity in the current model - numbering needs to be completed</returns>
        public static int GetQuantityInModel(AdvanceSteel.Nodes.SteelDbObject steelObject)
        {
            int ret = -1;

            using (var ctx = new SteelServices.DocContext())
            {
                if (steelObject != null)
                {
                    FilerObject filerObj = Utils.GetObject(steelObject.Handle);
                    if (filerObj != null)
                    {
                        if (filerObj.IsKindOf(FilerObject.eObjectType.kAtomicElem))
                        {
                            AtomicElement selectedObj = filerObj as AtomicElement;
                            ret = (int)selectedObj.GetQuantityInModel();
                        }
                        else
                        {
                            throw new System.Exception("Not a BEAM Object");
                        }
                    }
                    else
                    {
                        throw new System.Exception("AS Object is null");
                    }
                }
                else
                {
                    throw new System.Exception("Steel Object or Point is null");
                }
            }
            return(ret);
        }
Exemple #2
0
        /// <summary>
        /// This node can set User attributes for Advance Steel elements from Dynamo
        /// </summary>
        /// <param name="element">Advance Steel element</param>
        /// <param name="AttIdx">The index of the User attribute. Is a number between 1 and 10</param>
        /// <param name="value">Attribute value</param>
        /// <returns></returns>
        public static void SetUserAttribute(AdvanceSteel.Nodes.SteelDbObject element, int AttIdx, string value)
        {
            if (AttIdx < 1 || AttIdx > 10)
            {
                throw new System.Exception("Attribute index is not in the range from 1 to 10");
            }

            using (var ctx = new SteelServices.DocContext())
            {
                string handle = element.Handle;

                FilerObject   obj    = Utils.GetObject(handle);
                AtomicElement atomic = obj as AtomicElement;

                if (obj != null && obj.IsKindOf(FilerObject.eObjectType.kAtomicElem))
                {
                    //[1, 10] ->[0 ,9]
                    AttIdx = AttIdx - 1;

                    atomic.SetUserAttribute(AttIdx, value);
                }
                else
                {
                    throw new System.Exception("Failed to set attribute");
                }
            }
        }
        public IActionResult GetById(string id)
        {
            var item = AtomicElement.FindElement();

            if (item == null)
            {
                return(HttpNotFound());
            }
            return(new ObjectResult(item));
        }
Exemple #4
0
        /// <summary>
        /// Get intersection point of Steel object system line with Dynamo plane
        /// </summary>
        /// <param name="steelObject"> Advance Steel element</param>
        /// <param name="intersectionPlane"> Dynamo Plane to intersect with Steel body</param>
        /// <returns name="point"> point formed by cutting the system line through a plane</returns>
        public static Autodesk.DesignScript.Geometry.Point CutSystemLineByPlane(AdvanceSteel.Nodes.SteelDbObject steelObject,
                                                                                Autodesk.DesignScript.Geometry.Plane intersectionPlane)
        {
            Autodesk.DesignScript.Geometry.Point ret = Autodesk.DesignScript.Geometry.Point.ByCoordinates(0, 0, 0);
            using (var ctx = new SteelServices.DocContext())
            {
                if (steelObject != null || intersectionPlane != null)
                {
                    FilerObject filerObj = Utils.GetObject(steelObject.Handle);
                    Plane       cutPlane = Utils.ToAstPlane(intersectionPlane, true);
                    if (filerObj != null)
                    {
                        AtomicElement selectedObj = filerObj as AtomicElement;

                        if (selectedObj.IsKindOf(FilerObject.eObjectType.kBeam))
                        {
                            Autodesk.AdvanceSteel.Modelling.Beam passedBeam = selectedObj as Autodesk.AdvanceSteel.Modelling.Beam;
                            Line3d    line   = new Line3d(passedBeam.GetPointAtStart(), passedBeam.GetPointAtEnd());
                            Point3d[] intPts = new Point3d[] { };
                            cutPlane.IntersectWith(line, ref intPts, new Tol());

                            if (intPts.Length > 0)
                            {
                                ret = Utils.ToDynPoint(intPts[0], true);
                            }
                            else
                            {
                                throw new System.Exception("No Intersection point found on steel object with current plane");
                            }
                        }
                    }
                    else
                    {
                        throw new System.Exception("No Object found via registered handle");
                    }
                }
                else
                {
                    throw new System.Exception("No Steel Object found or Plane is Null");
                }
            }
            return(ret);
        }
Exemple #5
0
        /// <summary>
        /// Get points on the steel body that interected with line
        /// </summary>
        /// <param name="steelObject"> Advance Steel element</param>
        /// <param name="bodyResolution"> Set Steel body display resolution</param>
        /// <param name="line"> Dynamo Line to intersect with Steel body</param>
        /// <returns name="points"> list of points that are returned by intersction a line through a steel object based on the object display mode / resolution</returns>
        public static List <Autodesk.DesignScript.Geometry.Point> IntersectElementByLine(AdvanceSteel.Nodes.SteelDbObject steelObject,
                                                                                         int bodyResolution,
                                                                                         Autodesk.DesignScript.Geometry.Line line)
        {
            List <Autodesk.DesignScript.Geometry.Point> ret = new List <Autodesk.DesignScript.Geometry.Point>()
            {
            };

            using (var ctx = new SteelServices.DocContext())
            {
                if (steelObject != null || line != null)
                {
                    FilerObject filerObj      = Utils.GetObject(steelObject.Handle);
                    Line3d      projectedLine = Utils.ToAstLine3D(line, true);
                    Point3d     originPoint   = Utils.ToAstPoint(line.StartPoint, true);
                    if (filerObj != null)
                    {
                        AtomicElement selectedObj = filerObj as AtomicElement;
                        Point3d[]     foundPoints = null;

                        ModelerBody modelerTestBody = selectedObj.GetModeler((BodyContext.eBodyContext)bodyResolution);
                        if (modelerTestBody.IntersectWith(projectedLine, out foundPoints))
                        {
                            foundPoints = foundPoints.OrderByDescending(Ptx => Ptx.DistanceTo(originPoint)).ToArray();
                            for (int i = 0; i < foundPoints.Length; i++)
                            {
                                ret.Add(Utils.ToDynPoint(foundPoints[i], true));
                            }
                        }
                    }
                    else
                    {
                        throw new System.Exception("No Object found via registered handle");
                    }
                }
                else
                {
                    throw new System.Exception("No Steel Object found or Line Object is null");
                }
            }
            return(ret);
        }
        /// <summary>
        /// This node can set the Material for Advance Steel elements from Dynamo
        /// </summary>
        /// <param name="element">Advance Steel element</param>
        /// <param name="materialName">Material</param>
        /// <returns></returns>
        public static void SetMaterial(AdvanceSteel.Nodes.SteelDbObject element, string materialName)
        {
            //lock the document and start transaction
            using (var ctx = new SteelServices.DocContext())
            {
                string handle = element.Handle;

                FilerObject obj = Utils.GetObject(handle);

                if (obj != null && obj.IsKindOf(FilerObject.eObjectType.kAtomicElem))
                {
                    AtomicElement atomic = obj as AtomicElement;
                    atomic.Material = materialName;
                }
                else
                {
                    throw new System.Exception("Failed to set material");
                }
            }
        }
Exemple #7
0
        /// <summary>
        /// Get line segments of steel body that interected with plane
        /// </summary>
        /// <param name="steelObject"> Advance Steel element</param>
        /// <param name="bodyResolution"> Set Steel body display resolution</param>
        /// <param name="intersectionPlane"> Dynamo Plane to intersect with Steel body</param>
        /// <returns name="lines"> list of lines that form the section created by passing the steel object through the plane</returns>
        public static List <Autodesk.DesignScript.Geometry.Line> CutElementByPlane(AdvanceSteel.Nodes.SteelDbObject steelObject,
                                                                                   int bodyResolution,
                                                                                   Autodesk.DesignScript.Geometry.Plane intersectionPlane)
        {
            List <Autodesk.DesignScript.Geometry.Line> ret = new List <Autodesk.DesignScript.Geometry.Line>()
            {
            };

            using (var ctx = new SteelServices.DocContext())
            {
                if (steelObject != null || intersectionPlane != null)
                {
                    FilerObject filerObj = Utils.GetObject(steelObject.Handle);
                    Plane       cutPlane = Utils.ToAstPlane(intersectionPlane, true);
                    if (filerObj != null)
                    {
                        AtomicElement selectedObj = filerObj as AtomicElement;

                        ModelerBody modelerTestBody = selectedObj.GetModeler((BodyContext.eBodyContext)bodyResolution);
                        LineSeg3d[] segs            = null;

                        modelerTestBody.IntersectWith(cutPlane, out segs);
                        for (int i = 0; i < segs.Length; i++)
                        {
                            Autodesk.DesignScript.Geometry.Point dynStartPoint = Utils.ToDynPoint(segs[i].StartPoint, true);
                            Autodesk.DesignScript.Geometry.Point dynEndPoint   = Utils.ToDynPoint(segs[i].EndPoint, true);
                            ret.Add(Autodesk.DesignScript.Geometry.Line.ByStartPointEndPoint(dynStartPoint, dynEndPoint));
                        }
                    }
                    else
                    {
                        throw new System.Exception("No Object found via registered handle");
                    }
                }
                else
                {
                    throw new System.Exception("No Steel Object found or Plane is Null");
                }
            }
            return(ret);
        }
Exemple #8
0
        internal PlatePolycut(AdvanceSteel.Nodes.SteelDbObject element,
                              double xOffset, double yOffset, int corner,
                              int cutShapeRectCircle,
                              List <Property> plateFeatureProperties)
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    List <Property> defaultData     = plateFeatureProperties.Where(x => x.Level == ".").ToList <Property>();
                    List <Property> postWriteDBData = plateFeatureProperties.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>();

                    double length = 0;
                    double width  = 0;
                    double radius = 0;

                    if (defaultData.FirstOrDefault <Property>(x => x.Name == "Length") != null)
                    {
                        length = (double)defaultData.FirstOrDefault <Property>(x => x.Name == "Length").InternalValue;
                    }
                    if (defaultData.FirstOrDefault <Property>(x => x.Name == "Width") != null)
                    {
                        width = (double)defaultData.FirstOrDefault <Property>(x => x.Name == "Width").InternalValue;
                    }
                    if (defaultData.FirstOrDefault <Property>(x => x.Name == "Radius") != null)
                    {
                        radius = (double)defaultData.FirstOrDefault <Property>(x => x.Name == "Radius").InternalValue;
                    }

                    string existingFeatureHandle = SteelServices.ElementBinder.GetHandleFromTrace();

                    string           elementHandle = element.Handle;
                    FilerObject      obj           = Utils.GetObject(elementHandle);
                    PlateFeatContour plateFeat     = null;
                    if (obj != null && obj.IsKindOf(FilerObject.eObjectType.kPlate))
                    {
                        if (string.IsNullOrEmpty(existingFeatureHandle) || Utils.GetObject(existingFeatureHandle) == null)
                        {
                            Matrix2d m2d = new Matrix2d();
                            m2d.SetCoordSystem(new Point2d(xOffset, yOffset), new Vector2d(1, 0), new Vector2d(0, 1));
                            switch (cutShapeRectCircle)
                            {
                            case 0:
                                plateFeat = new PlateFeatContour(m2d, length, width);
                                break;

                            case 1:
                                plateFeat = new PlateFeatContour(m2d, radius);
                                break;
                            }

                            Vector2d offset;
                            switch (corner)
                            {
                            case 0: //Top Left
                                offset = new Vector2d(-1, 1);
                                break;

                            case 1: //Top Right
                                offset = new Vector2d(1, 1);
                                break;

                            case 2: //Bottom Right
                                offset = new Vector2d(1, -1);
                                break;

                            case 3: //Bottom left
                                offset = new Vector2d(-1, -1);
                                break;

                            default: //Anything else ignore
                                offset = new Vector2d(0, 0);
                                break;
                            }
                            plateFeat.Offset = offset;
                            AtomicElement atomic = obj as AtomicElement;

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

                            atomic.AddFeature(plateFeat);

                            if (postWriteDBData != null)
                            {
                                Utils.SetParameters(plateFeat, postWriteDBData);
                            }
                        }
                        else
                        {
                            plateFeat = Utils.GetObject(existingFeatureHandle) as PlateFeatContour;
                            if (plateFeat != null && plateFeat.IsKindOf(FilerObject.eObjectType.kPlateFeatContour))
                            {
                                Plate plate = obj as Plate;
                                plate.DelFeature(plateFeat);
                                plate.WriteToDb();

                                Matrix2d m2d = new Matrix2d();
                                m2d.SetCoordSystem(new Point2d(xOffset, yOffset), new Vector2d(1, 0), new Vector2d(0, 1));
                                switch (cutShapeRectCircle)
                                {
                                case 0:
                                    plateFeat = new PlateFeatContour(m2d, length, width);
                                    break;

                                case 1:
                                    plateFeat = new PlateFeatContour(m2d, radius);
                                    break;
                                }

                                Vector2d offset;
                                switch (corner)
                                {
                                case 0: //Top Left
                                    offset = new Vector2d(-1, 1);
                                    break;

                                case 1: //Top Right
                                    offset = new Vector2d(1, 1);
                                    break;

                                case 2: //Bottom Right
                                    offset = new Vector2d(1, -1);
                                    break;

                                case 3: //Bottom left
                                    offset = new Vector2d(-1, -1);
                                    break;

                                default: //Anything else ignore
                                    offset = new Vector2d(0, 0);
                                    break;
                                }
                                plateFeat.Offset = offset;
                                AtomicElement atomic = obj as AtomicElement;

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

                                atomic.AddFeature(plateFeat);

                                if (postWriteDBData != null)
                                {
                                    Utils.SetParameters(plateFeat, postWriteDBData);
                                }
                            }
                            else
                            {
                                throw new System.Exception("Not a Plate Feature");
                            }
                        }
                    }
                    else
                    {
                        throw new System.Exception("No Input Element found");
                    }

                    Handle = plateFeat.Handle;
                    SteelServices.ElementBinder.CleanupAndSetElementForTrace(plateFeat);
                }
            }
        }
Exemple #9
0
        internal PlatePolycut(AdvanceSteel.Nodes.SteelDbObject element,
                              Polyline3d cutPolyline,
                              Autodesk.AdvanceSteel.Geometry.Vector3d normal,
                              Autodesk.AdvanceSteel.Geometry.Vector3d lengthVector,
                              List <Property> plateFeatureProperties)
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    List <Property> defaultData     = plateFeatureProperties.Where(x => x.Level == ".").ToList <Property>();
                    List <Property> postWriteDBData = plateFeatureProperties.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>();

                    string existingFeatureHandle = SteelServices.ElementBinder.GetHandleFromTrace();

                    string            elementHandle = element.Handle;
                    FilerObject       obj           = Utils.GetObject(elementHandle);
                    PlateContourNotch plateFeat     = null;
                    if (obj != null && obj.IsKindOf(FilerObject.eObjectType.kPlate))
                    {
                        if (string.IsNullOrEmpty(existingFeatureHandle) || Utils.GetObject(existingFeatureHandle) == null)
                        {
                            Plate plate = obj as Plate;
                            plateFeat = new PlateContourNotch(plate, 0, cutPolyline, normal, lengthVector);

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

                            plate.AddFeature(plateFeat);

                            if (postWriteDBData != null)
                            {
                                Utils.SetParameters(plateFeat, postWriteDBData);
                            }
                        }
                        else
                        {
                            plateFeat = Utils.GetObject(existingFeatureHandle) as PlateContourNotch;
                            if (plateFeat != null && plateFeat.IsKindOf(FilerObject.eObjectType.kPlateContourNotch))
                            {
                                Plate plate = obj as Plate;
                                plate.DelFeature(plateFeat);
                                plate.WriteToDb();

                                plateFeat = new PlateContourNotch(plate, 0, cutPolyline, normal, lengthVector);
                                AtomicElement atomic = obj as AtomicElement;

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

                                atomic.AddFeature(plateFeat);

                                if (postWriteDBData != null)
                                {
                                    Utils.SetParameters(plateFeat, postWriteDBData);
                                }
                            }
                            else
                            {
                                throw new System.Exception("Not a Plate Feature");
                            }
                        }
                    }
                    else
                    {
                        throw new System.Exception("No Input Element found");
                    }

                    Handle = plateFeat.Handle;
                    SteelServices.ElementBinder.CleanupAndSetElementForTrace(plateFeat);
                }
            }
        }
Exemple #10
0
        internal BeamPlaneCut(AdvanceSteel.Nodes.SteelDbObject element,
                              int end,
                              double shorteningLength,
                              List <Property> beamFeatureProperties)
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    List <Property> defaultData     = beamFeatureProperties.Where(x => x.Level == ".").ToList <Property>();
                    List <Property> postWriteDBData = beamFeatureProperties.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>();

                    string         existingFeatureHandle = SteelServices.ElementBinder.GetHandleFromTrace();
                    string         elementHandle         = element.Handle;
                    FilerObject    obj      = Utils.GetObject(elementHandle);
                    BeamShortening beamFeat = null;
                    if (obj != null && (obj.IsKindOf(FilerObject.eObjectType.kBeam)))
                    {
                        Matrix3d matrixAtPointOnBeam = null;
                        Point3d  shortPt             = null;
                        Point3d  cutPoint            = null;
                        Vector3d normal = null;
                        if (obj.IsKindOf(FilerObject.eObjectType.kBentBeam))
                        {
                            BentBeam actObj = obj as BentBeam;
                            switch (end)
                            {
                            case 0: //Start
                                shortPt = actObj.GetPointAtStart(shorteningLength);
                                break;

                            case 1: //End
                                shortPt = actObj.GetPointAtEnd(shorteningLength);
                                break;
                            }
                            matrixAtPointOnBeam = actObj.GetCSAtPoint(shortPt);
                        }
                        else
                        {
                            Beam actObj = obj as Beam;
                            switch (end)
                            {
                            case 0: //Start
                                shortPt = actObj.GetPointAtStart(shorteningLength);
                                break;

                            case 1: //End
                                shortPt = actObj.GetPointAtEnd(shorteningLength);
                                break;
                            }
                            matrixAtPointOnBeam = actObj.GetCSAtPoint(shortPt);
                        }
                        Point3d  orgin = null;
                        Vector3d xV    = null;
                        Vector3d xY    = null;
                        Vector3d xZ    = null;
                        matrixAtPointOnBeam.GetCoordSystem(out orgin, out xV, out xY, out xZ);
                        cutPoint = orgin;
                        normal   = (end == 0 ? xV : xV.Negate());
                        if (string.IsNullOrEmpty(existingFeatureHandle) || Utils.GetObject(existingFeatureHandle) == null)
                        {
                            AtomicElement atomic = obj as AtomicElement;
                            beamFeat = new BeamShortening();
                            atomic.AddFeature(beamFeat);
                            beamFeat.Set(cutPoint, normal);
                            if (defaultData != null)
                            {
                                Utils.SetParameters(beamFeat, defaultData);
                            }
                            atomic.AddFeature(beamFeat);
                            if (postWriteDBData != null)
                            {
                                Utils.SetParameters(beamFeat, postWriteDBData);
                            }
                        }
                        else
                        {
                            beamFeat = Utils.GetObject(existingFeatureHandle) as BeamShortening;
                            if (beamFeat != null && beamFeat.IsKindOf(FilerObject.eObjectType.kBeamShortening))
                            {
                                beamFeat.Set(cutPoint, normal);
                                if (defaultData != null)
                                {
                                    Utils.SetParameters(beamFeat, defaultData);
                                }

                                if (postWriteDBData != null)
                                {
                                    Utils.SetParameters(beamFeat, postWriteDBData);
                                }
                            }
                            else
                            {
                                throw new System.Exception("Not a Beam Shorting Feature");
                            }
                        }
                    }
                    else
                    {
                        throw new System.Exception("No Input Element found");
                    }

                    Handle = beamFeat.Handle;
                    SteelServices.ElementBinder.CleanupAndSetElementForTrace(beamFeat);
                }
            }
        }
Exemple #11
0
        internal BeamPlaneCut(AdvanceSteel.Nodes.SteelDbObject element,
                              Point3d cutPoint,
                              Vector3d normal,
                              List <Property> beamFeatureProperties)
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    List <Property> defaultData     = beamFeatureProperties.Where(x => x.Level == ".").ToList <Property>();
                    List <Property> postWriteDBData = beamFeatureProperties.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>();

                    string existingFeatureHandle = SteelServices.ElementBinder.GetHandleFromTrace();

                    string         elementHandle = element.Handle;
                    FilerObject    obj           = Utils.GetObject(elementHandle);
                    BeamShortening beamFeat      = null;
                    if (obj != null && (obj.IsKindOf(FilerObject.eObjectType.kBeam)))
                    {
                        if (string.IsNullOrEmpty(existingFeatureHandle) || Utils.GetObject(existingFeatureHandle) == null)
                        {
                            AtomicElement atomic = obj as AtomicElement;
                            beamFeat = new BeamShortening();
                            atomic.AddFeature(beamFeat);
                            beamFeat.Set(cutPoint, normal);
                            if (defaultData != null)
                            {
                                Utils.SetParameters(beamFeat, defaultData);
                            }
                            atomic.AddFeature(beamFeat);
                            if (postWriteDBData != null)
                            {
                                Utils.SetParameters(beamFeat, postWriteDBData);
                            }
                        }
                        else
                        {
                            beamFeat = Utils.GetObject(existingFeatureHandle) as BeamShortening;
                            if (beamFeat != null && beamFeat.IsKindOf(FilerObject.eObjectType.kBeamShortening))
                            {
                                beamFeat.Set(cutPoint, normal);
                                if (defaultData != null)
                                {
                                    Utils.SetParameters(beamFeat, defaultData);
                                }

                                if (postWriteDBData != null)
                                {
                                    Utils.SetParameters(beamFeat, postWriteDBData);
                                }
                            }
                            else
                            {
                                throw new System.Exception("Not a Beam Shorting Feature");
                            }
                        }
                    }
                    else
                    {
                        throw new System.Exception("No Input Element found");
                    }

                    Handle = beamFeat.Handle;
                    SteelServices.ElementBinder.CleanupAndSetElementForTrace(beamFeat);
                }
            }
        }
Exemple #12
0
        internal BeamCope(AdvanceSteel.Nodes.SteelDbObject element,
                          int end, int side,
                          int cnrType, double radius,
                          List <Property> beamFeatureProperties)
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    List <Property> defaultData     = beamFeatureProperties.Where(x => x.Level == ".").ToList <Property>();
                    List <Property> postWriteDBData = beamFeatureProperties.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>();

                    double length = 0;
                    double depth  = 0;

                    length = (double)defaultData.FirstOrDefault <Property>(x => x.Name == "ReferenceLength").InternalValue;
                    depth  = (double)defaultData.FirstOrDefault <Property>(x => x.Name == "ReferenceDepth").InternalValue;

                    string existingFeatureHandle = SteelServices.ElementBinder.GetHandleFromTrace();

                    string          elementHandle = element.Handle;
                    FilerObject     obj           = Utils.GetObject(elementHandle);
                    BeamNotch2Ortho beamFeat      = null;
                    if (obj != null && obj.IsKindOf(FilerObject.eObjectType.kBeam))
                    {
                        if (string.IsNullOrEmpty(existingFeatureHandle) || Utils.GetObject(existingFeatureHandle) == null)
                        {
                            beamFeat = new BeamNotch2Ortho((Beam.eEnd)end, (Beam.eSide)side, length, depth);
                            beamFeat.SetCorner((BeamNotch.eBeamNotchCornerType)cnrType, radius);

                            AtomicElement atomic = obj as AtomicElement;

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

                            atomic.AddFeature(beamFeat);

                            if (postWriteDBData != null)
                            {
                                Utils.SetParameters(beamFeat, postWriteDBData);
                            }
                        }
                        else
                        {
                            beamFeat = Utils.GetObject(existingFeatureHandle) as BeamNotch2Ortho;
                            if (beamFeat != null && beamFeat.IsKindOf(FilerObject.eObjectType.kBeamNotch2Ortho))
                            {
                                beamFeat.End  = (Beam.eEnd)end;
                                beamFeat.Side = (Beam.eSide)side;
                                beamFeat.SetCorner((BeamNotch.eBeamNotchCornerType)cnrType, radius);

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

                                if (postWriteDBData != null)
                                {
                                    Utils.SetParameters(beamFeat, postWriteDBData);
                                }
                            }
                            else
                            {
                                throw new System.Exception("Not a Beam Feature");
                            }
                        }
                    }
                    else
                    {
                        throw new System.Exception("No Input Element found");
                    }

                    Handle = beamFeat.Handle;
                    SteelServices.ElementBinder.CleanupAndSetElementForTrace(beamFeat);
                }
            }
        }
Exemple #13
0
        internal PlateVertexCut(AdvanceSteel.Nodes.SteelDbObject element,
                                int vertexFeatureType,
                                List <Property> plateFeatureProperties)
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    List <Property> defaultData     = plateFeatureProperties.Where(x => x.Level == ".").ToList <Property>();
                    List <Property> postWriteDBData = plateFeatureProperties.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>();

                    double length1 = 0;
                    double length2 = 0;
                    double radius  = 0;

                    if (defaultData.FirstOrDefault <Property>(x => x.Name == "Length1") != null)
                    {
                        length1 = (double)defaultData.FirstOrDefault <Property>(x => x.Name == "Length1").InternalValue;
                    }
                    if (defaultData.FirstOrDefault <Property>(x => x.Name == "Length2") != null)
                    {
                        length2 = (double)defaultData.FirstOrDefault <Property>(x => x.Name == "Length2").InternalValue;
                    }
                    if (defaultData.FirstOrDefault <Property>(x => x.Name == "Radius") != null)
                    {
                        radius = (double)defaultData.FirstOrDefault <Property>(x => x.Name == "Radius").InternalValue;
                    }

                    string existingFeatureHandle = SteelServices.ElementBinder.GetHandleFromTrace();

                    string              elementHandle = element.Handle;
                    FilerObject         obj           = Utils.GetObject(elementHandle);
                    PlateFeatVertFillet plateFeat     = null;
                    if (obj != null && (obj.IsKindOf(FilerObject.eObjectType.kPlate) || obj.IsKindOf(FilerObject.eObjectType.kFoldedPlate)))
                    {
                        if (string.IsNullOrEmpty(existingFeatureHandle) || Utils.GetObject(existingFeatureHandle) == null)
                        {
                            plateFeat            = new PlateFeatVertFillet();
                            plateFeat.FilletType = (FilerObject.eFilletTypes)vertexFeatureType;

                            AtomicElement atomic = obj as AtomicElement;
                            if (defaultData != null)
                            {
                                Utils.SetParameters(plateFeat, defaultData);
                            }
                            atomic.AddFeature(plateFeat);
                            if (postWriteDBData != null)
                            {
                                Utils.SetParameters(plateFeat, postWriteDBData);
                            }
                        }
                        else
                        {
                            plateFeat = Utils.GetObject(existingFeatureHandle) as PlateFeatVertFillet;
                            if (plateFeat != null && plateFeat.IsKindOf(FilerObject.eObjectType.kPlateFeatVertFillet))
                            {
                                if (defaultData != null)
                                {
                                    Utils.SetParameters(plateFeat, defaultData);
                                }

                                if (postWriteDBData != null)
                                {
                                    Utils.SetParameters(plateFeat, postWriteDBData);
                                }
                            }
                            else
                            {
                                throw new System.Exception("Not a Plate Feature");
                            }
                        }
                    }
                    else
                    {
                        throw new System.Exception("No Input Element found");
                    }

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