2016-10-31 2 views
3

Я пытаюсь найти вершинные точки прогнутой полилинии. Итак, у меня есть твердое тело, которое было создано путем подметания круга вдоль трехмерной полилинии. Это выглядит так: image of sweeped solidПолучение точек вершины сущности в AutoCAD

Googeling весь пятница на прошлой неделе, я думаю, что мне нужно поиграть с частью субовости. Я узнал, как изменить цвет краев сущности, например, но не мог для christs не узнать, как получить доступ к геометрическим

Это то, что я пробовал до сих пор, но, как я заметил прямо внизу я вроде потерял там:

[CommandMethod("SubEntExample")] 
    public void SubEntExample() 
    { 
     Document doc = Application.DocumentManager.MdiActiveDocument; 
     Database db = doc.Database; 
     Editor ed = doc.Editor; 

     PromptEntityOptions peo = new PromptEntityOptions("\nSelect a 3D solid: "); 
     peo.SetRejectMessage("\nInvalid selection..."); 
     peo.AddAllowedClass(typeof(Solid3d), true); 

     PromptEntityResult per = ed.GetEntity(peo); 

     if (per.Status != PromptStatus.OK) 
      return; 

     using (Transaction Tx = db.TransactionManager.StartTransaction()) 
     { 
      Solid3d solid = Tx.GetObject(per.ObjectId, OpenMode.ForWrite) as Solid3d; 

      ObjectId[] ids = new ObjectId[] { per.ObjectId }; 

      FullSubentityPath path = new FullSubentityPath(ids, new SubentityId(SubentityType.Null, IntPtr.Zero)); 

      List<SubentityId> subEntIds = new List<SubentityId>(); 

      using (Autodesk.AutoCAD.BoundaryRepresentation.Brep brep = 
       new Autodesk.AutoCAD.BoundaryRepresentation.Brep(path)) 
      {      
       foreach (Autodesk.AutoCAD.BoundaryRepresentation.Edge edge in brep.Edges) 
       { 
        subEntIds.Add(edge.SubentityPath.SubentId); 
       }      
      } 

      foreach (SubentityId subentId in subEntIds) 
      { 

       *** here i am lost *** 

      } 
      Tx.Commit(); 
     } 
    } 
+0

Как насчет экспорта объекта в DXF и просмотра макияжа данных в текстовом файле? Это может объяснить вам механики субобъектов. У меня нет конкретных знаний об этом деле, но если они «id», то вы бы хотели, чтобы «открыть» эти идентификаторы? Они возвращают подходящие объекты, которые предоставляют данные координат. Но это догадка. Глядя на DXF может показать вам больше информации. Возможно, вы могли бы добавить его к своему вопросу. –

ответ

0

мое первое решение участвовать получить все ручки и решения, которые имеют отношение, но слава к оказали помощь в Интернете (:)) я придумал, как лучшее решение

/// <summary> 
    /// Checks if there are boundaryreps that are marked as elliptical or circular arcs 
    /// returns true if we found at least 2 of those points 
    /// also stores the points in a referenced Point3dCollection 
    /// </summary> 
    /// <param name="solid"></param> 
    /// <param name="pts"></param> 
    /// <returns></returns> 
    private bool GetSweepPathPoints(Solid3d solid, ref Point3dCollection pts) 
    { 
     // create boundary rep for the solid 
     using (Brep brep = new Brep(solid)) 
     { 
      // get edges of the boundary rep 
      BrepEdgeCollection edges = brep.Edges; 
      foreach (Edge edge in edges) 
      { 
       // get the nativ curve geometry of the edges and then 
       // check if it is a circle 
       // for more info look at: 
       // http://adndevblog.typepad.com/autocad/2012/08/retrieving-native-curve-geometry-using-brep-api.html 
       Curve3d curv = ((ExternalCurve3d)edge.Curve).NativeCurve; 
       if (curv is CircularArc3d) 
       { 
        // transform curved arch into circle and add it to the colecction 
        // (if not in it alreadz) 
        CircularArc3d circle = curv as CircularArc3d; 
        if (!pts.Contains(circle.Center)) pts.Add(circle.Center); 
       } 
      } 
     } 
     return (pts.Count > 1) ? true : false; 
    } 

Я называю все это следующим образом:

  Point3dCollection pts = new Point3dCollection(); 
      // only do the whole thing if we face a swept solid 
      if (GetSweepPathPoints(sld, ref pts)) 
      { 
       for (int i = 0; i < pts.Count; i++) 
       { 
        ed.WriteMessage("\nPt[{0}] = {1}", i, pts[i]); 
       } 
      } 
Смежные вопросы