The class is used to create ReferencePlane
        /// <summary>
        /// The implementation of CreateSash(),and creating the Window Sash Solid Geometry
        /// </summary>
        public override void CreateSash()
        {
            double frameCurveOffset1 = 0.075;
            double frameDepth        = 7 * m_wallThickness / 12 + m_windowInset;
            double sashCurveOffset   = 0.075;
            double sashDepth         = (frameDepth - m_windowInset) / 2;

            //get the exterior view and sash referenceplane which are used in this process
            Autodesk.Revit.DB.View exteriorView   = Utility.GetViewByName("Exterior", m_application, m_document);
            SubTransaction         subTransaction = new SubTransaction(m_document);

            subTransaction.Start();

            //add a middle reference plane between the top referenceplane and sill referenceplane
            CreateRefPlane refPlaneCreator = new CreateRefPlane();
            ReferencePlane middlePlane     = refPlaneCreator.Create(m_document, m_topPlane, exteriorView, new Autodesk.Revit.DB.XYZ(0, 0, -m_height / 2), new Autodesk.Revit.DB.XYZ(0, -1, 0), "tempmiddle");

            m_document.Regenerate();

            //add dimension between top, sill, and middle reference plane, make the dimension segment equal
            Dimension dim = m_dimensionCreator.AddDimension(exteriorView, m_topPlane, m_sillPlane, middlePlane);

            dim.AreSegmentsEqual = true;

            //create first sash
            CurveArray curveArr5 = m_extrusionCreator.CreateRectangle(m_width / 2 - frameCurveOffset1, -m_width / 2 + frameCurveOffset1, m_sillHeight + m_height / 2 + sashCurveOffset / 2, m_sillHeight + frameCurveOffset1, 0);
            CurveArray curveArr6 = m_extrusionCreator.CreateCurveArrayByOffset(curveArr5, sashCurveOffset);

            m_document.Regenerate();

            CurveArrArray curveArrArray3 = new CurveArrArray();

            curveArrArray3.Append(curveArr5);
            curveArrArray3.Append(curveArr6);
            Extrusion sash1 = m_extrusionCreator.NewExtrusion(curveArrArray3, m_sashPlane, 2 * sashDepth, sashDepth);

            m_document.Regenerate();

            Face      esashFace1 = GeoHelper.GetExtrusionFace(sash1, m_rightView, true);
            Face      isashFace1 = GeoHelper.GetExtrusionFace(sash1, m_rightView, false);
            Dimension sashDim1   = m_dimensionCreator.AddDimension(m_rightView, esashFace1, isashFace1);

            sashDim1.IsLocked = true;
            Dimension sashWithPlane1 = m_dimensionCreator.AddDimension(m_rightView, m_sashPlane, isashFace1);

            sashWithPlane1.IsLocked = true;
            sash1.SetVisibility(CreateVisibility());

            //create second sash
            CurveArray curveArr7 = m_extrusionCreator.CreateRectangle(m_width / 2 - frameCurveOffset1, -m_width / 2 + frameCurveOffset1, m_sillHeight + m_height - frameCurveOffset1, m_sillHeight + m_height / 2 - sashCurveOffset / 2, 0);
            CurveArray curveArr8 = m_extrusionCreator.CreateCurveArrayByOffset(curveArr7, sashCurveOffset);

            m_document.Regenerate();

            CurveArrArray curveArrArray4 = new CurveArrArray();

            curveArrArray4.Append(curveArr7);
            curveArrArray4.Append(curveArr8);
            Extrusion sash2 = m_extrusionCreator.NewExtrusion(curveArrArray4, m_sashPlane, sashDepth, 0);

            sash2.SetVisibility(CreateVisibility());
            m_document.Regenerate();

            Face      esashFace2 = GeoHelper.GetExtrusionFace(sash2, m_rightView, true);
            Face      isashFace2 = GeoHelper.GetExtrusionFace(sash2, m_rightView, false);
            Dimension sashDim2   = m_dimensionCreator.AddDimension(m_rightView, esashFace2, isashFace2);

            sashDim2.IsLocked = true;
            Dimension sashWithPlane2 = m_dimensionCreator.AddDimension(m_rightView, m_sashPlane, isashFace2);

            m_document.Regenerate();
            sashWithPlane2.IsLocked = true;

            //set category of the sash extrusions
            if (m_frameCat != null)
            {
                sash1.Subcategory = m_frameCat;
                sash2.Subcategory = m_frameCat;
            }
            Autodesk.Revit.DB.ElementId id = m_sashMatID;
            sash1.get_Parameter(BuiltInParameter.MATERIAL_ID_PARAM).Set(id);
            sash2.get_Parameter(BuiltInParameter.MATERIAL_ID_PARAM).Set(id);
            subTransaction.Commit();
        }
