<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Getting (subentity) vertex points of swept solid in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/6662855#M33972</link>
    <description>&lt;P&gt;Try this code. Maybe this is a better solution:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.BoundaryRepresentation;

// This line is not mandatory, but improves loading performances
[assembly: CommandClass(typeof(GetSweepAxis.MyCommands))]

namespace GetSweepAxis
{

  public class MyCommands
  {

    [CommandMethod("FindCylinderAxis")]
    public void FindCylinderAxis()
    {
      Document doc = Application.DocumentManager.MdiActiveDocument;
      Editor ed = doc.Editor;
      PromptEntityOptions peo = new PromptEntityOptions("Pick a 3DSOLID: ");
      peo.SetRejectMessage("\nA 3d solid must be selected.");
      peo.AddAllowedClass(typeof(Autodesk.AutoCAD.DatabaseServices.Solid3d), true);
      PromptEntityResult per = ed.GetEntity(peo);
      if (per.Status != PromptStatus.OK)
        return;

      using (Transaction tr = doc.Database.TransactionManager.StartTransaction())
      {
        Solid3d sld = tr.GetObject(per.ObjectId, OpenMode.ForRead, false) as Solid3d;
        Point3d axisPt1 = Point3d.Origin;
        Point3d axisPt2 = Point3d.Origin;
        Point3dCollection pts = new Point3dCollection();
        if (GetCylinderAxis(sld, ref  pts))
        {
          for (int i = 0; i &amp;lt; pts.Count; i++)
          {
            ed.WriteMessage("\nPt[{0}] = {1}", i, pts[i]);
          }
        }
        else
        {
          ed.WriteMessage("\nNot a sweeped solid");
        }
        tr.Commit();
      }
    }

    private bool GetCylinderAxis(Solid3d solid, ref Point3dCollection pts)
    {
      using (Brep brep = new Brep(solid))
      {
        BrepEdgeCollection edges = brep.Edges;
        foreach (Edge edge in edges)
        {
          Curve3d curv = ((ExternalCurve3d)edge.Curve).NativeCurve;
          if (curv is CircularArc3d)
          {
            CircularArc3d circle = curv as CircularArc3d;
            if (!pts.Contains(circle.Center)) pts.Add(circle.Center);
          }
          else if (curv is EllipticalArc3d)
          {
            EllipticalArc3d circle = curv as EllipticalArc3d;
            if (!pts.Contains(circle.Center)) pts.Add(circle.Center);
          }
        }
      }
      return (pts.Count &amp;gt; 1) ? true : false;
    }
  }
}
&lt;/PRE&gt;</description>
    <pubDate>Wed, 02 Nov 2016 16:15:01 GMT</pubDate>
    <dc:creator>Alexander.Rivilis</dc:creator>
    <dc:date>2016-11-02T16:15:01Z</dc:date>
    <item>
      <title>Getting (subentity) vertex points of swept solid</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/6659519#M33963</link>
      <description>&lt;P&gt;I am trying to find the vertex points of a swept polyline. So i have a solid that was created by sweeping a circle along a 3D polyline. It looks like that (and i would like to get the coordinates of those vertex points):&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Untitled.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/288145iAE7A8690160ADE99/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Untitled.png" alt="Untitled.png" /&gt;&lt;/span&gt;﻿&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Googling the whole of Friday last week i think i have to play around with the subentity part. I found out how to change the color of the subentity edges for instance, but couldn't for Christs sake not find out how to access the geometric&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what i tried out so far, but as i noted right at the bottom i am kinda lost there. (or am i completely on the wrong path with subentity)&lt;/P&gt;&lt;P&gt;(long story short, I want to get the coordinates of the vertices of the 3D solid that was swept from a 3dpolyline by using a circle)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    [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&amp;lt;SubentityId&amp;gt; subEntIds = new List&amp;lt;SubentityId&amp;gt;();

            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();
        }
    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 11:35:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/6659519#M33963</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-11-01T11:35:09Z</dc:date>
    </item>
    <item>
      <title>Re: Getting (subentity) vertex points of swept solid</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/6659788#M33964</link>
      <description>&lt;P&gt;Try to use &lt;STRONG&gt;GetGripPoints&lt;/STRONG&gt; method to get vertexes. But if history of Solid3d is cleared I think there is no method to get vertexes of 3dpolyline.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;P.S.: Correct forum for AutoCAD .NET API questions &amp;gt;&amp;gt;&amp;gt;&lt;A href="https://forums.autodesk.com/t5/net/bd-p/152" target="_blank"&gt;&lt;STRONG&gt;here&lt;/STRONG&gt;&lt;/A&gt;&amp;lt;&amp;lt;&amp;lt;&amp;nbsp; This forum is only for ObjectARX (C++) questions.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 13:40:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/6659788#M33964</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2016-11-01T13:40:49Z</dc:date>
    </item>
    <item>
      <title>Re: Getting (subentity) vertex points of swept solid</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/6659852#M33965</link>
      <description>&lt;P&gt;oh, sorry for posting it in the wrong forum.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;cheers for the answer, i will dig into that&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 14:08:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/6659852#M33965</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-11-01T14:08:02Z</dc:date>
    </item>
    <item>
      <title>Re: Getting (subentity) vertex points of swept solid</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/6659864#M33966</link>
      <description>&lt;P&gt;If you find another solution, then share it with all.&lt;/P&gt;
