OS Windows 7, Acad 2007 trying to write vb6 program to select on screen.
I can communicate with the open acad2007 but there are no Items in the variable ssetobj after a selection.
Code:
Private Sub Command_Click()
Dim myapp As AcadApplication
Dim mydoc As AcadDocument
Dim ssetObj As AcadSelectionSet
Dim ent As AcadObject
Dim numVertices As Long
On Error GoTo err:
Set myapp = GetObject(, "AutoCAD.Application.17")
Set mydoc = myapp.ActiveDocument
If mydoc.SelectionSets.Count > 0 Then
mydoc.SelectionSets(0).Delete
End If
Set ssetObj = mydoc.SelectionSets.Add("ss")
list1.Clear
Me.Hide
AppActivate ("Autocad")
ssetObj.SelectOnScreen:'SELECTION WORKS
Dim numpls As Integer
numpls = ssetObj.Count
Dim i As Integer
For i = 0 To numpls - 1
Set ent = ssetObj.Item(i):':confused:PROBLEM HERE SINCE THERE ARE NO ITEMS IN SSETOBJ
'DO STUFF
If ent.ObjectName = "AcDbLWPolyline" Or ent.ObjectName = "AcDbPolyline" Then
numVertices = (UBound(ent.Coordinates) + 1) / 2
list1.AddItem Str(ent.ObjectID) + "\" + Str(numVertices) + " Vertices"
End If
'END DO STUFF
Next i
Me.Show
Exit Sub
err:
MsgBox err.Description
End Sub
I can communicate with the open acad2007 but there are no Items in the variable ssetobj after a selection.
Code:
Private Sub Command_Click()
Dim myapp As AcadApplication
Dim mydoc As AcadDocument
Dim ssetObj As AcadSelectionSet
Dim ent As AcadObject
Dim numVertices As Long
On Error GoTo err:
Set myapp = GetObject(, "AutoCAD.Application.17")
Set mydoc = myapp.ActiveDocument
If mydoc.SelectionSets.Count > 0 Then
mydoc.SelectionSets(0).Delete
End If
Set ssetObj = mydoc.SelectionSets.Add("ss")
list1.Clear
Me.Hide
AppActivate ("Autocad")
ssetObj.SelectOnScreen:'SELECTION WORKS
Dim numpls As Integer
numpls = ssetObj.Count
Dim i As Integer
For i = 0 To numpls - 1
Set ent = ssetObj.Item(i):':confused:PROBLEM HERE SINCE THERE ARE NO ITEMS IN SSETOBJ
'DO STUFF
If ent.ObjectName = "AcDbLWPolyline" Or ent.ObjectName = "AcDbPolyline" Then
numVertices = (UBound(ent.Coordinates) + 1) / 2
list1.AddItem Str(ent.ObjectID) + "\" + Str(numVertices) + " Vertices"
End If
'END DO STUFF
Next i
Me.Show
Exit Sub
err:
MsgBox err.Description
End Sub