• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# CurveArray类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中CurveArray的典型用法代码示例。如果您正苦于以下问题:C# CurveArray类的具体用法?C# CurveArray怎么用?C# CurveArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CurveArray类属于命名空间,在下文中一共展示了CurveArray类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CreateHelix

        public void CreateHelix()
        {
            double increment = 0.1;
            double current = 0;
            XYZ startPt;
            XYZ endPt;
            XYZ zAxis = GeomUtils.kZAxis;
            XYZ origin = GeomUtils.kOrigin;
            Line line;
            Plane plane = m_revitApp.Application.Create.NewPlane(zAxis, origin);
            SketchPlane sketchPlane = SketchPlane.Create(m_revitApp.ActiveUIDocument.Document, plane);
            CurveArray curveArray = new CurveArray();

            startPt = new XYZ(Math.Cos(current), Math.Sin(current), current);
            current += increment;

            while (current <= GeomUtils.kTwoPi) {
                endPt = new XYZ(Math.Cos(current), Math.Sin(current), current);

                line = Line.CreateBound(startPt, endPt);
                curveArray.Append(line);

                startPt = endPt;
                current += increment;
            }

            m_revitApp.ActiveUIDocument.Document.Create.NewModelCurveArray(curveArray, sketchPlane);
        }
开发者ID:halad,项目名称:RevitLookup,代码行数:28,代码来源:TestGeometry.cs


示例2: Execute

        public IExternalCommand.Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            Application revit = commandData.Application;
            Document curDoc = revit.ActiveDocument;

            //配置几何曲线
            CurveArray curves = new CurveArray();
            if (null == curves)
            {
                message = "Create the curves failed.";
                return IExternalCommand.Result.Failed;
            }
            XYZ first = new XYZ(0, 0, 0);
            XYZ second = new XYZ(10, 0, 0);
            XYZ third = new XYZ(10, 10, 0);
            XYZ fourth = new XYZ(0, 10, 0);
            curves.Append(revit.Create.NewLine(ref first, ref second, true));
            curves.Append(revit.Create.NewLine(ref second, ref third, true));
            curves.Append(revit.Create.NewLine(ref third, ref fourth, true));
            curves.Append(revit.Create.NewLine(ref fourth, ref first, true));
            // 利用几何曲线,类型,标高等创建地板对象
            Floor createdFloor = curDoc.Create.NewFloor(curves, true);
            if (null == createdFloor)
            {
                message = "Create floor failed.!";
                return IExternalCommand.Result.Failed;
            }

            return IExternalCommand.Result.Succeeded;
        }
开发者ID:guchanghai,项目名称:Cut,代码行数:30,代码来源:NewFloor.cs


示例3: CreateFloor

 private static Autodesk.Revit.DB.Floor CreateFloor(IEnumerable<Value> edges, FloorType floorType, Autodesk.Revit.DB.Level level)
 {
     var ca = new CurveArray();
     edges.ToList().ForEach(x => ca.Append((Curve) ((Value.Container) x).Item));
     var floor = dynRevitSettings.Doc.Document.Create.NewFloor(ca, floorType, level, false);
     return floor;
 }
开发者ID:kah-heng,项目名称:Dynamo,代码行数:7,代码来源:Floor.cs


示例4: FindFloorViewDirection

 /// <summary>
 /// Find the view direction vector, 
 /// which is the same meaning of ViewDirection property in View class
 /// </summary>
 /// <param name="curveArray">the curve array which form floor's AnalyticalModel</param>
 /// <returns>the view direction vector</returns>
 public static Autodesk.Revit.DB.XYZ FindFloorViewDirection(CurveArray curveArray)
 {
     // Because the floor is always on the level,
     // so each curve can give the direction information.
     Curve curve = curveArray.get_Item(0);
     Autodesk.Revit.DB.XYZ first = curve.get_EndPoint(0);
     Autodesk.Revit.DB.XYZ second = curve.get_EndPoint(1);
     return FindDirection(first, second);
 }
开发者ID:AMEE,项目名称:revit,代码行数:15,代码来源:XYZMath.cs


