Exemplo n.º 1
0
        /// <summary>
        /// Set BlockName and Scale of Special Part
        /// </summary>
        /// <param name="steelObject">Input Dynamo Coordinate System</param>
        /// <param name="scale"> Input Special Part Scale</param>
        /// <param name="blockName"> Input Blockname to be used by SpecialPart</param>
        public static void SetBlock(SteelDbObject steelObject,
                                    string blockName,
                                    [DefaultArgument("1")] double scale)
        {
            using (var ctx = new SteelServices.DocContext())
            {
                string      handle = steelObject.Handle;
                FilerObject obj    = Utils.GetObject(handle);

                if (obj != null && obj.IsKindOf(FilerObject.eObjectType.kSpecialPart))
                {
                    Autodesk.AdvanceSteel.Modelling.SpecialPart specialPart = obj as Autodesk.AdvanceSteel.Modelling.SpecialPart;
                    specialPart.SetBlock(blockName, scale);
                }
                else
                {
                    throw new System.Exception("Failed to Get Special Part Object");
                }
            }
        }
Exemplo n.º 2
0
        public override Autodesk.DesignScript.Geometry.Curve GetDynCurve()
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    var anchorPattern = Utils.GetObject(Handle) as Autodesk.AdvanceSteel.Modelling.AnchorPattern;
                    if (anchorPattern == null)
                    {
                        throw new Exception("Null anchor pattern");
                    }

                    using (var point = Utils.ToDynPoint(anchorPattern.RefPoint, true))
                        using (var norm = Utils.ToDynVector(anchorPattern.Normal, true))
                        {
                            return(Autodesk.DesignScript.Geometry.Circle.ByCenterPointRadiusNormal(point, Utils.FromInternalDistanceUnits(anchorPattern.Radius, true), norm));
                        }
                }
            }
        }
Exemplo n.º 3
0
        /// <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");
                }
            }
        }
Exemplo n.º 4
0
        public override Autodesk.DesignScript.Geometry.Curve GetDynCurve()
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    var weld = Utils.GetObject(Handle) as Autodesk.AdvanceSteel.Modelling.WeldPoint;

                    if (weld == null)
                    {
                        throw new Exception("Null weld point");
                    }

                    using (var dynPoint = Utils.ToDynPoint(weld.CenterPoint, true))
                    {
                        return(Autodesk.DesignScript.Geometry.Circle.ByCenterPointRadius(dynPoint, 0.01));
                    }
                }
            }
        }
        public override Autodesk.DesignScript.Geometry.Curve GetDynCurve()
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    var beam = Utils.GetObject(Handle) as Beam;

                    Point3d asPt1 = beam.GetPointAtStart(0);
                    Point3d asPt2 = beam.GetPointAtEnd(0);

                    using (var pt1 = Utils.ToDynPoint(beam.GetPointAtStart(0), true))
                        using (var pt2 = Utils.ToDynPoint(beam.GetPointAtEnd(0), true))
                        {
                            var line = Autodesk.DesignScript.Geometry.Line.ByStartPointEndPoint(pt1, pt2);
                            return(line);
                        }
                }
            }
        }
Exemplo n.º 6
0
        internal TaperedBeam(Autodesk.DesignScript.Geometry.Point ptStart, Autodesk.DesignScript.Geometry.Point ptEnd, Autodesk.DesignScript.Geometry.Vector vOrientation, double startHeight = 100, double endHeight = 100, double webThickness = 100)
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    string handle = SteelServices.ElementBinder.GetHandleFromTrace();

                    Point3d beamStart = Utils.ToAstPoint(ptStart, true);
                    Point3d beamEnd   = Utils.ToAstPoint(ptEnd, true);

                    Autodesk.AdvanceSteel.Modelling.BeamTapered beam = null;
                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        beam = new Autodesk.AdvanceSteel.Modelling.BeamTapered(beamStart, beamEnd, Vector3d.kXAxis, startHeight, endHeight, webThickness);
                        beam.CreateComponents();
                        beam.WriteToDb();
                    }
                    else
                    {
                        beam = Utils.GetObject(handle) as BeamTapered;

                        if (beam != null && beam.IsKindOf(FilerObject.eObjectType.kBeamTapered))
                        {
                            Utils.AdjustBeamEnd(beam, beamStart);
                            beam.SetSysStart(beamStart);
                            beam.SetSysEnd(beamEnd);

                            Utils.SetOrientation(beam, Utils.ToAstVector3d(vOrientation, true));
                        }
                        else
                        {
                            throw new System.Exception("Not a tapered beam");
                        }
                    }

                    Handle = beam.Handle;
                    SteelServices.ElementBinder.CleanupAndSetElementForTrace(beam);
                }
            }
        }
