Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PickFirstSelectionSet

Status
Not open for further replies.

TTops

MIS
Sep 13, 2004
70
US
Greetings,

I am trying to let the user click on an "AcDbText" object and then use a hot key (Ctrl + E) to execute the following code:

****Start Code****
Sub EditPieceMark()
Dim SelectedItem As AcadText
Dim SelectionSet As AcadSelectionSet
Dim ReturnPnt As Variant
Dim PieceMarkRef As String

Set SelectionSet = ThisDrawing.PickfirstSelectionSet
If SelectionSet(0).ObjectName = "AcDbText" Then
Set SelectedItem = SelectionSet(0)
PieceMarkRef = Left(SelectedItem, InStr(1, SelectedItem, " "))
PieceMarkRef = Right(PieceMarkRef, Len(PieceMarkRef) - 1)
Else
MsgBox "You have selected the wrong type of item for this operation", vbExclamation + vbOKOnly, "Non-Text Item Selected"
Exit Sub
End If
FormIdentifier = "Edit"
Load frmAddBOMPart(PieceMarkRef)
frmAddBOMPart.Show
End Sub
****End Code****

My problem is that whenever the user presses the hot key, it seems to deselect the item on the drawing so that the AcadSelectionSet.Count is always zero. This throws the following error: "Invalid argument index in Item". This occurs when the if statement is executed. Any help would be greatly appreciated.
 
What does you call to this code look like as assigned to ctrl+E?

What version of autoCAD are you working in?

Kevin Petursson
 
I am working with AutoCAD 2006. My call to the ctrl+E looks like: (command "_-vbarun" "EditPieceMark")
where "EditPieceMark" is the sub routine in the module. This was done as a Macro.

But it doesn't matter now. I found an answer. I simply changed the "Set SelectionSet = ThisDrawing.PickfirstSelectionSet" line to "Set SelectionSet = ThisDrawing.ActiveSelectionSet" and everything seems to work just fine. Thanks for your interest in this problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top