Public Sub GetEntity(PLArea, PLCentroid) Dim objEnt As AcadEntity Dim varPick As Variant Dim Pline As AcadLWPolyline Dim loops(0) As AcadEntity, region Dim CenPt As Variant On Error Resume Next With ThisDrawing.Utility .GetEntity objEnt, varPick, vbCr & "Pick a Polyline: " If objEnt Is Nothing Then 'check if object was picked. .Prompt vbCrLf & "You did not pick as entity" Exit Sub End If If objEnt.ObjectName <> "AcDbPolyline" Then 'check if object was picked. MsgBox "That is not a PolyLine. It is a(n) " & objEnt.ObjectName & ". Please start over and try again." End End If End With 'cast Entity to Polyline proper Set Pline = objEnt PLArea = Pline.Area / 43560 ThisDrawing.SetVariable "DELOBJ", 0 ' this will prevent deleting the polyline Set loops(0) = objEnt region = ThisDrawing.ModelSpace.AddRegion(loops) CenPt = region(0).Centroid ' now that I have the centroid how do I delete the region I just created End Sub
From novice to tech pro — start learning today.