Exemplo n.º 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);
        }
        internal StraightBeam(Autodesk.DesignScript.Geometry.Point ptStart, Autodesk.DesignScript.Geometry.Point ptEnd, Autodesk.DesignScript.Geometry.Vector vOrientation)
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    string handle = SteelServices.ElementBinder.GetHandleFromTrace();

                    Point3d beamStart = Utils.ToAstPoint(ptStart, true);
                    Point3d beamEnd   = Utils.ToAstPoint(ptEnd, true);

                    Autodesk.AdvanceSteel.Modelling.StraightBeam beam = null;
                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        ProfileName profName = new ProfileName();
                        ProfilesManager.GetProfTypeAsDefault("I", out profName);
                        beam = new Autodesk.AdvanceSteel.Modelling.StraightBeam(profName.Name, beamStart, beamEnd, Vector3d.kXAxis);
                        beam.WriteToDb();
                    }
                    else
                    {
                        beam = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.StraightBeam;

                        if (beam != null && beam.IsKindOf(FilerObject.eObjectType.kStraightBeam))
                        {
                            Utils.AdjustBeamEnd(beam, beamStart);
                            beam.SetSysStart(beamStart);
                            beam.SetSysEnd(beamEnd);

                            Utils.SetOrientation(beam, Utils.ToAstVector3d(vOrientation, true));
                        }
                        else
                        {
                            throw new System.Exception("Not a straight Beam");
                        }
                    }
                    Handle = beam.Handle;
                    SteelServices.ElementBinder.CleanupAndSetElementForTrace(beam);
                }
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// Get Point at a distance from the START of the Beam
 /// </summary>
 /// <param name="steelObject">Advance Steel element</param>
 /// <param name="distance"> Distance from start point</param>
 /// <returns name="point"> from beam object start point return a point by the distance value</returns>
 public static Autodesk.DesignScript.Geometry.Point GetPointFromStart(AdvanceSteel.Nodes.SteelDbObject steelObject,
                                                                      [DefaultArgument("0")] double distance)
 {
     Autodesk.DesignScript.Geometry.Point ret = Autodesk.DesignScript.Geometry.Point.ByCoordinates(0, 0, 0);
     using (var ctx = new SteelServices.DocContext())
     {
         if (steelObject != null)
         {
             FilerObject filerObj = Utils.GetObject(steelObject.Handle);
             if (filerObj != null)
             {
                 if (filerObj.IsKindOf(FilerObject.eObjectType.kBeam))
                 {
                     Autodesk.AdvanceSteel.Modelling.Beam selectedObj = filerObj as Autodesk.AdvanceSteel.Modelling.Beam;
                     Point3d foundPoint = selectedObj.GetPointAtStart(distance);
                     if (foundPoint != null)
                     {
                         ret = Utils.ToDynPoint(foundPoint, true);
                     }
                     else
                     {
                         throw new System.Exception("No Point was returned from Function");
                     }
                 }
                 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 is null");
         }
     }
     return(ret);
 }
Exemplo n.º 10
0
        /// <summary>
        /// Set a property for a Steel Object
        /// </summary>
        /// <param name="steelObject"> Steel Object</param>
        /// <param name="property"> Property object</param>
        /// <returns name="steelObject"> The updated steel object</returns>
        public static SteelDbObject SetObjectProperty(SteelDbObject steelObject, Property property)
        {
            if (property.IsReadOnly)
            {
                throw new System.Exception("property is readonly");
            }

            using (var ctx = new SteelServices.DocContext())
            {
                FilerObject fo = Utils.GetObject(steelObject.Handle);
                if (fo != null)
                {
                    property.SetToObject(fo);
                    return(steelObject);
                }
                else
                {
                    throw new System.Exception("No Advance Steel Object Found");
                }
            }
        }
Exemplo n.º 11
0
        internal RectangularBoltPattern(SteelGeometry.Point3d boltPatternInsertPoint,
                                        SteelGeometry.Vector3d vx, SteelGeometry.Vector3d vy,
                                        IEnumerable <string> handlesToConnect,
                                        List <Property> boltData, int boltCon)
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    Autodesk.AdvanceSteel.Modelling.InfinitMidScrewBoltPattern bolts = null;

                    string handle = SteelServices.ElementBinder.GetHandleFromTrace();
                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        bolts = new Autodesk.AdvanceSteel.Modelling.InfinitMidScrewBoltPattern(boltPatternInsertPoint, vx, vy);
                        Utils.SetParameters(bolts, boltData);
                        bolts.WriteToDb();
                    }
                    else
                    {
                        bolts = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.InfinitMidScrewBoltPattern;

                        if (bolts != null && bolts.IsKindOf(FilerObject.eObjectType.kInfinitMidScrewBoltPattern))
                        {
                            Utils.SetParameters(bolts, boltData);
                        }
                        else
                        {
                            throw new System.Exception("Not a rectangular pattern");
                        }
                    }

                    FilerObject[] filerObjects = Utils.GetSteelObjectsToConnect(handlesToConnect);
                    bolts.Connect(filerObjects, (AtomicElement.eAssemblyLocation)boltCon);

                    Handle = bolts.Handle;
                    SteelServices.ElementBinder.CleanupAndSetElementForTrace(bolts);
                }
            }
        }
