- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am writing a routine that is supposed to get the heights and radii of all cylinders in a drawing. The cylinders are not necessarily aligned with WCS.
I am able to successfully find and identify which 3D Solids are cylinders, but am having a really hard time determining the height and radii of these entities. I am using ARX and the COM interface to get to the place where I identify the entity as a cylinder. From there I have tried either using properties of the Solid3D class, or the Acad3DSolid class. Example properties include: centroid, moments of inertia, principal moments, bounding box etc. Volume is also a property. I believe there is some math that can be done with these properties to determine height and radius, but most of my attempts only work if the cylinder is aligned with WCS. The requirements dictate the cylinder can be at any orientation. The Autodesk.AutoCAD.Geometry.Cylinder object does have a height and radius property, but I cannot find away to cast either the Solid3D or Acad3DSolid objects into the geometry. Any help would be appreciated, either with the correct math to determine on the object properties or some way to utilize another class. Looking at the properties of a cylinder in AutoCAD itself, the 3DSolid cylinder solidType clearly have height and radius properties (see screen shot).
Private Shared Sub getCylinderLengths()
Dim Solid3DobjectIDs As New List(Of ObjectId)
Solid3DobjectIDs = getAll3dSolidObjIDs() 'returns a list of objectID that are of type 3DSolid
Dim db As Database = HostApplicationServices.WorkingDatabase
If Solid3DobjectIDs.Count > 0 Then
For Each objid In Solid3DobjectIDs
Using t As Transaction = db.TransactionManager.StartTransaction()
Dim thisSolid As Solid3d = TryCast(t.GetObject(objid, OpenMode.ForRead), Solid3d)
Dim AcadSol As Autodesk.AutoCAD.Interop.Common.Acad3DSolid = thisSolid.AcadObject
If AcadSol.SolidType = "Cylinder" Then
'find radius and height here.
End If
t.Commit()
End Using
Next
End If
End Sub
Solved! Go to Solution.