Exemple #2
0
        /// <summary>
        /// The implementation of CreateSash(),and creating the Window Sash Solid Geometry
        /// </summary>
        public override void CreateSash()
        {
            double frameCurveOffset1 = 0.075;
            double frameDepth = 7*m_wallThickness/12+m_windowInset;
            double sashCurveOffset = 0.075;
            double sashDepth = (frameDepth - m_windowInset) / 2;

            //get the exterior view and sash referenceplane which are used in this process
            Autodesk.Revit.DB.View exteriorView = Utility.GetViewByName("Exterior", m_application, m_document);
            SubTransaction subTransaction = new SubTransaction(m_document);
            subTransaction.Start();

            //add a middle reference plane between the top referenceplane and sill referenceplane
            CreateRefPlane refPlaneCreator = new CreateRefPlane();
            ReferencePlane middlePlane=refPlaneCreator.Create(m_document, m_topPlane, exteriorView, new Autodesk.Revit.DB.XYZ (0, 0, -m_height / 2), new Autodesk.Revit.DB.XYZ (0, -1, 0), "tempmiddle");
            m_document.Regenerate();

            //add dimension between top, sill, and middle reference plane, make the dimension segment equal
            Dimension dim = m_dimensionCreator.AddDimension(exteriorView, m_topPlane, m_sillPlane, middlePlane);
            dim.AreSegmentsEqual = true;

            //create first sash
            CurveArray curveArr5 = m_extrusionCreator.CreateRectangle(m_width / 2 - frameCurveOffset1, -m_width / 2 + frameCurveOffset1, m_sillHeight + m_height / 2 + sashCurveOffset / 2, m_sillHeight + frameCurveOffset1, 0);
            CurveArray curveArr6 = m_extrusionCreator.CreateCurveArrayByOffset(curveArr5, sashCurveOffset);
            m_document.Regenerate();

            CurveArrArray curveArrArray3 = new CurveArrArray();
            curveArrArray3.Append(curveArr5);
            curveArrArray3.Append(curveArr6);
            Extrusion sash1 = m_extrusionCreator.NewExtrusion(curveArrArray3, m_sashPlane, 2 * sashDepth, sashDepth);
            m_document.Regenerate();

            Face esashFace1=GeoHelper.GetExtrusionFace(sash1,m_rightView,true);
            Face isashFace1=GeoHelper.GetExtrusionFace(sash1,m_rightView,false);
            Dimension sashDim1=m_dimensionCreator.AddDimension(m_rightView,esashFace1,isashFace1);
            sashDim1.IsLocked = true;
            Dimension sashWithPlane1 = m_dimensionCreator.AddDimension(m_rightView, m_sashPlane, isashFace1);
            sashWithPlane1.IsLocked = true;
            sash1.SetVisibility(CreateVisibility());

            //create second sash
            CurveArray curveArr7 = m_extrusionCreator.CreateRectangle(m_width / 2 - frameCurveOffset1, -m_width / 2 + frameCurveOffset1, m_sillHeight + m_height - frameCurveOffset1, m_sillHeight + m_height / 2 - sashCurveOffset / 2, 0);
            CurveArray curveArr8 = m_extrusionCreator.CreateCurveArrayByOffset(curveArr7, sashCurveOffset);
            m_document.Regenerate();

            CurveArrArray curveArrArray4 = new CurveArrArray();
            curveArrArray4.Append(curveArr7);
            curveArrArray4.Append(curveArr8);
            Extrusion sash2 = m_extrusionCreator.NewExtrusion(curveArrArray4, m_sashPlane, sashDepth, 0);
            sash2.SetVisibility(CreateVisibility());
            m_document.Regenerate();

            Face esashFace2 = GeoHelper.GetExtrusionFace(sash2, m_rightView, true);
            Face isashFace2 = GeoHelper.GetExtrusionFace(sash2, m_rightView, false);
            Dimension sashDim2 = m_dimensionCreator.AddDimension(m_rightView, esashFace2, isashFace2);
            sashDim2.IsLocked = true;
            Dimension sashWithPlane2 = m_dimensionCreator.AddDimension(m_rightView, m_sashPlane, isashFace2);
            m_document.Regenerate();
            sashWithPlane2.IsLocked = true;

            //set category of the sash extrusions
            if (m_frameCat != null)
            {
                sash1.Subcategory = m_frameCat;
                sash2.Subcategory = m_frameCat;
            }
            Autodesk.Revit.DB.ElementId id = new ElementId(m_sashMatID);
            sash1.ParametersMap.get_Item("Material").Set(id);
            sash2.ParametersMap.get_Item("Material").Set(id);
            subTransaction.Commit();
        }
        /// <summary>
        /// The implementation of CreateFrame()
        /// </summary>
        public override void CreateFrame()
        {
            SubTransaction subTransaction = new SubTransaction(m_document);

            subTransaction.Start();

            //create sash referenceplane and exterior referenceplane
            CreateRefPlane refPlaneCreator = new CreateRefPlane();

            if (m_sashPlane == null)
            {
                m_sashPlane = refPlaneCreator.Create(m_document, m_centerPlane, m_rightView, new Autodesk.Revit.DB.XYZ(0, m_wallThickness / 2 - m_windowInset, 0), new Autodesk.Revit.DB.XYZ(0, 0, 1), "Sash");
            }
            if (m_exteriorPlane == null)
            {
                m_exteriorPlane = refPlaneCreator.Create(m_document, m_centerPlane, m_rightView, new Autodesk.Revit.DB.XYZ(0, m_wallThickness / 2, 0), new Autodesk.Revit.DB.XYZ(0, 0, 1), "MyExterior");
            }
            m_document.Regenerate();

            //get the wall in the document and retrieve the exterior face
            List <Wall> walls            = Utility.GetElements <Wall>(m_application, m_document);
            Face        exteriorWallFace = GeoHelper.GetWallFace(walls[0], m_rightView, true);

            if (exteriorWallFace == null)
            {
                return;
            }

            //add dimension between sash reference plane and wall face,and add parameter "Window Inset",label the dimension with window-inset parameter
            Dimension       windowInsetDimension = m_dimensionCreator.AddDimension(m_rightView, m_sashPlane, exteriorWallFace);
            FamilyParameter windowInsetPara      = m_familyManager.AddParameter("Window Inset", new ForgeTypeId(), SpecTypeId.Length, false);

            m_familyManager.Set(windowInsetPara, m_windowInset);
            windowInsetDimension.FamilyLabel = windowInsetPara;

            //create the exterior frame
            double        frameCurveOffset1 = 0.075;
            CurveArray    curveArr1         = m_extrusionCreator.CreateRectangle(m_width / 2, -m_width / 2, m_sillHeight + m_height, m_sillHeight, 0);
            CurveArray    curveArr2         = m_extrusionCreator.CreateCurveArrayByOffset(curveArr1, frameCurveOffset1);
            CurveArrArray curveArrArray1    = new CurveArrArray();

            curveArrArray1.Append(curveArr1);
            curveArrArray1.Append(curveArr2);
            Extrusion extFrame = m_extrusionCreator.NewExtrusion(curveArrArray1, m_sashPlane, m_wallThickness / 2 + m_wallThickness / 12, -m_windowInset);

            extFrame.SetVisibility(CreateVisibility());
            m_document.Regenerate();

            //add alignment between wall face and exterior frame face
            exteriorWallFace = GeoHelper.GetWallFace(walls[0], m_rightView, true);  // Get the face again as the document is regenerated.
            Face            exteriorExtrusionFace1 = GeoHelper.GetExtrusionFace(extFrame, m_rightView, true);
            Face            interiorExtrusionFace1 = GeoHelper.GetExtrusionFace(extFrame, m_rightView, false);
            CreateAlignment alignmentCreator       = new CreateAlignment(m_document);

            alignmentCreator.AddAlignment(m_rightView, exteriorWallFace, exteriorExtrusionFace1);

            //add dimension between sash referenceplane and exterior frame face and lock the dimension
            Dimension extFrameWithSashPlane = m_dimensionCreator.AddDimension(m_rightView, m_sashPlane, interiorExtrusionFace1);

            extFrameWithSashPlane.IsLocked = true;
            m_document.Regenerate();

            //create the interior frame
            double     frameCurveOffset2 = 0.125;
            CurveArray curveArr3         = m_extrusionCreator.CreateRectangle(m_width / 2, -m_width / 2, m_sillHeight + m_height, m_sillHeight, 0);
            CurveArray curveArr4         = m_extrusionCreator.CreateCurveArrayByOffset(curveArr3, frameCurveOffset2);

            m_document.Regenerate();

            CurveArrArray curveArrArray2 = new CurveArrArray();

            curveArrArray2.Append(curveArr3);
            curveArrArray2.Append(curveArr4);
            Extrusion intFrame = m_extrusionCreator.NewExtrusion(curveArrArray2, m_sashPlane, m_wallThickness - m_windowInset, m_wallThickness / 2 + m_wallThickness / 12);

            intFrame.SetVisibility(CreateVisibility());
            m_document.Regenerate();

            //add alignment between interior face of wall and interior frame face
            Face interiorWallFace       = GeoHelper.GetWallFace(walls[0], m_rightView, false);
            Face interiorExtrusionFace2 = GeoHelper.GetExtrusionFace(intFrame, m_rightView, false);
            Face exteriorExtrusionFace2 = GeoHelper.GetExtrusionFace(intFrame, m_rightView, true);

            alignmentCreator.AddAlignment(m_rightView, interiorWallFace, interiorExtrusionFace2);

            //add dimension between sash referenceplane and interior frame face and lock the dimension
            Dimension intFrameWithSashPlane = m_dimensionCreator.AddDimension(m_rightView, m_sashPlane, exteriorExtrusionFace2);

            intFrameWithSashPlane.IsLocked = true;

            //create the sill frame
            CurveArray    sillCurs       = m_extrusionCreator.CreateRectangle(m_width / 2, -m_width / 2, m_sillHeight + frameCurveOffset1, m_sillHeight, 0);
            CurveArrArray sillCurveArray = new CurveArrArray();

            sillCurveArray.Append(sillCurs);
            Extrusion sillFrame = m_extrusionCreator.NewExtrusion(sillCurveArray, m_sashPlane, -m_windowInset, -m_windowInset - 0.1);

            m_document.Regenerate();

            //add alignment between wall face and sill frame face
            exteriorWallFace = GeoHelper.GetWallFace(walls[0], m_rightView, true);  // Get the face again as the document is regenerated.
            Face sillExtFace = GeoHelper.GetExtrusionFace(sillFrame, m_rightView, false);

            alignmentCreator.AddAlignment(m_rightView, sillExtFace, exteriorWallFace);
            m_document.Regenerate();

            //set subcategories of the frames
            if (m_frameCat != null)
            {
                extFrame.Subcategory  = m_frameCat;
                intFrame.Subcategory  = m_frameCat;
                sillFrame.Subcategory = m_frameCat;
            }
            subTransaction.Commit();
        }
