Beispiel #1
0
        /// <summary>
        /// Create sketch plane for generic model profile
        /// </summary>
        /// <param name="normal">plane normal</param>
        /// <param name="origin">origin point</param>
        /// <returns></returns>
        internal SketchPlane CreateSketchPlane(Autodesk.Revit.DB.XYZ normal, Autodesk.Revit.DB.XYZ origin)
        {
            // First create a Geometry.Plane which need in NewSketchPlane() method
            Plane geometryPlane = m_revit.Create.NewPlane(normal, origin);

            if (null == geometryPlane)  // assert the creation is successful
            {
                throw new Exception("Create the geometry plane failed.");
            }
            // Then create a sketch plane using the Geometry.Plane
            SketchPlane plane = m_creationFamily.NewSketchPlane(geometryPlane);

            // throw exception if creation failed
            if (null == plane)
            {
                throw new Exception("Create the sketch plane failed.");
            }
            return(plane);
        }
        /// <summary>
        /// The method is used to create extrusion using FamilyItemFactory.NewExtrusion()
        /// </summary>
        /// <param name="curveArrArray">the CurveArrArray parameter</param>
        /// <param name="workPlane">the reference plane is used to create SketchPlane</param>
        /// <param name="startOffset">the extrusion's StartOffset property</param>
        /// <param name="endOffset">the extrusion's EndOffset property</param>
        /// <returns>the new extrusion</returns>
        public Extrusion NewExtrusion(CurveArrArray curveArrArray, ReferencePlane workPlane, double startOffset, double endOffset)
        {
            Extrusion rectExtrusion = null;

            try
            {
                SubTransaction subTransaction = new SubTransaction(m_document);
                subTransaction.Start();
                SketchPlane sketch = m_familyCreator.NewSketchPlane(workPlane.Plane);
                rectExtrusion             = m_familyCreator.NewExtrusion(true, curveArrArray, sketch, Math.Abs(endOffset - startOffset));
                rectExtrusion.StartOffset = startOffset;
                rectExtrusion.EndOffset   = endOffset;
                subTransaction.Commit();
                return(rectExtrusion);
            }
            catch
            {
                return(null);
            }
        }