SelectObjects from Listview

SelectObjects from Listview

Sgear
Advocate Advocate
911 Views
2 Replies
Message 1 of 3

SelectObjects from Listview

Sgear
Advocate
Advocate

 

Hi

 

I am try to select object from Listview but I get = Value of Type cannot be convert to '1-dimensional array

 

 

 Autodesk.AutoCAD.Internal.Utils.SelectObjects(ListView.SelectedItems.Item(0).SubItems(1).Text)

Regards

Sgear

0 Likes
Accepted solutions (1)
912 Views
2 Replies
Replies (2)
Message 2 of 3

Keith.Brown
Advisor
Advisor
Accepted solution

What is in the list of your treeview?  Are you listing the objects Handles, ObjectId, or something else?  SelectObjects method takes an array of ObjectIds.  You are passing it a string which will not work.

 

You can use the Editor.SetImpliedSelection method to select your objects in a drawing.  The method takes an array of ObjectId's.

 

For instance the following code will clear out the pickfirst selection set.

 

editor.SetImpliedSelection(New ObjectId() {})

You can do the same thing with the method you are trying to use.

 

Autodesk.AutoCAD.Internal.Utils.SelectObject(New ObjectId() {})

So in summary,  you must get an array of ObjectId's and pass to the SelectObject method.

 

0 Likes
Message 3 of 3

Sgear
Advocate
Advocate

 

 

I add Object to listview include Object ID 

I am try to DoubleClick in listview to select Object I select in Listview

 

Thanks will check out Editor.SetImpliedSelection

 

 

 

 

           For Each colId In colIds

                Using trans As Transaction = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.TransactionManager.StartTransaction()

                    dbObj = trans.GetObject(colId, OpenMode.ForRead)
                    ObjectIDsave = colId.ToString()

                    If TypeOf (dbObj) Is BlockReference Then

                    Else
                        Dim l As Polyline = DirectCast(dbObj, Polyline)
                        stLength = stLength + l.Length.ToString
                    End If
                    trans.Commit()
                    trans.Dispose()
                End Using



            Next colId

' Add to listview !

 

0 Likes