Automating AutoCAD SelectionSets...

I am trying to automate AutoCAD Selection Sets and I've got the code working to make the selection sets with a filter.. but it's returning a count of "0" for the items in the set when it should be returning a count of 1 for the drawing I'm working with.  Does anyone know why this code is having issues:
V_AutoCadInterfaceObject.Open(V_FilePathAutoCad)
 
            Dim V_StartBorderSelectionSet As AcadSelectionSet
 
            Try
                V_StartBorderSelectionSet = V_AutoCad.ActiveDocument.SelectionSets.Add("StartBorders")
            Catch ex As Exception
                V_StartBorderSelectionSet = V_AutoCad.ActiveDocument.SelectionSets.Item("StartBorders")
                V_StartBorderSelectionSet.Clear()
            End Try
 
            Dim FilterType(2) As Int16
            Dim FilterData(2) As Object
 
            FilterType(0) = 100
            FilterData(0) = "AcDbBlockReference"
 
            FilterType(1) = 0
            FilterData(1) = "START"
 
            Dim FilterTypeObject As Object
            Dim FilterDataObject As Object
 
            FilterTypeObject = FilterType
            FilterDataObject = FilterData
 
            V_StartBorderSelectionSet.Select(acSelectionSetAll, , , FilterTypeObject, FilterDataObject)
 
            MsgBox(V_StartBorderSelectionSet.Count)

Open in new window

LVL 4
LittleOleMeDesignsAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
darrenmcwiConnect With a Mentor Commented:
FilterType(1) = 0
FilterData(1) = "INSERT"
0
 
borgunitConnect With a Mentor Commented:
By the same token, the second filter would be:

FilterType(1) = 2
FilterData(1) = "START"

I am assuming a search for a block named START
0
 
borgunitCommented:
OOPs, correction

By the same token, the second filter would be:

FilterType(0) = 2
FilterData(0) = "START"

I am assuming a search for a block named START
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LittleOleMeDesignsAuthor Commented:
I've tried it with these set like this:

 FilterType(1) = 0
 FilterData(1) = "Insert"

 FilterType(0) = 0
 FilterData(0) = "START"

Like This:
 FilterType(0) = 0
 FilterData(0) = "Insert"

 FilterType(1) = 2
 FilterData(1) = "START"

And like this:
 FilterType(1) = 0
 FilterData(1) = "Insert"

 FilterType(0) = 2
 FilterData(0) = "START"

And same result on all of them... every time it tells me that there is a count of 0 and there is 1 START block in that drawing so it should be telling me 1
0
 
LittleOleMeDesignsAuthor Commented:
I am using this to open drawings without "opening" them... would this make a difference:

Dim V_AutoCadInterfaceObject As AxDbDocument
V_AutoCadInterfaceObject = V_AutoCad.GetInterfaceObject("ObjectDBX.AxDbDocument")
V_AutoCad = GetObject(, "AutoCad.Application.15")
0
 
borgunitCommented:
I use a snippet that just "grabs" the selection set by the block name as shown. Plug this into your code and see what happens.
Dim FilterType(0) As Int16
Dim FilterData(0) As Object
 
FilterType(0) = 2
FilterData(0) = "START"
 
Dim FilterTypeObject As Object
Dim FilterDataObject As Object
 
FilterTypeObject = FilterType
FilterDataObject = FilterData

Open in new window

0
 
LittleOleMeDesignsAuthor Commented:
Nope... same result.

I'm using Visual Studio 2005 and AutoCAD 2002 if that makes a difference as well.
0
 
LittleOleMeDesignsAuthor Commented:
I also should not that I can run this manually on that drawing it finds the one START block... so it's got to be something with the code

in AutoCAD command line and filter dialog box:
select
'filter
block name
START
add to list
apply

I've also just tried opening the file both in the background like I mentioned previously as well as opening it where the user can see it, and I still got the same result.

Man.. this is annoying... lol
0
 
borgunitCommented:
Miss-timed my reply. Yes, the selection set will not work on ObjectDBX. You will have to interate all objects in modelspace (lets say) until you get to a blockreference and then check its name.
0
 
LittleOleMeDesignsAuthor Commented:
@borgunit
Isn't the purposes of ObjectDBX to be able to read block attribute data without opening the drawing.. if you can't use selectionsets with it.. what would you use?

Also, as I mentioned previously,  I've tried it both using ObjectDBX as well as without it and I still get the same result.

Also, I just tried this without filtering at all and got the same result:
V_StartBorderSelectionSet.Select(acSelectionSetAll, , , , )
0
 
darrenmcwiCommented:
Borgunit is correct.

To anser your followup, SelectionSets are based on graphical coordinates as they relate to screen pixels. That's why you can't typically hatch an area that's not entirely within the drawing editor. That's why you can't perform a "window" or "crossing" selection set in a part of the drawing that's currently zoomed/panned outside the drawing editor.

Because ObjectDBX opens the drawing in memory without loading the graphical data, it has no basis for determining those sorts of things.  It doesn't use raw coordinates either as that would kill performance having to sift through the entire coordinate system for the purposes fo selection sets, which is why a screen pixel to drawing coordinat conversion in done behind the scenes.

Even thgough your selection isn't specifying a wondow or selection using coordinates, the Selection Set infastructure needs the graphical data loaded to be able to work which is why, unfortunately, you're left iterating through all the objects in the drawing.

On the plus side, because there's no graphics loaded into memory, iteration through the drawing database is very fast and efficient where it typically wouldn't be,
0
 
LittleOleMeDesignsAuthor Commented:
Ok.. I finally got this figured out thanks to your suggestions.. I'm still stuck on one part, but since it's no longer related to selectionsets, I started a new question for it located at:
http://www.experts-exchange.com/Software/Photos_Graphics/CAD_Architecture/AutoCAD/Q_24307097.html

Thank-You both for your help on this!
0
All Courses

From novice to tech pro — start learning today.