Exemplo n.º 12
0
        public override Autodesk.DesignScript.Geometry.Curve GetDynCurve()
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    var plate = Utils.GetObject(Handle) as Autodesk.AdvanceSteel.Modelling.Plate;

                    Polyline3d astPoly = null;
                    plate.GetBaseContourPolygon(0.0, out astPoly);

                    var dynPoints = Utils.ToDynPoints(astPoly.Vertices, true);
                    var poly      = Autodesk.DesignScript.Geometry.Polygon.ByPoints(dynPoints, astPoly.IsClosed);
                    foreach (var pt in dynPoints)
                    {
                        pt.Dispose();
                    }

                    return(poly);
                }
            }
        }
Exemplo n.º 13
0
        internal WeldLine(SteelGeometry.Point3d[] astPoints, IEnumerable <string> handlesToConnect, int connectionType, bool isClosed = false)
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    string handle = SteelServices.ElementBinder.GetHandleFromTrace();

                    FilerObject existingObject = Utils.GetObject(handle);
                    existingObject?.DelFromDb();

                    var weld = new Autodesk.AdvanceSteel.Modelling.WeldLine(astPoints, Vector3d.kXAxis, Vector3d.kYAxis);
                    weld.IsClosed = isClosed;
                    weld.WriteToDb();

                    weld.Connect(Utils.GetSteelObjectsToConnect(handlesToConnect), (AtomicElement.eAssemblyLocation)connectionType);

                    Handle = weld.Handle;
                    SteelServices.ElementBinder.CleanupAndSetElementForTrace(weld);
                }
            }
        }
Exemplo n.º 14
0
        public override Autodesk.DesignScript.Geometry.Curve GetDynCurve()
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    var camera = Utils.GetObject(Handle) as Autodesk.AdvanceSteel.Modelling.SpecialPart;

                    Matrix3d cameraCS = camera.CS;
                    Vector3d xVect    = null;
                    Vector3d yVect    = null;
                    Vector3d ZVect    = null;
                    Point3d  origin   = null;
                    cameraCS.GetCoordSystem(out origin, out xVect, out yVect, out ZVect);

                    using (var dynPoint = Utils.ToDynPoint(origin, true))
                    {
                        return(Autodesk.DesignScript.Geometry.Circle.ByCenterPointRadius(dynPoint, 0.01));
                    }
                }
            }
        }
