示例#1
0
        internal CompoundBeam(Autodesk.DesignScript.Geometry.Point ptStart, Autodesk.DesignScript.Geometry.Point ptEnd, Autodesk.DesignScript.Geometry.Vector vOrientation, string beamSection)
        {
            //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);

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

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

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

                    CompoundStraightBeam beamCompound = Utils.GetObject(handle) as CompoundStraightBeam;

                    if (beamCompound != null && beamCompound.IsKindOf(FilerObject.eObjectType.kCompoundStraightBeam))
                    {
                        Utils.AdjustBeamEnd(beamCompound, beamStart);
                        beamCompound.SetSysStart(beamStart);
                        beamCompound.SetSysEnd(beamEnd);
                        Utils.SetOrientation(beamCompound, Utils.ToAstVector3d(vOrientation, true));

                        if (Utils.CompareCompoundSectionTypes(sectionType, beamCompound.ProfSectionType))
                        {
                            if (beamCompound.ProfSectionName != sectionName)
                            {
                                beamCompound.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");
                    }

                    this.Handle = handle;

                    AdvanceSteel.Services.ElementBinder.CleanupAndSetElementForTrace(beamCompound);
                }
            }
        }
        internal CompoundBeam(Autodesk.DesignScript.Geometry.Point ptStart, Autodesk.DesignScript.Geometry.Point ptEnd, Autodesk.DesignScript.Geometry.Vector vOrientation, string beamSection)
        {
            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);

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

                    Autodesk.AdvanceSteel.Modelling.CompoundStraightBeam beam = null;
                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        beam = new Autodesk.AdvanceSteel.Modelling.CompoundStraightBeam(beamStart, beamEnd, Vector3d.kXAxis);
                        beam.CreateComponents(sectionType, sectionName);
                        Utils.SetOrientation(beam, Utils.ToAstVector3d(vOrientation, true));

                        beam.WriteToDb();
                    }
                    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);
                            Utils.SetOrientation(beam, Utils.ToAstVector3d(vOrientation, true));

                            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);
                }
            }
        }
示例#3
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);
                }
            }
        }