示例#1
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);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Implement this method as an external command for Revit.
        /// </summary>
        /// <param name="commandData">An object that is passed to the external application
        /// which contains data related to the command,
        /// such as the application object and active view.</param>
        /// <param name="message">A message that can be set by the external application
        /// which will be displayed if a failure or cancellation is returned by
        /// the external command.</param>
        /// <param name="elements">A set of elements to which the external application
        /// can add elements that are to be highlighted in case of failure or cancellation.</param>
        /// <returns>Return the status of the external command.
        /// A result of Succeeded means that the API external method functioned as expected.
        /// Cancelled can be used to signify that the user cancelled the external operation
        /// at some point. Failure should be returned if the application is unable to proceed with
        /// the operation.</returns>
        public virtual Result Execute(ExternalCommandData commandData
                                      , ref string message, ElementSet elements)
        {
            //Get the document from external command data.
            UIDocument activeDoc = commandData.Application.ActiveUIDocument;

            Autodesk.Revit.DB.Document doc = activeDoc.Document;

            if (null == doc)
            {
                return(Result.Failed);
            }

            try
            {
                // The list of elements to create the shear stud pattern on
                Reference eRef = activeDoc.Selection.PickObject(ObjectType.Face, "Please pick an element to create the shear stud pattern on");

                // Start detailed steel modeling transaction
                using (FabricationTransaction trans = new FabricationTransaction(doc, false, "Create shear stud pattern"))
                {
                    // Creating the shear stud pattern involves using AdvanceSteel classes and objects only.
                    // for more details, please consult http://www.autodesk.com/adv-steel-api-walkthroughs-2019-enu
                    FilerObject filerObj = Utilities.Functions.GetFilerObject(doc, eRef);

                    if (null == filerObj)
                    {
                        return(Result.Failed);
                    }

                    Autodesk.AdvanceSteel.Modelling.Connector shearStud = new Autodesk.AdvanceSteel.Modelling.Connector();
                    shearStud.WriteToDb();

                    // Creating a rectangle for the shear stud pattern. A Polyline3d is required for the rectangle. We will use it for the Arranger and the Matrix3d objects.
                    Polyline3d polyLine = new Polyline3d();
                    Matrix3d   matCS    = new Matrix3d();
                    Arranger   arranger = null;

                    double x = eRef.GlobalPoint.X * Utilities.Functions.FEET_TO_MM;
                    double y = eRef.GlobalPoint.Y * Utilities.Functions.FEET_TO_MM;
                    double z = eRef.GlobalPoint.Z * Utilities.Functions.FEET_TO_MM;
                    double w = 500; // width of the contour;
                    double h = 500; // height of the contour;

                    polyLine.Append(new Point3d(x, y, z));
                    polyLine.Append(new Point3d(x + w, y, z));
                    polyLine.Append(new Point3d(x + w, y + h, z));
                    polyLine.Append(new Point3d(x, y + h, z));

                    Point3d[] vertices = polyLine.Vertices;

                    if (vertices.Length == 4) //rectangular shear stud pattern
                    {
                        Vector3d xAxis1 = vertices[0].Subtract(vertices[1]);
                        Vector3d xAxis2 = vertices[0].Subtract(vertices[3]);
                        Vector3d zAxis  = new Vector3d(0, 0, 1);
                        Vector3d vDiag  = vertices[0].Subtract(vertices[2]);
                        Point3d  orig   = new Point3d(vertices[2]);
                        orig = orig.Add(vDiag * 0.5);
                        if (xAxis1.GetLength() > xAxis2.GetLength())
                        {
                            arranger = new BoundedRectArranger(xAxis1.GetLength(), xAxis2.GetLength());
                            matCS.SetCoordSystem(orig, xAxis1.Normalize(), zAxis.CrossProduct(xAxis1).Normalize(), zAxis.Normalize());
                        }
                        else
                        {
                            arranger = new BoundedRectArranger(xAxis2.GetLength(), xAxis1.GetLength());
                            matCS.SetCoordSystem(orig, xAxis2.Normalize(), zAxis.CrossProduct(xAxis2).Normalize(), zAxis.Normalize());
                        }
                        arranger.Nx = 2;
                        arranger.Ny = 2;
                    }

                    shearStud.Arranger = arranger;
                    shearStud.SetCS(matCS);
                    shearStud.Connect(filerObj, matCS);
                    shearStud.Material = "Mild Steel";
                    shearStud.Standard = "Nelson S3L-Inch";
                    shearStud.Diameter = 19.05;
                    shearStud.Length   = 101.6;

                    trans.Commit();
                }
            }
            catch (Autodesk.Revit.Exceptions.OperationCanceledException)
            {
                return(Result.Cancelled);
            }
            return(Result.Succeeded);
        }
示例#3
0
        internal CircularShearStudsPattern(string handleToConnect,
                                           SteelGeometry.Matrix3d coordSyst,
                                           List <Property> shearStudData,
                                           int boltCon)
        {
            lock (access_obj)
            {
                using (var ctx = new SteelServices.DocContext())
                {
                    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>();

                    Autodesk.AdvanceSteel.Modelling.Connector shearStuds = null;
                    string handle = SteelServices.ElementBinder.GetHandleFromTrace();
                    if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null)
                    {
                        var temp_radius = (double)arrangerShearStudData.FirstOrDefault <Property>(x => x.Name == "Radius").InternalValue;
                        var temp_noss   = (int)arrangerShearStudData.FirstOrDefault <Property>(x => x.Name == "NumberOfElements").InternalValue;

                        shearStuds          = new Autodesk.AdvanceSteel.Modelling.Connector();
                        shearStuds.Arranger = new Autodesk.AdvanceSteel.Arrangement.CircleArranger(Matrix2d.kIdentity, temp_radius, temp_noss);

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