Exemplo n.º 15
0
        internal WeldPoint(SteelGeometry.Point3d astPoint, IEnumerable <string> handlesToConnect, int connectionType)
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    Autodesk.AdvanceSteel.Modelling.WeldPoint weld = null;
                    string handle = SteelServices.ElementBinder.GetHandleFromTrace();

                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        weld = new Autodesk.AdvanceSteel.Modelling.WeldPoint(astPoint, Vector3d.kXAxis, Vector3d.kYAxis);
                        weld.WriteToDb();
                    }
                    else
                    {
                        weld = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.WeldPoint;

                        if (weld != null && weld.IsKindOf(FilerObject.eObjectType.kWeldPattern))
                        {
                            Matrix3d coordinateSystem = new Matrix3d();
                            coordinateSystem.SetCoordSystem(astPoint, Vector3d.kXAxis, Vector3d.kYAxis, Vector3d.kZAxis);
                            weld.SetCS(coordinateSystem);
                        }
                        else
                        {
                            throw new System.Exception("Not a weld point");
                        }
                    }

                    FilerObject[] filerObjects = Utils.GetFilerObjects(handlesToConnect);
                    weld.Connect(filerObjects, (AtomicElement.eAssemblyLocation)connectionType);

                    Handle = weld.Handle;
                    SteelServices.ElementBinder.CleanupAndSetElementForTrace(weld);
                }
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Set Advance Steel Camera Clipping Values
        /// </summary>
        /// <param name="steelObject"> Selected Advance Steel Camera Object</param>
        /// <param name="clippingSide"> Set Clipping Side of Camera 0 - None, 1 = Upper, 2 - Lower, 3 - Both</param>
        /// <param name="upperClippingValue"> Set Upper Clipping Value</param>
        /// <param name="lowerClippingValue"> Set Lower Clipping Value</param>
        public static void SetZClipping(SteelDbObject steelObject,
                                        [DefaultArgument("3")] int clippingSide,
                                        [DefaultArgument("0")] double upperClippingValue,
                                        [DefaultArgument("0")] double lowerClippingValue)
        {
            using (var ctx = new SteelServices.DocContext())
            {
                string      handle = steelObject.Handle;
                FilerObject obj    = Utils.GetObject(handle);

                if (obj != null && obj.IsKindOf(FilerObject.eObjectType.kCamera))
                {
                    Autodesk.AdvanceSteel.ConstructionHelper.Camera camera = obj as Autodesk.AdvanceSteel.ConstructionHelper.Camera;
                    camera.setZClipping((Autodesk.AdvanceSteel.ConstructionHelper.eZClip)clippingSide,
                                        Utils.ToInternalDistanceUnits(upperClippingValue, true),
                                        Utils.ToInternalDistanceUnits(lowerClippingValue, true));
                }
                else
                {
                    throw new System.Exception("Failed to Get Camera Object");
                }
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Set Advance Steel Camera Extents / Size
        /// </summary>
        /// <param name="steelObject"> Selected Advance Steel Camera Object</param>
        /// <param name="cameraExtents"> Set Camera Extents 0 - Automatic, 3 - Fixed Size</param>
        /// <param name="xCameraSize"> Set Camera Extents in X Direction</param>
        /// <param name="yCameraSize"> Set Camera Extents in Y Direction</param>
        public static void SetXYExtents(SteelDbObject steelObject,
                                        [DefaultArgument("0")] int cameraExtents,
                                        [DefaultArgument("0")] double xCameraSize,
                                        [DefaultArgument("0")] double yCameraSize)
        {
            using (var ctx = new SteelServices.DocContext())
            {
                string      handle = steelObject.Handle;
                FilerObject obj    = Utils.GetObject(handle);

                if (obj != null && obj.IsKindOf(FilerObject.eObjectType.kCamera))
                {
                    Autodesk.AdvanceSteel.ConstructionHelper.Camera camera = obj as Autodesk.AdvanceSteel.ConstructionHelper.Camera;
                    camera.setXYExtents((Autodesk.AdvanceSteel.ConstructionHelper.Camera.eXYExtents)cameraExtents,
                                        Utils.ToInternalDistanceUnits(xCameraSize, true),
                                        Utils.ToInternalDistanceUnits(yCameraSize, true));
                }
                else
                {
                    throw new System.Exception("Failed to Get Camera Object");
                }
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Get a property from a steel object
        /// </summary>
        /// <param name="steelObject"> Steel object</param>
        /// <param name="propertyName"> Name of the property</param>
        /// <returns name="property">The desired property</returns>
        public static Property GetObjectProperty(SteelDbObject steelObject, string propertyName)
        {
            Property ret = null;

            using (var ctx = new SteelServices.DocContext())
            {
                FilerObject filerObj = Utils.GetObject(steelObject.Handle);

                Property extractionProperty = Utils.GetProperty(propertyName);
                if (extractionProperty != null)
                {
                    if (extractionProperty.EvaluateFromObject(filerObj))
                    {
                        ret = extractionProperty;
                    }
                }
                else
                {
                    throw new System.Exception("No property found for the given name");
                }
            }
            return(ret);
        }
Exemplo n.º 19
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);
        }
Exemplo n.º 20
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);
        }
