Пример #1
0
        /// <summary>
        /// Create one SweptBlend
        /// </summary>
        private void CreateSweptBlend()
        {
            try
            {
                #region Create top and bottom profiles and path curve
                Autodesk.Revit.DB.XYZ pnt1 = new Autodesk.Revit.DB.XYZ(0, 0, 0);
                Autodesk.Revit.DB.XYZ pnt2 = new Autodesk.Revit.DB.XYZ(1, 0, 0);
                Autodesk.Revit.DB.XYZ pnt3 = new Autodesk.Revit.DB.XYZ(1, 1, 0);
                Autodesk.Revit.DB.XYZ pnt4 = new Autodesk.Revit.DB.XYZ(0, 1, 0);
                Autodesk.Revit.DB.XYZ pnt5 = new Autodesk.Revit.DB.XYZ(0, 0, 1);

                CurveArrArray arrarr1 = new CurveArrArray();
                CurveArray    arr1    = new CurveArray();
                arr1.Append(Line.CreateBound(pnt1, pnt2));
                arr1.Append(Line.CreateBound(pnt2, pnt3));
                arr1.Append(Line.CreateBound(pnt3, pnt4));
                arr1.Append(Line.CreateBound(pnt4, pnt1));
                arrarr1.Append(arr1);

                Autodesk.Revit.DB.XYZ pnt6    = new Autodesk.Revit.DB.XYZ(0.5, 0, 0);
                Autodesk.Revit.DB.XYZ pnt7    = new Autodesk.Revit.DB.XYZ(1, 0.5, 0);
                Autodesk.Revit.DB.XYZ pnt8    = new Autodesk.Revit.DB.XYZ(0.5, 1, 0);
                Autodesk.Revit.DB.XYZ pnt9    = new Autodesk.Revit.DB.XYZ(0, 0.5, 0);
                CurveArrArray         arrarr2 = new CurveArrArray();
                CurveArray            arr2    = new CurveArray();
                arr2.Append(Line.CreateBound(pnt6, pnt7));
                arr2.Append(Line.CreateBound(pnt7, pnt8));
                arr2.Append(Line.CreateBound(pnt8, pnt9));
                arr2.Append(Line.CreateBound(pnt9, pnt6));
                arrarr2.Append(arr2);

                SweepProfile bottomProfile = m_revit.Create.NewCurveLoopsProfile(arrarr1);
                SweepProfile topProfile    = m_revit.Create.NewCurveLoopsProfile(arrarr2);

                Autodesk.Revit.DB.XYZ pnt10 = new Autodesk.Revit.DB.XYZ(5, 0, 0);
                Autodesk.Revit.DB.XYZ pnt11 = new Autodesk.Revit.DB.XYZ(0, 20, 0);
                Curve curve = Line.CreateBound(pnt10, pnt11);

                Autodesk.Revit.DB.XYZ normal      = Autodesk.Revit.DB.XYZ.BasisZ;
                SketchPlane           sketchPlane = CreateSketchPlane(normal, Autodesk.Revit.DB.XYZ.Zero);
                #endregion
                // here create one swept blend
                SweptBlend newSweptBlend1 = m_creationFamily.NewSweptBlend(true, curve, sketchPlane, bottomProfile, topProfile);
                // move to proper place
                Autodesk.Revit.DB.XYZ transPoint1 = new Autodesk.Revit.DB.XYZ(11, 32, 0);
                ElementTransformUtils.MoveElement(m_familyDocument, newSweptBlend1.Id, transPoint1);
            }
            catch (Exception e)
            {
                m_errCount++;
                m_errorInfo += "Unexpected exceptions occur in CreateSweptBlend: " + e.ToString() + "\r\n";
            }
        }
