2016-10-31 2 views
3

스윕 폴리 라인의 정점을 찾으려고합니다. 3D 폴리 라인을 따라 원을 스윕함으로써 생성 된 솔리드가 있습니다. 다음과 같이 보입니다 : image of sweeped solidAutoCAD에서 부속 점 버텍스 점을 얻는 방법

지난 주 금요일 전체를 Googeling하는 것은 내가 어젠 티티 부분으로 놀아야 만한다고 생각합니다. 예를 들어, 하위 엔티티의 색상을 변경하는 방법을 알았지 만 기하학에 액세스하는 방법을 찾지 못한 그리스도를위한 couldnt

이것은 내가 지금까지 시험해 보았던 것이지만 내가 바닥에서 바로 지적했듯이 좀이 손실 오전 :

[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로 내보내고 텍스트 파일의 데이터 구성을 살펴 보는 것은 어떻습니까? 하위 실체의 메커니즘을 설명 할 수 있습니다. 나는 그 사건에 대한 구체적인 지식을 가지고 있지 않지만, 만약 그들이 "이드"라면 그 다음에 그 이드를 "열어"무엇을 할 것인가? 이것들은 좌표 데이터를 제공하는 적절한 객체를 반환합니다. 그러나 그것은 추측입니다. 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]); 
       } 
      } 
관련 문제