示例5: Floor

        /// <summary>
        /// Private constructor
        /// </summary>
        private Floor(CurveArray curveArray, Autodesk.Revit.DB.FloorType floorType, Autodesk.Revit.DB.Level level)
        {
            TransactionManager.Instance.EnsureInTransaction(Document);

            // we assume the floor is not structural here, this may be a bad assumption
            var floor = Document.Create.NewFloor(curveArray, floorType, level, false);

            InternalSetFloor( floor );

            TransactionManager.Instance.TransactionTaskDone();

            ElementBinder.CleanupAndSetElementForTrace(Document, InternalFloor);
        }
开发者ID:RobertiF,项目名称:Dynamo,代码行数:16,代码来源:Floor.cs


示例6: Execute

        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            Autodesk.Revit.UI.UIApplication uiapp = commandData.Application;
              Autodesk.Revit.UI.UIDocument uidoc = uiapp.ActiveUIDocument;
              Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
              Autodesk.Revit.DB.Document doc = uidoc.Document;

              // Build a wall profile for the wall creation
              XYZ[] pts = new XYZ[] {
            XYZ.Zero,
            new XYZ(20, 0,  0),
            new XYZ(20, 0, 15),
            new XYZ(10, 0, 30),
            new XYZ( 0, 0, 15)
            };

              // Get application creation object
              Autodesk.Revit.Creation.Application appCreation = app.Create;

              // Create wall profile
              CurveArray profile = new CurveArray();
              XYZ q = pts[pts.Length - 1];

              foreach (XYZ p in pts)
              {
            profile.Append(appCreation.NewLineBound(q, p));
            q = p;
              }

              XYZ normal = XYZ.BasisY;

              WallType wallType
            = new FilteredElementCollector(doc)
              .OfClass(typeof(WallType))
              .First<Element>()
            as WallType;

              Level level
            = new FilteredElementCollector(doc)
              .OfClass(typeof(Level))
              .First<Element>(e
            => e.Name.Equals("Level 1"))
              as Level;

              Transaction trans = new Transaction(doc);
              trans.Start("Test Gable Wall");
              Wall wall = doc.Create.NewWall(profile, wallType, level, true, normal);
              trans.Commit();

              return Result.Succeeded;
        }
开发者ID:dalefugier,项目名称:Sockeye,代码行数:51,代码来源:CmdTestGableWall.cs


示例7: CreateBeamSystem

 /// <summary>
 /// create beam system according to given profile and property
 /// </summary>
 public void CreateBeamSystem()
 {
     Autodesk.Revit.Creation.Document docCreation = m_data.CommandData.Application.ActiveUIDocument.Document.Create;
     // create CurveArray and insert Lines in order
     CurveArray curves = new CurveArray();
     foreach (Line line in m_data.Lines)
     {
         curves.Append(line);
     }
     // create beam system takes closed profile consist of lines
     BeamSystem aBeamSystem = docCreation.NewBeamSystem(curves, m_data.CommandData.Application.ActiveUIDocument.Document.ActiveView.SketchPlane);
     // set created beam system's layout rule and beam type property
     aBeamSystem.LayoutRule = m_data.Param.Layout;
     aBeamSystem.BeamType   = m_data.Param.BeamType;
 }
开发者ID:AMEE,项目名称:revit,代码行数:18,代码来源:BeamSystemBuilder.cs