Пример #2
0
        /// <summary>
        /// Create a new swept blend form.
        /// The NewSweptBlend method requires the
        /// input profile to be in the XY plane.
        /// </summary>
        public void CreateNewSweptBlend(Document doc)
        {
            Debug.Assert(doc.IsFamilyDocument,
                         "this method will only work in a family document");

            Application app = doc.Application;

            Autodesk.Revit.Creation.Application creapp
                = app.Create;

            CurveArrArray curvess0
                = creapp.NewCurveArrArray();

            CurveArray curves0 = new CurveArray();

            XYZ p00 = creapp.NewXYZ(0, 7.5, 0);
            XYZ p01 = creapp.NewXYZ(0, 15, 0);

            // changing Z to 1 in the following line fails:

            XYZ p02 = creapp.NewXYZ(-1, 10, 0);

            //curves0.Append( creapp.NewLineBound( p00, p01 ) ); // 2013

            curves0.Append(Line.CreateBound(p00, p01)); // 2014
            curves0.Append(Line.CreateBound(p01, p02));
            curves0.Append(Line.CreateBound(p02, p00));
            curvess0.Append(curves0);

            CurveArrArray curvess1 = creapp.NewCurveArrArray();
            CurveArray    curves1  = new CurveArray();

            XYZ p10 = creapp.NewXYZ(7.5, 0, 0);
            XYZ p11 = creapp.NewXYZ(15, 0, 0);

            // changing the Z value in the following line fails:

            XYZ p12 = creapp.NewXYZ(10, -1, 0);

            curves1.Append(Line.CreateBound(p10, p11));
            curves1.Append(Line.CreateBound(p11, p12));
            curves1.Append(Line.CreateBound(p12, p10));
            curvess1.Append(curves1);

            SweepProfile sweepProfile0
                = creapp.NewCurveLoopsProfile(curvess0);

            SweepProfile sweepProfile1
                = creapp.NewCurveLoopsProfile(curvess1);

            XYZ   pnt10 = new XYZ(5, 0, 0);
            XYZ   pnt11 = new XYZ(0, 20, 0);
            Curve curve = Line.CreateBound(pnt10, pnt11);

            XYZ normal = XYZ.BasisZ;

            SketchPlane splane = CreateSketchPlane(
                doc, normal, XYZ.Zero);

            try
            {
                SweptBlend sweptBlend = doc.FamilyCreate.NewSweptBlend(
                    true, curve, splane, sweepProfile0, sweepProfile1);
            }
            catch (Exception ex)
            {
                Util.ErrorMsg("NewSweptBlend exception: " + ex.Message);
            }
        }
Пример #3
0
        /// <summary>
        /// Create a new swept blend form using arcs to
        /// define circular start and end profiles and an
        /// arc path. The NewSweptBlend method requires
        /// the input profiles to be in the XY plane.
        /// </summary>
        public void CreateNewSweptBlendArc(Document doc)
        {
            Debug.Assert(doc.IsFamilyDocument,
                         "this method will only work in a family document");

            Application app = doc.Application;

            Autodesk.Revit.Creation.Application creapp
                = app.Create;

            Autodesk.Revit.Creation.FamilyItemFactory credoc
                = doc.FamilyCreate;

            #region Original code for Revit 2012
      #if COMPILE_ORIGINAL_CODE
            XYZ           pnt1    = new XYZ(0, -1, 0);
            XYZ           pnt2    = new XYZ(1, 0, 0);
            XYZ           pnt3    = new XYZ(0, 1, 0);
            XYZ           pnt4    = new XYZ(-1, 0, 0);
            Arc           aArc1   = creapp.NewArc(pnt1, pnt3, pnt2);
            Arc           aArc2   = creapp.NewArc(pnt3, pnt1, pnt4);
            CurveArrArray arrarr1 = new CurveArrArray();

            SweepProfile bottomProfile
                = creapp.NewCurveLoopsProfile(arrarr1);

            CurveArray arr1 = new CurveArray();
            arr1.Append(aArc1);
            arr1.Append(aArc2);
            XYZ           pnt6    = new XYZ(0, -2, 0);
            XYZ           pnt7    = new XYZ(2, 0, 0);
            XYZ           pnt8    = new XYZ(0, 2, 0);
            XYZ           pnt9    = new XYZ(-2, 0, 0);
            Arc           aArc3   = creapp.NewArc(pnt6, pnt8, pnt7);
            Arc           aArc4   = creapp.NewArc(pnt8, pnt6, pnt9);
            CurveArrArray arrarr2 = new CurveArrArray();
            CurveArray    arr2    = new CurveArray();
            arr2.Append(aArc3);
            arr2.Append(aArc4);
            arrarr2.Append(arr2);

            SweepProfile topProfile
                = creapp.NewCurveLoopsProfile(arrarr2);

            XYZ   pnt10   = new XYZ(0, 0, 0);
            XYZ   pnt11   = new XYZ(0, 5, 0);
            XYZ   pnt122  = new XYZ(2.5, 2.5, 0);
            Arc   testArc = creapp.NewArc(pnt10, pnt11, pnt122);
            Curve curve   = (Curve)testArc;

            Plane geometryPlane = creapp.NewPlane(
                XYZ.BasisZ, XYZ.Zero);

            SketchPlane sketchPlane = doc.NewSketchPlane(
                geometryPlane);

            SweptBlend aSweptBlend = doc.NewSweptBlend(
                true, curve, sketchPlane, bottomProfile,
                topProfile);
      #endif // COMPILE_ORIGINAL_CODE
            #endregion // Original code for Revit 2012

            XYZ        px   = XYZ.BasisX;
            XYZ        py   = XYZ.BasisY;
            Arc        arc1 = Arc.Create(-px, px, -py);
            Arc        arc2 = Arc.Create(px, -px, py);
            CurveArray arr1 = new CurveArray();
            arr1.Append(arc1);
            arr1.Append(arc2);
            CurveArrArray arrarr1 = new CurveArrArray();
            arrarr1.Append(arr1);

            SweepProfile bottomProfile
                = creapp.NewCurveLoopsProfile(arrarr1);

            px += px;
            py += py;
            Arc        arc3 = Arc.Create(-px, px, -py);
            Arc        arc4 = Arc.Create(px, -px, py);
            CurveArray arr2 = new CurveArray();
            arr2.Append(arc3);
            arr2.Append(arc4);
            CurveArrArray arrarr2 = new CurveArrArray();
            arrarr2.Append(arr2);

            SweepProfile topProfile
                = creapp.NewCurveLoopsProfile(arrarr2);

            XYZ p0      = XYZ.Zero;
            XYZ p5      = 5 * XYZ.BasisY;
            XYZ pmid    = new XYZ(2.5, 2.5, 0);
            Arc testArc = Arc.Create(p0, p5, pmid);

            Plane geometryPlane = creapp.NewPlane(
                XYZ.BasisZ, XYZ.Zero);

            SketchPlane sketchPlane = SketchPlane.Create(
                doc, geometryPlane);

            SweptBlend aSweptBlend = credoc.NewSweptBlend(
                true, testArc, sketchPlane, bottomProfile,
                topProfile);
        }
