By Virupaksha Aithal
You can use Object id to send the “entity selection” while sending the command to AutoCAD using SendCommand API. You need to format the command string such that it contains the objectid handles. Refer below code, which invokes the fillet command after getting 2 lines from the user. The fillet command is used to show the use of Object id during the command invocation and you can use this logic in any other command which requires object selection.
_
Public Sub testFillet()
Dim doc As Document = _
Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = doc.Editor
Dim Db As Database = doc.Database
Dim pEntRes1 As PromptEntityResult = ed.GetEntity( _
"Select first line to Fillet")
If pEntRes1.Status PromptStatus.OK Then
Return
End If
Dim obj1 As String = pEntRes1.ObjectId.ObjectClass.Name
If String.Compare(obj1, "AcDbLine", True) 0 Then
ed.WriteMessage("Select line entity" + vbLf)
Return
End If
Dim pEntRes2 As PromptEntityResult = ed.GetEntity( _
"Select second line to Fillet")
If pEntRes2.Status PromptStatus.OK Then
Return
End If
obj1 = pEntRes2.ObjectId.ObjectClass.Name
If String.Compare(obj1, "AcDbLine", True) 0 Then
ed.WriteMessage("Select line entity" + vbLf)
Return
End If
Dim strHandle1 As String = _
pEntRes1.ObjectId.Handle.ToString()
Dim strEntName1 As String = _
"(handent """ & strHandle1 & """)"
Dim strHandle2 As String = _
pEntRes2.ObjectId.Handle.ToString()
Dim strEntName2 As String = _
"(handent """ & strHandle2 & """)"
Dim strCommand As String = _
"_fillet" + vbCr + "r" + vbCr + "0.495" + _
vbCr + strEntName1 + vbCr + strEntName2 + vbCr
doc.AcadDocument.SendCommand(strCommand)
End Sub

Leave a Reply