示例8: CreateCurveArrayByOffset

 /// <summary>
 /// The method is used to create a CurveArray along to an origin CurveArray and an offset value
 /// </summary>
 /// <param name="origin">the original CurveArray</param>
 /// <param name="offset">the offset value</param>
 /// <returns>CurveArray</returns>
 public CurveArray CreateCurveArrayByOffset(CurveArray origin, double offset)
 {
     Line line;
     Line temp;
     int counter = 0;
     CurveArray curveArr = m_appCreator.NewCurveArray();
     Autodesk.Revit.DB.XYZ offsetx = new Autodesk.Revit.DB.XYZ (offset, 0, 0);
     Autodesk.Revit.DB.XYZ offsetz = new Autodesk.Revit.DB.XYZ (0, 0, offset);
     Autodesk.Revit.DB.XYZ p0 = new Autodesk.Revit.DB.XYZ ();
     Autodesk.Revit.DB.XYZ p1 = new Autodesk.Revit.DB.XYZ (); ;
     Autodesk.Revit.DB.XYZ p2 = new Autodesk.Revit.DB.XYZ ();
     Autodesk.Revit.DB.XYZ p3 = new Autodesk.Revit.DB.XYZ ();
     foreach (Curve curve in origin)
     {
         temp = curve as Line;
         if (temp != null)
         {
             if (counter == 0)
             {
                 p0 = temp.get_EndPoint(0).Subtract(offsetz).Subtract(offsetx);
             }
             else if (counter == 1)
             {
                 p1 = temp.get_EndPoint(0).Subtract(offsetz).Add(offsetx);
             }
             else if (counter == 2)
             {
                 p2 = temp.get_EndPoint(0).Add(offsetx).Add(offsetz);
             }
             else
             {
                 p3 = temp.get_EndPoint(0).Subtract(offsetx).Add(offsetz);
             }
         }
         counter++;
     }
     line = m_appCreator.NewLineBound(p0, p1);
     curveArr.Append(line);
     line = m_appCreator.NewLineBound(p1, p2);
     curveArr.Append(line);
     line = m_appCreator.NewLineBound(p2, p3);
     curveArr.Append(line);
     line = m_appCreator.NewLineBound(p3, p0);
     curveArr.Append(line);
     return curveArr;
 }
开发者ID:AMEE,项目名称:revit,代码行数:52,代码来源:CreateExtrusion.cs


示例9: MakeArc

 /// <summary>
 /// Create arc element by three points
 /// </summary>
 /// <param name="app">revit application</param>
 /// <param name="ptA">point a</param>
 /// <param name="ptB">point b</param>
 /// <param name="ptC">point c</param>
 /// <returns></returns>
 public static ModelCurve MakeArc(UIApplication app, Autodesk.Revit.DB.XYZ ptA, Autodesk.Revit.DB.XYZ ptB, Autodesk.Revit.DB.XYZ ptC)
 {
     Document doc = app.ActiveUIDocument.Document;
      Arc arc = app.Application.Create.NewArc(ptA, ptB, ptC);
      // Create three lines and a plane by the points
      Line line1 = app.Application.Create.NewLine(ptA, ptB, true);
      Line line2 = app.Application.Create.NewLine(ptB, ptC, true);
      Line line3 = app.Application.Create.NewLine(ptC, ptA, true);
      CurveArray ca = new CurveArray();
      ca.Append(line1);
      ca.Append(line2);
      ca.Append(line3);
      Plane plane = app.Application.Create.NewPlane(ca);
      SketchPlane skplane = doc.FamilyCreate.NewSketchPlane(plane);
      // Create arc here
      ModelCurve modelcurve = doc.FamilyCreate.NewModelCurve(arc, skplane);
      return modelcurve;
 }
开发者ID:AMEE,项目名称:revit,代码行数:26,代码来源:Command.cs


示例10: CreateFootPrintRoof

        /// <summary>
        /// Create a footprint roof.
        /// </summary>
        /// <param name="footPrint">The footprint is a curve loop, or a wall loop, or loops combined of walls and curves</param>
        /// <param name="level">The base level of the roof to be created.</param>
        /// <param name="roofType">The type of the newly created roof.</param>
        /// <returns>Return a new created footprint roof.</returns>
        public FootPrintRoof CreateFootPrintRoof(CurveArray footPrint, Level level, RoofType roofType)
        {
            FootPrintRoof footprintRoof = null;
            Transaction createRoofTransaction = new Transaction(m_commandData.Application.ActiveUIDocument.Document, "FootPrintRoof");
            createRoofTransaction.Start();
            try
            {
                ModelCurveArray footPrintToModelCurveMapping = new ModelCurveArray();
                footprintRoof = m_creationDoc.NewFootPrintRoof(footPrint, level, roofType, out footPrintToModelCurveMapping);
                createRoofTransaction.Commit();
            }
            catch (System.Exception e)
            {
                createRoofTransaction.RollBack();
                throw e;
            }

            return footprintRoof;
        }
开发者ID:AMEE,项目名称:revit,代码行数:26,代码来源:FootPrintRoofManager.cs