Exemplo n.º 21
0
        public override Autodesk.DesignScript.Geometry.Curve GetDynCurve()
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    var camera = Utils.GetObject(Handle) as Autodesk.AdvanceSteel.ConstructionHelper.Camera;

                    Matrix3d cameraCS = camera.CameraCS;
                    Vector3d xVect    = null;
                    Vector3d yVect    = null;
                    Vector3d ZVect    = null;
                    Point3d  origin   = null;
                    cameraCS.GetCoordSystem(out origin, out xVect, out yVect, out ZVect);
                    var cameraPoint = Utils.ToDynPoint(origin, true);
                    var p1          = origin + (xVect * -100);
                    p1 = p1 + (yVect * 100);
                    var p2 = p1 + (xVect * 200);
                    var p4 = p1 + (yVect * -200);
                    var p3 = p4 + (xVect * 200);

                    List <Point3d> lstPoints = new List <Point3d>()
                    {
                        p1, p2, p3, p4
                    };

                    IEnumerable <Autodesk.DesignScript.Geometry.Point> dynPoints = Utils.ToDynPoints(lstPoints.ToArray(), true);
                    var poly = Autodesk.DesignScript.Geometry.Polygon.ByPoints(dynPoints, true);
                    foreach (var pt in dynPoints)
                    {
                        pt.Dispose();
                    }

                    return(poly);
                }
            }
        }
Exemplo n.º 22
0
        public static Dictionary <string, double> GetPhysicalLengthAndWidth(AdvanceSteel.Nodes.SteelDbObject steelObject)
        {
            Dictionary <string, double> ret = new Dictionary <string, double>();

            using (var ctx = new SteelServices.DocContext())
            {
                if (steelObject != null)
                {
                    FilerObject filerObj = Utils.GetObject(steelObject.Handle);
                    if (filerObj != null)
                    {
                        if (filerObj.IsKindOf(FilerObject.eObjectType.kPlateBase))
                        {
                            Autodesk.AdvanceSteel.Modelling.PlateBase selectedObj = filerObj as Autodesk.AdvanceSteel.Modelling.PlateBase;
                            double length = 0;
                            double width  = 0;
                            selectedObj.GetPhysLengthAndWidth(out length, out width);
                            ret.Add("Length", Utils.FromInternalDistanceUnits(length, true));
                            ret.Add("Width", Utils.FromInternalDistanceUnits(width, true));
                        }
                        else
                        {
                            throw new System.Exception("Not a Plate Object");
                        }
                    }
                    else
                    {
                        throw new System.Exception("AS Object is null");
                    }
                }
                else
                {
                    throw new System.Exception("Steel Object or Point is null");
                }
            }
            return(ret);
        }
Exemplo n.º 23
0
 /// <summary>
 /// Get Plane from planar objects like - plate, grating, slab or isolated footing
 /// </summary>
 /// <param name="steelObject"> Advance Steel element</param>
 /// <returns name="plane"> returns a plane from plannar objects - plate, slab, footing isolated or grating</returns>
 public static Autodesk.DesignScript.Geometry.Plane GetPlane(AdvanceSteel.Nodes.SteelDbObject steelObject)
 {
     Autodesk.DesignScript.Geometry.Plane ret = null;
     using (var ctx = new SteelServices.DocContext())
     {
         if (steelObject != null)
         {
             FilerObject filerObj = Utils.GetObject(steelObject.Handle);
             if (filerObj != null)
             {
                 if (filerObj.IsKindOf(FilerObject.eObjectType.kPlate) ||
                     filerObj.IsKindOf(FilerObject.eObjectType.kSlab) ||
                     filerObj.IsKindOf(FilerObject.eObjectType.kFootingIsolated) ||
                     filerObj.IsKindOf(FilerObject.eObjectType.kGrating))
                 {
                     PlateBase selectedObj = filerObj as PlateBase;
                     Plane     plane       = selectedObj.DefinitionPlane;
                     ret = Utils.ToDynPlane(plane, true);
                 }
                 else
                 {
                     throw new System.Exception("Wrong type of Steel Object found, must be a Plate, Grating, Slab or Footing Isolated - Planner Object");
                 }
             }
             else
             {
                 throw new System.Exception("No Object found via registered handle");
             }
         }
         else
         {
             throw new System.Exception("No Steel Object found");
         }
     }
     return(ret);
 }
Exemplo n.º 24
0
 /// <summary>
 /// Sets the Polycurve in an Advance Steel Polybeam
 /// </summary>
 /// <param name="polyBeam"> Advance Steel polyBeam</param>
 /// <param name="polyCurve"> Input Dynamo Polycurve</param>
 /// <returns></returns>
 public static void SetPolyCurve(PolyBeam polyBeam,
                                 Autodesk.DesignScript.Geometry.PolyCurve polyCurve)
 {
     using (var ctx = new SteelServices.DocContext())
     {
         if (polyBeam != null)
         {
             FilerObject filerObj = Utils.GetObject(polyBeam.Handle);
             if (filerObj != null)
             {
                 if (filerObj.IsKindOf(FilerObject.eObjectType.kPolyBeam))
                 {
                     Autodesk.AdvanceSteel.Modelling.PolyBeam selectedObj = filerObj as Autodesk.AdvanceSteel.Modelling.PolyBeam;
                     selectedObj.SetPolyline(Utils.ToAstPolyline3d(polyCurve, true));
                 }
                 throw new System.Exception("Wrong type of Steel Object found, must be a Polybeam");
             }
         }
         else
         {
             throw new System.Exception("No Steel Object found or Line Object is null");
         }
     }
 }