&lt;P&gt;You can also getting all Faces/Edges/Vertexes of this Solid3d (with help of BREP .NET API), but I am not sure that you can identify vertexes of 3dpolyline among all other vertexes of Solid3d.&lt;/P&gt;
&lt;P&gt;Also you can read:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://adndevblog.typepad.com/autocad/2015/09/finding-axis-end-points-of-a-cylindrical-3d-solid.html" target="_blank"&gt;http://adndevblog.typepad.com/autocad/2015/09/finding-axis-end-points-of-a-cylindrical-3d-solid.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://adndevblog.typepad.com/autocad/2012/08/retrieving-native-curve-geometry-using-brep-api.html" target="_blank"&gt;http://adndevblog.typepad.com/autocad/2012/08/retrieving-native-curve-geometry-using-brep-api.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2016 14:28:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/6659864#M33966</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2016-11-01T14:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: Getting (subentity) vertex points of swept solid</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/6660211#M33967</link>
      <description>&lt;P&gt;as you already warned me the getgrippoints wont differ between the grippoints, so i would get all of them and not just the ones of the polyline&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i've fallen over the GetObjectSnapPoints method now but for some reason with the samplecode i wrote it wont fill the point collection (snappoints) at all&lt;/P&gt;&lt;P&gt;does anyone have a clue what i am doing wrong there:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        [CommandMethod("testcentersnap")]
        public void testcentersnap()
        {
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            
            
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                PromptEntityResult selectionRes = ed.GetEntity("Select Entity ");

                if (selectionRes.Status == PromptStatus.OK)
                {
                    try
                    {
                        ObjectId objId = selectionRes.ObjectId;
                        Entity ent = (Entity)tr.GetObject(objId, OpenMode.ForRead);

                        Point3d tempPoint = new Point3d();
                        Matrix3d mat = Matrix3d.Identity;
                        Point3dCollection snapPts = new Point3dCollection();
                        IntegerCollection geomIds = new IntegerCollection(1);

                        ent.GetObjectSnapPoints(ObjectSnapModes.ModeCenter, 1, tempPoint, tempPoint, mat, snapPts, geomIds);                        

                        foreach (Point3d singlePoint3D in snapPts)
                        {
                            ed.WriteMessage("X: " + singlePoint3D.X.ToString() + "\n" +
                                            "Y: " + singlePoint3D.Y.ToString() + "\n" +
                                            "Z: " + singlePoint3D.Z.ToString() + "\n");
                        }                        
                    }
                    catch (Autodesk.AutoCAD.Runtime.Exception ex)
                    {
                        ed.WriteMessage(ex.Message);
                        tr.Abort();
                    }
                }
            }
        }&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Nov 2016 16:28:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/6660211#M33967</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-11-01T16:28:28Z</dc:date>
    </item>
    <item>
      <title>Re: Getting (subentity) vertex points of swept solid</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/6660322#M33968</link>
      <description>GetObjectSnapPoints can not help you.</description>
      <pubDate>Tue, 01 Nov 2016 17:04:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/6660322#M33968</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2016-11-01T17:04:17Z</dc:date>
    </item>
    <item>
      <title>Re: Getting (subentity) vertex points of swept solid</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/6662586#M33969</link>
      <description>&lt;P&gt;it indeed did not help hehe &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in my case all the swept solids were created by sweeping a circle around the path&lt;/P&gt;&lt;P&gt;So for my situation the following solution does the job.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can ignore the 5 first grip points as they will always be the grip points of the sweep element (a circle)&lt;/P&gt;&lt;P&gt;i then stay left with the grip points of the sweep path&lt;/P&gt;&lt;P&gt;i further then check if the grips are the middle grips or not, in case they are i remove them from my list where i store all the grips&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is the code i ended up for now (that is by far not an optimized solution, but it does its job for now, if anyone has better solutions/ideas just keep them comin:) &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;        /// &amp;lt;summary&amp;gt;
        /// gets the middle of two points
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="p1"&amp;gt;&amp;lt;/param&amp;gt;
        /// &amp;lt;param name="p2"&amp;gt;&amp;lt;/param&amp;gt;
        /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;
        public static Point3d GetMiddlePoint(Point3d p1, Point3d p2)
        {
            LineSegment3d temporaryLine = new LineSegment3d(p1, p2);
            return temporaryLine.MidPoint;
        }

        /// &amp;lt;summary&amp;gt;
        /// checks if the point is a middle point of the previous and following point
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="p1"&amp;gt;&amp;lt;/param&amp;gt;
        /// &amp;lt;param name="p2"&amp;gt;&amp;lt;/param&amp;gt;
        /// &amp;lt;param name="testingPoint"&amp;gt;&amp;lt;/param&amp;gt;
        /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;
        public static bool IsMidPointOfVertices(Point3d p1, Point3d p2, Point3d testingPoint)
        {
            if (GetMiddlePoint(p1, p2) == testingPoint)
                return true;

            return false;
        }

        /// &amp;lt;summary&amp;gt;
        /// Label all the vertex points in a swept 3d solid
        /// only works if the sweep element is a circle
        /// &amp;lt;/summary&amp;gt;
        [CommandMethod("GripPoint")]
        static public void GripPoint()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                try
                {
                    // Prompt for selection of a solid to be traversed
                    PromptEntityOptions prEntOpt = new PromptEntityOptions("\nSelect a 3D solid:");
                    prEntOpt.SetRejectMessage("\nMust be a 3D solid.");
                    prEntOpt.AddAllowedClass(typeof(Solid3d), true);
                    PromptEntityResult prEntRes = ed.GetEntity(prEntOpt);

                    ObjectId[] objIds = { prEntRes.ObjectId };
                    Solid3d en = (Solid3d)tr.GetObject(prEntRes.ObjectId, OpenMode.ForRead);

                    // declaring needed variables for GetGripPoints() method
                    GripDataCollection gripsTotalAmount = new GripDataCollection();
                    double curViewUnitSize = 0;
                    int gripSize = 0;
                    Vector3d curViewDir = doc.Editor.GetCurrentView().ViewDirection;
                    GetGripPointsFlags bitFlags = GetGripPointsFlags.GripPointsOnly;
                    en.GetGripPoints(gripsTotalAmount, curViewUnitSize, gripSize, curViewDir, bitFlags);

                    // if we have more than 8 vertices than we have a proper polyline (5 alone for the sweepcircle)
                    // so only if we have more than 8 we swap it into our list (from 5 till end of grips)
                    if (gripsTotalAmount.Count &amp;gt; 7)
                    {
                        List&amp;lt;GripData&amp;gt; polyLineGrips = new List&amp;lt;GripData&amp;gt;();

                        for (int counter = 5; counter &amp;lt; gripsTotalAmount.Count; counter++)
                            polyLineGrips.Add(gripsTotalAmount[counter]);


                        // loop through all polyline grips and see if we have middlepoint grips
                        // if we do, we remove them from the list
                        // starting from maxcount and going down so RemoveAt wont change the order
                        int whileCounter = polyLineGrips.Count - 2;
                        while (whileCounter &amp;gt; 0)
                        {
                            // check if current point is middlepoint and remove it fromt he list
                            // if that is the case
                            if (IsMidPointOfVertices(polyLineGrips[whileCounter - 1].GripPoint,
                                                      polyLineGrips[whileCounter + 1].GripPoint,
                                                      polyLineGrips[whileCounter].GripPoint))
                            {
                                polyLineGrips.RemoveAt(whileCounter);
                            }
                            whileCounter--;
                        }
                        

                        // temporary for loop to showcase labelling (testing purpose only)
                        for (int counter = 0; counter &amp;lt; polyLineGrips.Count; counter++)
                        {
                            // Open the Block table record Model space for write
                            BlockTable acBlkTbl = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
                            BlockTableRecord acBlkTblRec = tr.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;

                            // Create a single-line text object
                            DBText acText = new DBText();
                            acText.SetDatabaseDefaults();
                            acText.Position = polyLineGrips[counter].GripPoint;
                            acText.Height = 0.05;
                            acText.TextString = Convert.ToString(counter + 1);

                            // Add the new object to the block table record and the transaction
                            acBlkTblRec.AppendEntity(acText);
                            tr.AddNewlyCreatedDBObject(acText, true);
                        }
                    }

                    tr.Commit();
                }
                catch (System.Exception ex)
                {
                    ed.WriteMessage("\nException during traversal: {0}", ex.Message);
                }
            }
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2016 15:08:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/6662586#M33969</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-11-02T15:08:08Z</dc:date>
    </item>
    <item>
      <title>Re: Getting (subentity) vertex points of swept solid</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/6662648#M33970</link>
      <description>&lt;P&gt;If history was cleared (command BREP) then you code do not return appropriate vertexes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2016-11-02_17-21-29.png" style="width: 705px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/288567i658C737668E1B04E/image-size/large?v=v2&amp;amp;px=999" role="button" title="2016-11-02_17-21-29.png" alt="2016-11-02_17-21-29.png" /&gt;&lt;/span&gt;﻿&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2016 15:23:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/6662648#M33970</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2016-11-02T15:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: Getting (subentity) vertex points of swept solid</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/6662737#M33971</link>
      <description>&lt;P&gt;yeah thats what i found out aswell, luckily its for a very specific task and i know for sure that the history wont be cleared for where we use it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am sadly aware that it is not a perfect (actually far away from that) or beautiful suoltion.&lt;/P&gt;&lt;P&gt;BUT it is a solution that does its job for now &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2016 15:40:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/6662737#M33971</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-11-02T15:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: Getting (subentity) vertex points of swept solid</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/6662855#M33972</link>
      <description>&lt;P&gt;Try this code. Maybe this is a better solution:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.BoundaryRepresentation;