示例11: CreateExtrusionRoof

        /// <summary>
        /// Create a extrusion roof.
        /// </summary>
        /// <param name="profile">The profile combined of straight lines and arcs.</param>
        /// <param name="refPlane">The reference plane for the extrusion roof.</param>
        /// <param name="level">The reference level of the roof to be created.</param>
        /// <param name="roofType">The type of the newly created roof.</param>
        /// <param name="extrusionStart">The extrusion start point.</param>
        /// <param name="extrusionEnd">The extrusion end point.</param>
        /// <returns>Return a new created extrusion roof.</returns>
        public ExtrusionRoof CreateExtrusionRoof(CurveArray profile, ReferencePlane refPlane, Level level, RoofType roofType,
            double extrusionStart, double extrusionEnd)
        {
            ExtrusionRoof extrusionRoof = null;
            Transaction createRoofTransaction = new Transaction(m_commandData.Application.ActiveUIDocument.Document, "ExtrusionRoof");
            createRoofTransaction.Start();
            try
            {
                extrusionRoof = m_creationDoc.NewExtrusionRoof(profile, refPlane, level, roofType, extrusionStart, extrusionEnd);
                createRoofTransaction.Commit();
            }
            catch (System.Exception e)
            {
                createRoofTransaction.RollBack();
                throw e;
            }

            return extrusionRoof;
        }
开发者ID:AMEE,项目名称:revit,代码行数:29,代码来源:ExtrusionRoofManager.cs


示例12: IsRectangular

        const double PRECISION = 0.00001; //precision when judge whether two doubles are equal

        #endregion Fields

        #region Methods

        /// <summary>
        /// judge whether given 4 lines can form a rectangular
        /// </summary>
        /// <param name="lines"></param>
        /// <returns>is rectangular</returns>
        /// <summary>
        /// judge whether given 4 lines can form a rectangular
        /// </summary>
        /// <param name="lines"></param>
        /// <returns>is rectangular</returns>
        public static bool IsRectangular(CurveArray curves)
        {
            if (curves.Size != 4)
            {
                return false;
            }

            Line[] lines = new Line[4];
            for (int i = 0; i < 4; i++)
            {
                lines[i] = curves.get_Item(i) as Line;
                if (null == lines[i])
                {
                    return false;
                }
            }

            Line iniLine = lines[0];
            Line[] verticalLines = new Line[2];
            Line paraLine = null;
            int index = 0;
            for (int i = 1; i < 4; i++)
            {
                if (IsVertical(lines[0], lines[i]))
                {
                    verticalLines[index] = lines[i];
                    index++;
                }
                else
                {
                    paraLine = lines[i];
                }
            }
            if (index != 2)
            {
                return false;
            }
            bool flag = IsVertical(paraLine, verticalLines[0]);
            return flag;
        }
开发者ID:AMEE,项目名称:revit,代码行数:56,代码来源:GeomUtil.cs


示例13: GetFloorGeom

        /// <summary>
        /// get necessary data when create AreaReinforcement on a horizontal floor
        /// </summary>
        /// <param name="floor">floor on which to create AreaReinforcemen</param>
        /// <param name="refer">reference of the horizontal face on the floor</param>
        /// <param name="curves">curves compose the horizontal face of the floor</param>
        /// <returns>is successful</returns>
        public bool GetFloorGeom(Floor floor, ref Reference refer, ref CurveArray curves)
        {
            //get horizontal face's reference
            FaceArray faces = GeomUtil.GetFaces(floor);
            foreach (Face face in faces)
            {
                if (GeomUtil.IsHorizontalFace(face))
                {
                    refer = face.Reference;
                    break;
                }
            }
            if (null == refer)
            {
                return false;
            }
            //get analytical model profile
            AnalyticalModel model = floor.GetAnalyticalModel();
            if (null == model)
            {
                return false;
            }

            IList<Curve> curveList = model.GetCurves(AnalyticalCurveType.ActiveCurves);
            curves = m_currentDoc.Application.Create.NewCurveArray();
            foreach (Curve curve in curveList)
            {
                curves.Append(curve);
            }

            if (!GeomUtil.IsRectangular(curves))
            {
                return false;
            }
            curves = AddInlaidCurves(curves, 0.5);

            return true;
        }
开发者ID:AMEE,项目名称:revit,代码行数:45,代码来源:GeomHelper.cs