Exemplo n.º 25
0
        /// <summary>
        /// Set Advance Steel Beam Insert Reference Axis
        /// </summary>
        /// <param name="steelObject"> Advance Steel element</param>
        /// <param name="refAxis"> Input Beam reference axis UpperLeft = 0, UpperSys = 1, UpperRight = 2, MidLeft = 3, SysSys = 4, MidRight = 5, LowerLeft = 6, LowerSys = 7, LowerRight = 8, ContourCenter = 9</param>
        public static void SetBeamReferenceAxis(AdvanceSteel.Nodes.SteelDbObject steelObject,
                                                int refAxis)
        {
            if (Enum.IsDefined(typeof(Autodesk.AdvanceSteel.Modelling.Beam.eRefAxis), refAxis) == false)
            {
                throw new System.Exception("Invalid Reference axis");
            }

            using (var ctx = new SteelServices.DocContext())
            {
                if (steelObject != null)
                {
                    FilerObject filerObj = Utils.GetObject(steelObject.Handle);
                    if (filerObj != null)
                    {
                        if (filerObj.IsKindOf(FilerObject.eObjectType.kBeam))
                        {
                            Autodesk.AdvanceSteel.Modelling.Beam selectedObj = filerObj as Autodesk.AdvanceSteel.Modelling.Beam;
                            selectedObj.RefAxis = (Autodesk.AdvanceSteel.Modelling.Beam.eRefAxis)refAxis;
                        }
                        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 is null");
                }
            }
        }
Exemplo n.º 26
0
        internal CompoundBeam(Autodesk.DesignScript.Geometry.Point ptStart,
                              Autodesk.DesignScript.Geometry.Point ptEnd,
                              Autodesk.DesignScript.Geometry.Vector vOrientation,
                              List <Property> beamProperties)
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    List <Property> defaultData        = beamProperties.Where(x => x.Level == ".").ToList <Property>();
                    List <Property> postWriteDBData    = beamProperties.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>();
                    Property        foundProfName      = beamProperties.FirstOrDefault <Property>(x => x.Name == "ProfName");
                    string          sectionProfileName = "";
                    if (foundProfName != null)
                    {
                        sectionProfileName = (string)foundProfName.InternalValue;
                    }

                    string handle = SteelServices.ElementBinder.GetHandleFromTrace();

                    Point3d  beamStart = Utils.ToAstPoint(ptStart, true);
                    Point3d  beamEnd   = Utils.ToAstPoint(ptEnd, true);
                    Vector3d refVect   = Utils.ToAstVector3d(vOrientation, true);

                    string sectionType = Utils.SplitSectionName(sectionProfileName)[0];
                    string sectionName = Utils.SplitSectionName(sectionProfileName)[1];

                    Autodesk.AdvanceSteel.Modelling.CompoundStraightBeam beam = null;
                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        beam = new Autodesk.AdvanceSteel.Modelling.CompoundStraightBeam(beamStart, beamEnd, refVect);
                        beam.CreateComponents(sectionType, sectionName);

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

                        beam.WriteToDb();

                        if (postWriteDBData != null)
                        {
                            Utils.SetParameters(beam, postWriteDBData);
                        }
                    }
                    else
                    {
                        beam = Utils.GetObject(handle) as CompoundStraightBeam;

                        if (beam != null && beam.IsKindOf(FilerObject.eObjectType.kCompoundStraightBeam))
                        {
                            Utils.AdjustBeamEnd(beam, beamStart);
                            beam.SetSysStart(beamStart);
                            beam.SetSysEnd(beamEnd);

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

                            Utils.SetOrientation(beam, refVect);

                            if (postWriteDBData != null)
                            {
                                Utils.SetParameters(beam, postWriteDBData);
                            }

                            if (Utils.CompareCompoundSectionTypes(sectionType, beam.ProfSectionType))
                            {
                                if (beam.ProfSectionName != sectionName)
                                {
                                    beam.ChangeProfile(sectionType, sectionName);
                                }
                            }
                            else
                            {
                                throw new System.Exception("Failed to change section as compound section type is different than the one created the beam was created with");
                            }
                        }
                        else
                        {
                            throw new System.Exception("Not a compound beam");
                        }
                    }

                    Handle = beam.Handle;
                    SteelServices.ElementBinder.CleanupAndSetElementForTrace(beam);
                }
            }
        }