// This line is not mandatory, but improves loading performances
[assembly: CommandClass(typeof(GetSweepAxis.MyCommands))]

namespace GetSweepAxis
{

  public class MyCommands
  {

    [CommandMethod("FindCylinderAxis")]
    public void FindCylinderAxis()
    {
      Document doc = Application.DocumentManager.MdiActiveDocument;
      Editor ed = doc.Editor;
      PromptEntityOptions peo = new PromptEntityOptions("Pick a 3DSOLID: ");
      peo.SetRejectMessage("\nA 3d solid must be selected.");
      peo.AddAllowedClass(typeof(Autodesk.AutoCAD.DatabaseServices.Solid3d), true);
      PromptEntityResult per = ed.GetEntity(peo);
      if (per.Status != PromptStatus.OK)
        return;

      using (Transaction tr = doc.Database.TransactionManager.StartTransaction())
      {
        Solid3d sld = tr.GetObject(per.ObjectId, OpenMode.ForRead, false) as Solid3d;
        Point3d axisPt1 = Point3d.Origin;
        Point3d axisPt2 = Point3d.Origin;
        Point3dCollection pts = new Point3dCollection();
        if (GetCylinderAxis(sld, ref  pts))
        {
          for (int i = 0; i &amp;lt; pts.Count; i++)
          {
            ed.WriteMessage("\nPt[{0}] = {1}", i, pts[i]);
          }
        }
        else
        {
          ed.WriteMessage("\nNot a sweeped solid");
        }
        tr.Commit();
      }
    }

