Example #1
0
        internal StraightBeam(Autodesk.DesignScript.Geometry.Point ptStart, Autodesk.DesignScript.Geometry.Point ptEnd, Autodesk.DesignScript.Geometry.Vector vOrientation)
        {
            //use lock just to be safe
            //AutoCAD does not support multithreaded access
            lock (myLock)
            {
                //lock the document and start transaction
                using (var _CADAccess = new AdvanceSteel.Services.ObjectAccess.CADContext())
                {
                    string handle = AdvanceSteel.Services.ElementBinder.GetHandleFromTrace();

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

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

                        myBeam.WriteToDb();
                        handle = myBeam.Handle;
                    }

                    Beam beam = Utils.GetObject(handle) as Beam;

                    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");
                    }

                    this.Handle = handle;

                    AdvanceSteel.Services.ElementBinder.CleanupAndSetElementForTrace(beam);
                }
            }
        }
Example #2
0
        // custom function here
        private void CreateStraightBeam()
        {
            ProfileName pn = new ProfileName();

            ProfilesManager.GetProfTypeAsDefault("I", out pn);

            ASGeo.Point3d s1 = ASGeo.Point3d.kOrigin;
            ASGeo.Point3d e1 = new ASGeo.Point3d(0, 0, 3500);

            ASMod.StraightBeam b1 = new ASMod.StraightBeam(pn.Name, s1, e1, ASGeo.Vector3d.kXAxis);
            b1.WriteToDb();

            ASGeo.Point3d s2 = new ASGeo.Point3d(0, 0, 3500);
            ASGeo.Point3d e2 = new ASGeo.Point3d(0, 3000, 3500);

            ASMod.StraightBeam b2 = new ASMod.StraightBeam("AISC 14.1 W Shape#@§@#W10x33", s2, e2, ASGeo.Vector3d.kXAxis);
            // ASMod.StraightBeam b2 = new ASMod.StraightBeam("HEA  DIN18800-1#@§@#HEA200", s2, e2, ASGeo.Vector3d.kXAxis);
            b2.WriteToDb();
        }
        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);
                    Vector3d refVect   = Utils.ToAstVector3d(vOrientation, 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, refVect);
                        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, refVect);
                        }
                        else
                        {
                            throw new System.Exception("Not a straight Beam");
                        }
                    }
                    Handle = beam.Handle;
                    SteelServices.ElementBinder.CleanupAndSetElementForTrace(beam);
                }
            }
        }
Example #4
0
        internal StraightBeam(Autodesk.DesignScript.Geometry.Point ptStart,
                              Autodesk.DesignScript.Geometry.Point ptEnd,
                              Autodesk.DesignScript.Geometry.Vector vOrientation,
                              int refAxis, bool crossSectionMirror,
                              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();

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

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

                    Autodesk.AdvanceSteel.Modelling.StraightBeam beam = null;
                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        beam = new Autodesk.AdvanceSteel.Modelling.StraightBeam(sectionName, beamStart, beamEnd, refVect);
                        if (Beam.eRefAxis.IsDefined(typeof(Beam.eRefAxis), refAxis) == true)
                        {
                            beam.RefAxis = (Beam.eRefAxis)refAxis;
                        }
                        beam.SetCrossSectionMirrored(crossSectionMirror, false);

                        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.StraightBeam;

                        if (beam != null && beam.IsKindOf(FilerObject.eObjectType.kStraightBeam))
                        {
                            string sectionType = Utils.SplitSectionName(sectionName)[0];
                            string sectionSize = Utils.SplitSectionName(sectionName)[1];
                            Utils.AdjustBeamEnd(beam, beamStart);
                            beam.SetSysStart(beamStart);
                            beam.SetSysEnd(beamEnd);
                            beam.ChangeProfile(sectionType, sectionSize);
                            if (Beam.eRefAxis.IsDefined(typeof(Beam.eRefAxis), refAxis) == true)
                            {
                                beam.RefAxis = (Beam.eRefAxis)refAxis;
                            }

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

                            beam.SetCrossSectionMirrored(crossSectionMirror, false);
                            Utils.SetOrientation(beam, refVect);

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