Exemplo n.º 27
0
        internal Grid(List <Property> gridProperties, double length, double width = 0, int noOfAxis = 0)
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    List <Property> defaultData     = gridProperties.Where(x => x.Level == ".").ToList <Property>();
                    List <Property> postWriteDBData = gridProperties.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>();

                    Matrix3d gridMat = (Matrix3d)defaultData.FirstOrDefault <Property>(x => x.Name == "CS").InternalValue;

                    string handle = SteelServices.ElementBinder.GetHandleFromTrace();

                    Autodesk.AdvanceSteel.Modelling.Grid myGrid = null;
                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        switch (noOfAxis)
                        {
                        case 0:
                            myGrid = new Autodesk.AdvanceSteel.Modelling.Grid1D(gridMat, length);
                            break;

                        default:
                            myGrid = new Autodesk.AdvanceSteel.Modelling.Grid1D(gridMat, length, width, noOfAxis);
                            break;
                        }
                        if (defaultData != null)
                        {
                            Utils.SetParameters(myGrid, defaultData);
                        }

                        myGrid.WriteToDb();

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

                        if (myGrid != null && myGrid.IsKindOf(FilerObject.eObjectType.kGrid))
                        {
                            myGrid.updateWidth(length);
                            if (width > 0)
                            {
                                myGrid.updateLength(width);
                                myGrid.setNumElementPerSequence(0, noOfAxis);
                            }

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

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

                    Handle = myGrid.Handle;
                    SteelServices.ElementBinder.CleanupAndSetElementForTrace(myGrid);
                }
            }
        }
Exemplo n.º 28
0
        internal RectangularShearStudsPattern(SteelGeometry.Point3d astPoint1, SteelGeometry.Point3d astPoint2, string handleToConnect,
                                              SteelGeometry.Vector3d vx, SteelGeometry.Vector3d vy,
                                              SteelGeometry.Matrix3d coordSyst,
                                              List <Property> shearStudData, int boltCon)
        {
            lock (access_obj)
            {
                List <Property> defaultShearStudData  = shearStudData.Where(x => x.Level == ".").ToList <Property>();
                List <Property> arrangerShearStudData = shearStudData.Where(x => x.Level == "Arranger").ToList <Property>();
                List <Property> postWriteDBData       = shearStudData.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>();

                int temp_nx = (int)arrangerShearStudData.FirstOrDefault <Property>(x => x.Name == "Nx").InternalValue;
                int temp_ny = (int)arrangerShearStudData.FirstOrDefault <Property>(x => x.Name == "Ny").InternalValue;

                var dx = Utils.GetRectangleLength(astPoint1, astPoint2, vx) / (temp_nx - 1);
                Utils.CheckListUpdateOrAddValue(arrangerShearStudData, "Dx", dx, "Arranger");

                var dy = Utils.GetRectangleHeight(astPoint1, astPoint2, vx) / (temp_ny - 1);
                Utils.CheckListUpdateOrAddValue(arrangerShearStudData, "Dy", dy, "Arranger");

                using (var ctx = new SteelServices.DocContext())
                {
                    Autodesk.AdvanceSteel.Modelling.Connector shearStuds = null;
                    string handle = SteelServices.ElementBinder.GetHandleFromTrace();
                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        shearStuds = new Autodesk.AdvanceSteel.Modelling.Connector();
                        Autodesk.AdvanceSteel.Arrangement.Arranger arranger = new Autodesk.AdvanceSteel.Arrangement.RectangularArranger(Matrix2d.kIdentity, dx, dy, temp_nx, temp_ny);
                        shearStuds.Arranger = arranger;

                        if (defaultShearStudData != null)
                        {
                            Utils.SetParameters(shearStuds, defaultShearStudData);
                        }

                        Utils.SetParameters(shearStuds.Arranger, arrangerShearStudData);

                        shearStuds.WriteToDb();

                        if (postWriteDBData != null)
                        {
                            Utils.SetParameters(shearStuds, postWriteDBData);
                        }
                    }
                    else
                    {
                        shearStuds = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.Connector;
                        if (shearStuds != null || shearStuds.IsKindOf(FilerObject.eObjectType.kConnector))
                        {
                            if (defaultShearStudData != null)
                            {
                                Utils.SetParameters(shearStuds, defaultShearStudData);
                            }

                            Utils.SetParameters(shearStuds.Arranger, arrangerShearStudData);

                            if (postWriteDBData != null)
                            {
                                Utils.SetParameters(shearStuds, postWriteDBData);
                            }
                        }
                        else
                        {
                            throw new System.Exception("Not a shear stud pattern");
                        }
                    }

                    FilerObject obj = Utils.GetObject(handleToConnect);
                    Autodesk.AdvanceSteel.Modelling.WeldPoint weld = shearStuds.Connect(obj, coordSyst);
                    weld.AssemblyLocation = (AtomicElement.eAssemblyLocation)boltCon;

                    Handle = shearStuds.Handle;
                    SteelServices.ElementBinder.CleanupAndSetElementForTrace(shearStuds);
                }
            }
        }