    private bool GetCylinderAxis(Solid3d solid, ref Point3dCollection pts)
    {
      using (Brep brep = new Brep(solid))
      {
        BrepEdgeCollection edges = brep.Edges;
        foreach (Edge edge in edges)
        {
          Curve3d curv = ((ExternalCurve3d)edge.Curve).NativeCurve;
          if (curv is CircularArc3d)
          {
            CircularArc3d circle = curv as CircularArc3d;
            if (!pts.Contains(circle.Center)) pts.Add(circle.Center);
          }
          else if (curv is EllipticalArc3d)
          {
            EllipticalArc3d circle = curv as EllipticalArc3d;
            if (!pts.Contains(circle.Center)) pts.Add(circle.Center);
          }
        }
      }
      return (pts.Count &amp;gt; 1) ? true : false;
    }
  }
}
&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Nov 2016 16:15:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/6662855#M33972</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2016-11-02T16:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: Getting (subentity) vertex points of swept solid</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/6664323#M33973</link>
      <description>&lt;P&gt;that is obviously a way better solution, thanks a lot&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so frustrating how i keep searching and searching and in the end the solution i come up with is so much worse than what you just typed in a few seconds &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;thanks for the help, much appreciated!&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2016 09:18:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/6664323#M33973</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-11-03T09:18:10Z</dc:date>
    </item>
    <item>
      <title>Re: Getting (subentity) vertex points of swept solid</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/6664429#M33974</link>
      <description>&lt;P&gt;This solution I also did not immediately found. It is base on this topic: &lt;A href="http://adndevblog.typepad.com/autocad/2015/09/finding-axis-end-points-of-a-cylindrical-3d-solid.html" target="_blank" rel="nofollow noopener noreferrer"&gt;http://adndevblog.typepad.com/autocad/2015/09/find&lt;WBR /&gt;ing-axis-end-points-of-a-cylindrical-3d-solid.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;But in your case not CircularArc3d but also EllipticalArc3d curve may appeared.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2016 10:22:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/6664429#M33974</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2016-11-03T10:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: Getting (subentity) vertex points of swept solid</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/12231056#M33975</link>
      <description>&lt;P&gt;Thanks for sharing the code. However not sure how to use in civil3D 2022. Need further guidance&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 04:51:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/12231056#M33975</guid>
      <dc:creator>Abhay.KaranjikarQRNDZ</dc:creator>
      <dc:date>2023-09-11T04:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: Getting (subentity) vertex points of swept solid</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/12231689#M33976</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12932123"&gt;@Abhay.KaranjikarQRNDZ&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CAN YUO START&lt;/P&gt;&lt;P&gt;&lt;A title="Setting up a .NET Project for Autodesk Civil 3D" href="https://help.autodesk.com/view/CIV3D/2024/ENU/?guid=GUID-DE3A46DA-508E-43A0-8538-C77D978D06B2" target="_blank" rel="noopener"&gt;Setting up a .NET Project for Autodesk Civil 3D&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.JPG" style="width: 867px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1264615i4E6B66FE2CCD3997/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.JPG" alt="1.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 11:03:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-subentity-vertex-points-of-swept-solid/m-p/12231689#M33976</guid>
      <dc:creator>hosneyalaa</dc:creator>
      <dc:date>2023-09-11T11:03:27Z</dc:date>
    </item>
  </channel>
</rss>

