internal BentBeam(Autodesk.DesignScript.Geometry.Point ptStart, Autodesk.DesignScript.Geometry.Point ptEnd, Autodesk.DesignScript.Geometry.Point ptOnArc, 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();
                    var    beamStart = (ptStart == null ? new Point3d() : Utils.ToAstPoint(ptStart, true));
                    var    beamEnd   = (ptEnd == null ? new Point3d() : Utils.ToAstPoint(ptEnd, true));
                    _ptOnArc = Utils.ToAstPoint(ptOnArc, true);

                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        ProfileName profName = new ProfileName();
                        ProfilesManager.GetProfTypeAsDefault("I", out profName);

                        var myBeam = new Autodesk.AdvanceSteel.Modelling.BentBeam(profName.Name, Vector3d.kZAxis, beamStart, _ptOnArc, beamEnd);

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

                    var beam = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.BentBeam;

                    if (beam != null && beam.IsKindOf(FilerObject.eObjectType.kBentBeam))
                    {
                        beam.SetSystemline(beamStart, _ptOnArc, beamEnd);
                        Utils.SetOrientation(beam, Utils.ToAstVector3d(vOrientation, true));
                    }
                    else
                    {
                        throw new System.Exception("Not a bent Beam");
                    }

                    Handle = handle;

                    AdvanceSteel.Services.ElementBinder.CleanupAndSetElementForTrace(beam);
                }
            }
        }
示例#2
0
        internal BentBeam(Autodesk.DesignScript.Geometry.Point ptStart, Autodesk.DesignScript.Geometry.Point ptEnd, Autodesk.DesignScript.Geometry.Point ptOnArc, Autodesk.DesignScript.Geometry.Vector vOrientation)
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    string   handle    = SteelServices.ElementBinder.GetHandleFromTrace();
                    Point3d  beamStart = (ptStart == null ? new Point3d() : Utils.ToAstPoint(ptStart, true));
                    Point3d  beamEnd   = (ptEnd == null ? new Point3d() : Utils.ToAstPoint(ptEnd, true));
                    Vector3d refVect   = Utils.ToAstVector3d(vOrientation, true);
                    _ptOnArc = Utils.ToAstPoint(ptOnArc, true);

                    Autodesk.AdvanceSteel.Modelling.BentBeam beam = null;
                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        ProfileName profName = new ProfileName();
                        ProfilesManager.GetProfTypeAsDefault("I", out profName);

                        beam = new Autodesk.AdvanceSteel.Modelling.BentBeam(profName.Name, refVect, beamStart, _ptOnArc, beamEnd);
                        beam.WriteToDb();
                    }
                    else
                    {
                        beam = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.BentBeam;

                        if (beam != null && beam.IsKindOf(FilerObject.eObjectType.kBentBeam))
                        {
                            beam.SetSystemline(beamStart, _ptOnArc, beamEnd);
                            Utils.SetOrientation(beam, refVect);
                        }
                        else
                        {
                            throw new System.Exception("Not a bent Beam");
                        }
                    }

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