示例14: SimpleFloor

        /// <summary>
        ///  Used by the SimpleShed to create its floors and the fake roof
        /// </summary>
        /// <param name="profile"></param>
        public Revit.ElementId SimpleFloor( CurveArray profile, Level level )
        {
            Autodesk.Revit.Creation.Document doc = m_revitApp.ActiveUIDocument.Document.Create;
              Autodesk.Revit.Creation.Application applic = m_revitApp.Application.Create;

              // Obtain the required floor type
              FloorType floorType = null;

              try
              {
            FilteredElementCollector fec = new FilteredElementCollector( m_revitApp.ActiveUIDocument.Document );
            ElementClassFilter elementsAreWanted = new ElementClassFilter( typeof( FloorType ) );
            fec.WherePasses( elementsAreWanted );
            List<Element> elements = fec.ToElements() as List<Element>;

            foreach( Element element in elements )
            {
              FloorType fType = element as FloorType;

              if( fType == null )
              {
            continue;
              }

              if( fType.Name == "Generic - 12\"" )
              {
            floorType = fType;
              }
            }
              }
              catch( Exception e )
              {
            throw e;
              }

              // Set the stuctural value
              bool structural = true;

              Revit.ElementId elemId = new ElementId( 0 );

              // Create the floor instance
              try
              {
            if( level.Name == "Level 2" )
            {
              level.Elevation = 10.0;

              Floor f = doc.NewFloor( profile, floorType, level, structural );

              Revit.ElementId fId = f.Id;
              m_shedElements.Add( fId );

              // This param need to be set for any level above Level 1 for the floor to move to the correct level
              Revit.Parameter midFloorparam = f.get_Parameter( BuiltInParameter.FLOOR_HEIGHTABOVELEVEL_PARAM );
              midFloorparam.Set( 0.0 );

              return f.LevelId;
            }

            if( level.Name == "Level 1" )
            {

              Floor f = doc.NewFloor( profile, floorType, level, structural );

              Revit.ElementId fId = f.Id;
              m_shedElements.Add( fId );

              return f.LevelId;
            }

            // if none of the types match
            return elemId;
              }
              catch( Exception e )
              {
            throw e;
              }
        }
开发者ID:halad,项目名称:RevitLookup,代码行数:82,代码来源:TestElements.cs


示例15: CreateBlend

        static Blend CreateBlend( 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 factory
            = doc.FamilyCreate;

              double startAngle = 0;
              double midAngle = Math.PI;
              double endAngle = 2 * Math.PI;

              XYZ xAxis = XYZ.BasisX;
              XYZ yAxis = XYZ.BasisY;

              XYZ center = XYZ.Zero;
              XYZ normal = -XYZ.BasisZ;
              double radius = 0.7579;

              //Arc arc1 = creApp.NewArc( center, radius, startAngle, midAngle, xAxis, yAxis ); // 2013
              //Arc arc2 = creApp.NewArc( center, radius, midAngle, endAngle, xAxis, yAxis ); // 2013

              Arc arc1 = Arc.Create( center, radius, startAngle, midAngle, xAxis, yAxis ); // 2014
              Arc arc2 = Arc.Create( center, radius, midAngle, endAngle, xAxis, yAxis ); // 2014

              CurveArray baseProfile = new CurveArray();

              baseProfile.Append( arc1 );
              baseProfile.Append( arc2 );

              // create top profile:

              CurveArray topProfile = new CurveArray();

              bool circular_top = false;

              if( circular_top )
              {
            // create a circular top profile:

            XYZ center2 = new XYZ( 0, 0, 1.27 );

            //Arc arc3 = creApp.NewArc( center2, radius, startAngle, midAngle, xAxis, yAxis ); // 2013
            //Arc arc4 = creApp.NewArc( center2, radius, midAngle, endAngle, xAxis, yAxis ); // 2013

            Arc arc3 = Arc.Create( center2, radius, startAngle, midAngle, xAxis, yAxis ); // 2014
            Arc arc4 = Arc.Create( center2, radius, midAngle, endAngle, xAxis, yAxis ); // 2014

            topProfile.Append( arc3 );
            topProfile.Append( arc4 );
              }
              else
              {
            // create a skewed rectangle top profile:

            XYZ[] pts = new XYZ[] {
              new XYZ(0,0,3),
              new XYZ(2,0,3),
              new XYZ(3,2,3),
              new XYZ(0,4,3)
            };

            for( int i = 0; i < 4; ++i )
            {
              //topProfile.Append( creApp.NewLineBound( // 2013

              topProfile.Append( Line.CreateBound( // 2014
            pts[0 == i ? 3 : i - 1], pts[i] ) );
            }
              }

              Plane basePlane = creApp.NewPlane(
            normal, center );

              //SketchPlane sketch = factory.NewSketchPlane( basePlane ); // 2013
              SketchPlane sketch = SketchPlane.Create( doc, basePlane ); // 2014

              Blend blend = factory.NewBlend( true,
            topProfile, baseProfile, sketch );

              return blend;
        }