Exemple #4
0
        /// <summary>
        /// The implementation of CreateFrame()
        /// </summary>
        public override void CreateFrame()
        {
            SubTransaction subTransaction = new SubTransaction(m_document);
            subTransaction.Start();
            //get the wall in the document and retrieve the exterior face
            List<Wall> walls = Utility.GetElements<Wall>(m_application, m_document);
            Face exteriorWallFace = GeoHelper.GetWallFace(walls[0], m_rightView, true);

            //create sash referenceplane and exterior referenceplane
            CreateRefPlane refPlaneCreator = new CreateRefPlane();
            if(m_sashPlane==null)
                m_sashPlane = refPlaneCreator.Create(m_document, m_centerPlane, m_rightView, new Autodesk.Revit.DB.XYZ (0, m_wallThickness / 2 - m_windowInset, 0), new Autodesk.Revit.DB.XYZ (0, 0, 1), "Sash");
            if (m_exteriorPlane==null)
                m_exteriorPlane = refPlaneCreator.Create(m_document, m_centerPlane, m_rightView, new Autodesk.Revit.DB.XYZ (0, m_wallThickness / 2, 0), new Autodesk.Revit.DB.XYZ (0, 0, 1), "MyExterior");
            m_document.Regenerate();

            //add dimension between sash reference plane and wall face,and add parameter "Window Inset",label the dimension with window-inset parameter
            Dimension windowInsetDimension = m_dimensionCreator.AddDimension(m_rightView, m_sashPlane, exteriorWallFace);
            FamilyParameter windowInsetPara = m_familyManager.AddParameter("Window Inset", BuiltInParameterGroup.INVALID, ParameterType.Length, false);
            m_familyManager.Set(windowInsetPara, m_windowInset);
            windowInsetDimension.Label = windowInsetPara;

            //create the exterior frame
            double frameCurveOffset1 = 0.075;
            CurveArray curveArr1 = m_extrusionCreator.CreateRectangle(m_width / 2, -m_width / 2, m_sillHeight + m_height, m_sillHeight, 0);
            CurveArray curveArr2 = m_extrusionCreator.CreateCurveArrayByOffset(curveArr1, frameCurveOffset1);
            CurveArrArray curveArrArray1 = new CurveArrArray();
            curveArrArray1.Append(curveArr1);
            curveArrArray1.Append(curveArr2);
            Extrusion extFrame = m_extrusionCreator.NewExtrusion(curveArrArray1, m_sashPlane, m_wallThickness / 2 + m_wallThickness/12, -m_windowInset);
            extFrame.SetVisibility( CreateVisibility());
            m_document.Regenerate();

            //add alignment between wall face and exterior frame face
            Face exteriorExtrusionFace1=GeoHelper.GetExtrusionFace(extFrame,m_rightView,true);
            Face interiorExtrusionFace1 = GeoHelper.GetExtrusionFace(extFrame,m_rightView,false);
            CreateAlignment alignmentCreator = new CreateAlignment(m_document);
            alignmentCreator.AddAlignment(m_rightView,exteriorWallFace,exteriorExtrusionFace1);

            //add dimension between sash referenceplane and exterior frame face and lock the dimension
            Dimension extFrameWithSashPlane = m_dimensionCreator.AddDimension(m_rightView, m_sashPlane, interiorExtrusionFace1);
            extFrameWithSashPlane.IsLocked = true;
            m_document.Regenerate();

            //create the interior frame
            double frameCurveOffset2 = 0.125;
            CurveArray curveArr3 = m_extrusionCreator.CreateRectangle(m_width / 2, -m_width / 2, m_sillHeight + m_height, m_sillHeight, 0);
            CurveArray curveArr4 = m_extrusionCreator.CreateCurveArrayByOffset(curveArr3, frameCurveOffset2);
            m_document.Regenerate();

            CurveArrArray curveArrArray2 = new CurveArrArray();
            curveArrArray2.Append(curveArr3);
            curveArrArray2.Append(curveArr4);
            Extrusion intFrame = m_extrusionCreator.NewExtrusion(curveArrArray2, m_sashPlane, m_wallThickness - m_windowInset, m_wallThickness / 2 + m_wallThickness / 12);
            intFrame.SetVisibility( CreateVisibility());
            m_document.Regenerate();

            //add alignment between interior face of wall and interior frame face
            Face interiorWallFace = GeoHelper.GetWallFace(walls[0], m_rightView, false);
            Face interiorExtrusionFace2 = GeoHelper.GetExtrusionFace(intFrame, m_rightView, false);
            Face exteriorExtrusionFace2 = GeoHelper.GetExtrusionFace(intFrame, m_rightView, true);
            alignmentCreator.AddAlignment(m_rightView, interiorWallFace, interiorExtrusionFace2);

            //add dimension between sash referenceplane and interior frame face and lock the dimension
            Dimension intFrameWithSashPlane = m_dimensionCreator.AddDimension(m_rightView, m_sashPlane, exteriorExtrusionFace2);
            intFrameWithSashPlane.IsLocked = true;

            //create the sill frame
            CurveArray sillCurs = m_extrusionCreator.CreateRectangle(m_width / 2, -m_width / 2, m_sillHeight + frameCurveOffset1, m_sillHeight, 0);
            CurveArrArray sillCurveArray = new CurveArrArray();
            sillCurveArray.Append(sillCurs);
            Extrusion sillFrame= m_extrusionCreator.NewExtrusion(sillCurveArray, m_sashPlane, -m_windowInset, -m_windowInset - 0.1);
            m_document.Regenerate();

            //add alignment between wall face and sill frame face
            Face sillExtFace = GeoHelper.GetExtrusionFace(sillFrame, m_rightView, false);
            alignmentCreator.AddAlignment(m_rightView, sillExtFace, exteriorWallFace);
            m_document.Regenerate();

            //set subcategories of the frames
            if (m_frameCat != null)
            {
                extFrame.Subcategory = m_frameCat;
                intFrame.Subcategory = m_frameCat;
                sillFrame.Subcategory = m_frameCat;
            }
            subTransaction.Commit();
        }