Exemplo n.º 29
0
        internal ConcreteStraightBeam(string concName,
                                      Autodesk.DesignScript.Geometry.Point ptStart,
                                      Autodesk.DesignScript.Geometry.Point ptEnd,
                                      Autodesk.DesignScript.Geometry.Vector vOrientation,
                                      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>();

                    string handle = SteelServices.ElementBinder.GetHandleFromTrace();

                    Point3d  beamStart = Utils.ToAstPoint(ptStart, true);
                    Point3d  beamEnd   = Utils.ToAstPoint(ptEnd, true);
                    Vector3d refVect   = Utils.ToAstVector3d(vOrientation, true);

                    Autodesk.AdvanceSteel.Modelling.ConcreteBeam concBeam = null;
                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        concBeam = new Autodesk.AdvanceSteel.Modelling.ConcreteBeam(concName, beamStart, beamEnd, refVect);
                        if (defaultData != null)
                        {
                            Utils.SetParameters(concBeam, defaultData);
                        }

                        concBeam.WriteToDb();

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

                        if (concBeam != null && concBeam.IsKindOf(FilerObject.eObjectType.kConcreteBeam))
                        {
                            Utils.AdjustBeamEnd(concBeam, beamStart);
                            concBeam.SetSysStart(beamStart);
                            concBeam.SetSysEnd(beamEnd);
                            concBeam.ProfName = concName;

                            Utils.SetOrientation(concBeam, refVect);

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

                            if (postWriteDBData != null)
                            {
                                Utils.SetParameters(concBeam, postWriteDBData);
                            }
                        }
                        else
                        {
                            throw new System.Exception("Not a Concrete Straight Beam");
                        }
                    }
                    Handle = concBeam.Handle;
                    SteelServices.ElementBinder.CleanupAndSetElementForTrace(concBeam);
                }
            }
        }
Exemplo n.º 30
0
        internal PolyBeam(Polyline3d poly,
                          Autodesk.DesignScript.Geometry.Vector vOrientation,
                          List <Property> beamProperties)
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    List <Property> defaultData     = beamProperties.Where(x => x.Level == ".").ToList <Property>();
                    List <Property> postWriteDBData = beamProperties.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>();
                    Property        foundProfName   = beamProperties.FirstOrDefault <Property>(x => x.Name == "ProfName");
                    string          sectionName     = "";
                    if (foundProfName != null)
                    {
                        sectionName = (string)foundProfName.InternalValue;
                    }

                    string handle = SteelServices.ElementBinder.GetHandleFromTrace();

                    if (string.IsNullOrEmpty(sectionName))
                    {
                        ProfileName profName = new ProfileName();
                        ProfilesManager.GetProfTypeAsDefault("I", out profName);
                        sectionName = profName.Name;
                    }

                    Vector3d refVect = Utils.ToAstVector3d(vOrientation, true);

                    Autodesk.AdvanceSteel.Modelling.PolyBeam beam = null;
                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        beam = new Autodesk.AdvanceSteel.Modelling.PolyBeam(sectionName, poly, refVect);

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

                        beam.WriteToDb();

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

                        if (beam != null && beam.IsKindOf(FilerObject.eObjectType.kPolyBeam))
                        {
                            beam.SetPolyline(poly);

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

                            Utils.SetOrientation(beam, refVect);

                            if (postWriteDBData != null)
                            {
                                Utils.SetParameters(beam, postWriteDBData);
                            }
                        }
                        else
                        {
                            throw new System.Exception("Not an UnFolded Straight Beam");
                        }
                    }
                    Handle = beam.Handle;
                    SteelServices.ElementBinder.CleanupAndSetElementForTrace(beam);
                }
            }
        }