开发者ID:nbright,项目名称:the_building_coder_samples,代码行数:87,代码来源:CmdNewBlend.cs


示例16: Stream

        private void Stream(ArrayList data, CurveArray curveArray)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(CurveArray)));

            IEnumerator iter = curveArray.GetEnumerator();
            int i = 0;
            while (iter.MoveNext())
            {
                data.Add(new Snoop.Data.Object(string.Format("Curve {0:d}", i++), iter.Current));
            }
        }
开发者ID:jeremytammik,项目名称:RevitLookup,代码行数:11,代码来源:CollectorExtGeom.cs


示例17: GetCurveArray

        private CurveArray GetCurveArray(IEnumerable<LyrebirdCurve> curves)
        {
            CurveArray crvArray = new CurveArray();
            int i = 0;
            foreach (LyrebirdCurve lbc in curves)
            {
                if (lbc.CurveType == "Circle")
                {
                    XYZ pt1 = new XYZ(UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[0].X, lengthDUT), UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[0].Y, lengthDUT), UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[0].Z, lengthDUT));
                    XYZ pt2 = new XYZ(UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[1].X, lengthDUT), UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[1].Y, lengthDUT), UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[1].Z, lengthDUT));
                    XYZ pt3 = new XYZ(UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[2].X, lengthDUT), UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[2].Y, lengthDUT), UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[2].Z, lengthDUT));
                    XYZ pt4 = new XYZ(UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[3].X, lengthDUT), UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[3].Y, lengthDUT), UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[3].Z, lengthDUT));
                    XYZ pt5 = new XYZ(UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[4].X, lengthDUT), UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[4].Y, lengthDUT), UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[4].Z, lengthDUT));
                    Arc arc1 = Arc.Create(pt1, pt3, pt2);
                    Arc arc2 = Arc.Create(pt3, pt5, pt4);
                    crvArray.Append(arc1);
                    crvArray.Append(arc2);
                }
                else if (lbc.CurveType == "Arc")
                {
                    XYZ pt1 = new XYZ(UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[0].X, lengthDUT), UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[0].Y, lengthDUT), UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[0].Z, lengthDUT));
                    XYZ pt2 = new XYZ(UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[1].X, lengthDUT), UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[1].Y, lengthDUT), UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[1].Z, lengthDUT));
                    XYZ pt3 = new XYZ(UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[2].X, lengthDUT), UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[2].Y, lengthDUT), UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[2].Z, lengthDUT));
                    Arc arc = Arc.Create(pt1, pt3, pt2);
                    crvArray.Append(arc);
                }
                else if (lbc.CurveType == "Line")
                {
                    XYZ pt1 = new XYZ(UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[0].X, lengthDUT), UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[0].Y, lengthDUT), UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[0].Z, lengthDUT));
                    XYZ pt2 = new XYZ(UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[1].X, lengthDUT), UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[1].Y, lengthDUT), UnitUtils.ConvertToInternalUnits(lbc.ControlPoints[1].Z, lengthDUT));
                    Line line = Line.CreateBound(pt1, pt2);
                    crvArray.Append(line);
                }
                else if (lbc.CurveType == "Spline")
                {
                    List<XYZ> controlPoints = new List<XYZ>();
                    List<double> weights = lbc.Weights;
                    List<double> knots = lbc.Knots;

                    foreach (LyrebirdPoint lp in lbc.ControlPoints)
                    {
                        XYZ pt = new XYZ(UnitUtils.ConvertToInternalUnits(lp.X, lengthDUT), UnitUtils.ConvertToInternalUnits(lp.Y, lengthDUT), UnitUtils.ConvertToInternalUnits(lp.Z, lengthDUT));
                        controlPoints.Add(pt);
                    }
                    try
                    {
                        if (lbc.Degree == 3)
                        {
                            NurbSpline spline = NurbSpline.Create(controlPoints, weights, knots, lbc.Degree, false, true);
                            crvArray.Append(spline);
                        }
                        else
                        {
                            HermiteSpline spline = HermiteSpline.Create(controlPoints, false);
                            crvArray.Append(spline);
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine("Error", ex.Message);
                    }
                }
                i++;
            }
            return crvArray;
        }
