Hi all - I'm wondering if it is possible to test for concentricity - as in, to select every object contained within a circle / polyline / polygon etc. Is this possible using Autocad's .NET api?
What you are describing is not concentricity. That is when arcs or circles share the same centerpoint.
If you want to check if an entity is inside a boundary you can use this example:
<CommandMethod("ChkInside", CommandFlags.Modal)> Public Shared Sub ChkInside()
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = doc.Editor
Dim db As Database = doc.Database
Dim peo As New PromptEntityOptions(vbLf & "Select circle: ")
peo.SetRejectMessage(vbLf & "Should be a circle!")
peo.AddAllowedClass(GetType(Circle), False)
Dim per As PromptEntityResult = ed.GetEntity(peo)
If per.Status <> PromptStatus.OK Then Return
Dim peo2 As New PromptEntityOptions(vbLf & "Select line: ")
peo2.SetRejectMessage(vbLf & "Should be a line!")
peo2.AddAllowedClass(GetType(Line), False)
Dim per2 As PromptEntityResult = ed.GetEntity(peo2)
If per2.Status <> PromptStatus.OK Then Return
Using trx As Transaction = db.TransactionManager.StartTransaction()
Dim Boundary As Curve = CType(trx.GetObject(per.ObjectId, OpenMode.ForRead), Curve)
Using trimmer As New Autodesk.AutoCAD.ExportLayout.Trimmer()
Dim EntityToCheck As Entity = CType(trx.GetObject(per2.ObjectId, OpenMode.ForWrite), Entity)
trimmer.Trim(EntityToCheck, Boundary)
If trimmer.EntityCompletelyInside Then
ed.WriteMessage(vbLf & "INSIDE")
Else
ed.WriteMessage(vbLf & "NOT INSIDE")
End If
End Using
End Using
End Sub
This is just a quick example to check if a selected line is inside a selected boundary (circle in this example).
It should be fairly easy to adapt this to check for a larger selection of entities.
Hey, thanks so much for the reply! This is exactly what I needed - I'm using C# rather than VB, however, and I can't find any reference to Trimmer usage in the documentation and "ExportLayout" doesn't show up when I search the contents of Autodesk.Autocad in my ide. Do you know where I can find the proper documentation for implementing this in C#?
Tyler 🙂
For 'documentation' you will need have to look here:
https://forums.autodesk.com/t5/net/how-to-trim-the-culve-outside-the-polyline/m-p/7705850
This is where I found this for my own projects. It seems there is no real documentation for this feature.
You can find some more nice features of the trimmer also.
Although I must say that some features don't seem to work very consistently, so the lack of documentation means it can be difficult to troubleshoot.
Trnaslating from VB.NET to C# can be done with this transloator:
Can't find what you're looking for? Ask the community or share your knowledge.