Пример #4
0
        private void Stream( ArrayList data, SweptBlend sweptBlend )
        {
            data.Add( new Snoop.Data.ClassSeparator( typeof( SweptBlend ) ) );

              data.Add( new Snoop.Data.Enumerable( "Bottom profile", sweptBlend.BottomProfile ) );
              data.Add( new Snoop.Data.Enumerable( "Top profile", sweptBlend.TopProfile ) );
              data.Add( new Snoop.Data.Object( "Bottom profile symbol", sweptBlend.BottomProfileSymbol ) );
              data.Add( new Snoop.Data.Object( "Top profile symbol", sweptBlend.TopProfileSymbol ) );
              data.Add( new Snoop.Data.Object( "Bottom sketch", sweptBlend.BottomSketch ) );
              data.Add( new Snoop.Data.Object( "Top sketch", sweptBlend.TopSketch ) );
              data.Add( new Snoop.Data.Object( "Path sketch", sweptBlend.PathSketch ) );
              data.Add( new Snoop.Data.Object( "Selected path", sweptBlend.SelectedPath ) );
        }
        public FamilyGeometryForm(Autodesk.Revit.DB.GenericForm form)
        {
            Id = form.Id.IntegerValue;
            this.geomVisibility = new GeometryVisibility(form.GetVisibility());

            //Autodesk.Revit.DB.Parameter sketchPlaneParam = form.get_Parameter(Autodesk.Revit.DB.BuiltInParameter.SKETCH_PLANE_PARAM);
            //if(sketchPlaneParam != null)
            //{
            //    this.
            //}

            IsSolidGeometry = form.IsSolid;
            if (form.Subcategory == null)
            {
                SubcategoryName = "";
            }
            else
            {
                SubcategoryName = form.Subcategory.Name;
            }



            if (form is Extrusion)
            {
                FormType = FormTypeEnum.Extrusion;
                Extrusion      ex = form as Extrusion;
                Sketch         extrusionProfile = ex.Sketch;
                GeometrySketch gs = new GeometrySketch(extrusionProfile);
                List_Profiles = new List <GeometrySketch> {
                    gs
                };
            }
            else if (form is Blend)
            {
                FormType = FormTypeEnum.Blend;
                Blend          bl            = form as Blend;
                GeometrySketch TopProfile    = new GeometrySketch(bl.TopSketch);
                GeometrySketch BottomProfile = new GeometrySketch(bl.BottomSketch);
                List_Profiles = new List <GeometrySketch> {
                    TopProfile, BottomProfile
                };
            }
            else if (form is Revolution)
            {
                FormType = FormTypeEnum.Revolution;
                Revolution     rev        = form as Revolution;
                Sketch         revProfile = rev.Sketch;
                GeometrySketch gs         = new GeometrySketch(revProfile);

                GeometrySketch axis = new GeometrySketch(rev.Axis.Id.IntegerValue, -1, null);
                List_Profiles = new List <GeometrySketch> {
                    gs, axis
                };
            }
            else if (form is Sweep)
            {
                FormType = FormTypeEnum.Sweep;
                Sweep sw = form as Sweep;
                List_Profiles = new List <GeometrySketch>();
                if (sw.Path3d != null)
                {
                    GeometrySketch gs = new GeometrySketch(sw.Path3d);
                    List_Profiles.Add(gs);
                }
                else if (sw.PathSketch != null)
                {
                    GeometrySketch gs = new GeometrySketch(sw.PathSketch);
                    List_Profiles.Add(gs);
                }

                if (sw.ProfileSymbol != null)
                {
                    GeometrySketch gs = new GeometrySketch(sw.ProfileSymbol.Profile.Id.IntegerValue, -1, null);
                }
                else if (sw.ProfileSketch != null)
                {
                    GeometrySketch gs = new GeometrySketch(sw.ProfileSketch);
                    List_Profiles.Add(gs);
                }
            }
            else if (form is SweptBlend)
            {
                FormType = FormTypeEnum.SweptBlend;
                SweptBlend sb = form as SweptBlend;
                List_Profiles = new List <GeometrySketch>();
                if (sb.SelectedPath != null)
                {
                    Curve          path = sb.SelectedPath;
                    GeometrySketch gs   = new GeometrySketch(path.Reference.ElementId.IntegerValue, -1, null);
                    List_Profiles.Add(gs);
                }
                else if (sb.PathSketch != null)
                {
                    GeometrySketch gs = new GeometrySketch(sb.PathSketch);
                    List_Profiles.Add(gs);
                }

                GeometrySketch gs1 = new GeometrySketch(sb.TopProfile);
                GeometrySketch gs2 = new GeometrySketch(sb.BottomProfile);
                List_Profiles.Add(gs1);
                List_Profiles.Add(gs2);
            }
        }