开发者ID:samuto,项目名称:Lyrebird,代码行数:66,代码来源:LyrebirdService.cs


示例18: lock


//.........这里部分代码省略.........
                            }
                        }
                    }
                    else if (revitFamily.CategoryId == -2000032)
                    {
                        // get parameters for floors
                        FilteredElementCollector floorCollector = new FilteredElementCollector(doc);
                        floorCollector.OfClass(typeof(FloorType));
                        floorCollector.OfCategory(BuiltInCategory.OST_Floors);
                        foreach (FloorType ft in floorCollector)
                        {
                            if (ft.Name == typeName)
                            {
                                // Get the type parameters
                                List<Parameter> typeParams = new List<Parameter>();
                                foreach (Parameter p in ft.Parameters)
                                {
                                    if(!p.IsReadOnly)
                                        typeParams.Add(p);
                                }

                                // Get the instance parameters
                                List<Parameter> instParameters = new List<Parameter>();
                                using (Transaction t = new Transaction(doc, "temp family"))
                                {
                                    t.Start();
                                    Floor floor = null;
                                    try
                                    {
                                        Curve c1 = Line.CreateBound(new XYZ(0, 0, 0), new XYZ(1, 0, 0));
                                        Curve c2 = Line.CreateBound(new XYZ(0, 1, 0), new XYZ(1, 1, 0));
                                        Curve c3 = Line.CreateBound(new XYZ(1, 1, 0), new XYZ(0, 1, 0));
                                        Curve c4 = Line.CreateBound(new XYZ(0, 1, 0), new XYZ(0, 0, 0));
                                        CurveArray profile = new CurveArray();
                                        profile.Append(c1);
                                        profile.Append(c2);
                                        profile.Append(c3);
                                        profile.Append(c4);
                                        floor = doc.Create.NewFloor(profile, false);
                                    }

                                    catch (Exception ex)
                                    {
                                        // Failed to create the wall, no instance parameters will be found
                                        Debug.WriteLine(ex.Message);
                                    }
                                    if (floor != null)
                                    {
                                        foreach (Parameter p in floor.Parameters)
                                        {
                                            if (!p.IsReadOnly)
                                                instParameters.Add(p);
                                        }
                                    }
                                    t.RollBack();
                                }
                                typeParams.Sort((x, y) => String.CompareOrdinal(x.Definition.Name, y.Definition.Name));
                                instParameters.Sort((x, y) => String.CompareOrdinal(x.Definition.Name, y.Definition.Name));
                                foreach (Parameter p in typeParams)
                                {
                                    RevitParameter rp = new RevitParameter
                                    {
                                        ParameterName = p.Definition.Name,
                                        StorageType = p.StorageType.ToString(),
                                        IsType = true
                                    };
开发者ID:samuto,项目名称:Lyrebird,代码行数:67,代码来源:LyrebirdService.cs


示例19: Execute

        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication app = commandData.Application;
              UIDocument uidoc = app.ActiveUIDocument;
              Document doc = uidoc.Document;

              // Retrieve selected floors, or all floors, if nothing is selected:

              List<Element> floors = new List<Element>();
              if( !Util.GetSelectedElementsOrAll(
            floors, uidoc, typeof( Floor ) ) )
              {
            Selection sel = uidoc.Selection;
            message = ( 0 < sel.Elements.Size )
              ? "Please select some floor elements."
              : "No floor elements found.";
            return Result.Failed;
              }

              // Determine top face of each selected floor:

              int nNullFaces = 0;
              List<Face> topFaces = new List<Face>();
              Options opt = app.Application.Create.NewGeometryOptions();

              foreach( Floor floor in floors )
              {
            GeometryElement geo = floor.get_Geometry( opt );

            //GeometryObjectArray objects = geo.Objects; // 2012

            foreach( GeometryObject obj in geo )
            {
              Solid solid = obj as Solid;
              if( solid != null )
              {
            PlanarFace f = GetTopFace( solid );
            if( null == f )
            {
              Debug.WriteLine(
                Util.ElementDescription( floor )
                + " has no top face." );
              ++nNullFaces;
            }
            topFaces.Add( f );
              }
            }
              }

              // Create new floors from the top faces found
              // before creating the new floor, we would obviously
              // apply whatever modifications are required to the
              // new floor profile:

              Autodesk.Revit.Creation.Application creApp = app.Application.Create;
              Autodesk.Revit.Creation.Document creDoc = doc.Create;

              int i = 0;
              int n = topFaces.Count - nNullFaces;

              Debug.Print(
            "{0} top face{1} found.",
            n, Util.PluralSuffix( n ) );

              foreach( Face f in topFaces )
              {
            Floor floor = floors[i++] as Floor;

            if( null != f )
            {
              EdgeArrayArray eaa = f.EdgeLoops;
              CurveArray profile;

              #region Attempt to include inner loops
            #if ATTEMPT_TO_INCLUDE_INNER_LOOPS
              bool use_original_loops = true;
              if( use_original_loops )
              {
            profile = Convert( eaa );
              }
              else
            #endif // ATTEMPT_TO_INCLUDE_INNER_LOOPS
              #endregion // Attempt to include inner loops

              {
            profile = new CurveArray();

            // Only use first edge array,
            // the outer boundary loop,
            // skip the further items
            // representing holes:

            EdgeArray ea = eaa.get_Item( 0 );
            foreach( Edge e in ea )
            {
              IList<XYZ> pts = e.Tessellate();
              int m = pts.Count;
//.........这里部分代码省略.........
开发者ID:JesseMom,项目名称:the_building_coder_samples,代码行数:101,代码来源:CmdEditFloor.cs


示例20: Create

        /// <summary>
        /// Creates a new Revit Slab
        /// </summary>
        /// <param name="slab"></param>
        /// <returns></returns>
        public static Element Create(this Grevit.Types.Slab slab)
        {
            // Create a List of Curves for the ouline
            List<Curve> curves = new List<Curve>();

            // Translate Grevit Curves to Revit Curves
            for (int i = 0; i < slab.surface.profile[0].outline.Count; i++)
            {
                foreach (Curve curve in Utilities.GrevitCurvesToRevitCurves(slab.surface.profile[0].outline[i])) curves.Add(curve);
            }

            // Get the two slope points
            XYZ slopePointBottom = slab.bottom.ToXYZ();
            XYZ slopeTopPoint = slab.top.ToXYZ();

            // get a Z Value from an outline point to check if the slope points are in this plane
            double outlineZCheckValue = curves[0].GetEndPoint(0).Z;

            // If one of the points is not in the same Z plane
            // Create new points replacing the Z value
            if (!slopePointBottom.Z.Equals(outlineZCheckValue) || !slopeTopPoint.Z.Equals(outlineZCheckValue))
            {
                slopePointBottom = new XYZ(slopePointBottom.X, slopePointBottom.Y, outlineZCheckValue);
                slopeTopPoint = new XYZ(slopeTopPoint.X, slopeTopPoint.Y, outlineZCheckValue);
            }

            // Create a new slope line between the points
            Autodesk.Revit.DB.Line slopeLine = Autodesk.Revit.DB.Line.CreateBound(slopePointBottom, slopeTopPoint);

            // Sort the outline curves contiguous
            Utilities.SortCurvesContiguous(GrevitBuildModel.document.Application.Create, curves);

            // Create a new surve array for creating the slab
            CurveArray outlineCurveArray = new CurveArray();
            foreach (Curve c in curves) outlineCurveArray.Append(c);

            // get the supposed level
            Element levelElement = GrevitBuildModel.document.GetLevelByName(slab.levelbottom,slopePointBottom.Z);
            if (levelElement != null)
            {
                // Create a new s 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CurveLoop类代码示例发布时间:2022-05-24
下一篇:
C# Curve类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap