Solved

Automating AutoCAD SelectionSets...

Posted on 2009-04-08
12
2,106 Views
Last Modified: 2013-12-04
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

0
Comment
Question by:LittleOleMeDesigns
  • 6
  • 4
  • 2
12 Comments
 
LVL 11

Accepted Solution

by:
darrenmcwi earned 250 total points
ID: 24096663
FilterType(1) = 0
FilterData(1) = "INSERT"
0
 
LVL 10

Assisted Solution

by:borgunit
borgunit earned 250 total points
ID: 24096830
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
 
LVL 10

Expert Comment

by:borgunit
ID: 24096842
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 4

Author Comment

by:LittleOleMeDesigns
ID: 24097612
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
 
LVL 4

Author Comment

by:LittleOleMeDesigns
ID: 24097662
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
 
LVL 10

Expert Comment

by:borgunit
ID: 24097749
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
 
LVL 4

Author Comment

by:LittleOleMeDesigns
ID: 24097828
Nope... same result.

I'm using Visual Studio 2005 and AutoCAD 2002 if that makes a difference as well.
0
 
LVL 4

Author Comment

by:LittleOleMeDesigns
ID: 24097895
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
 
LVL 10

Expert Comment

by:borgunit
ID: 24097946
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
 
LVL 4

Author Comment

by:LittleOleMeDesigns
ID: 24097996
@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
 
LVL 11

Expert Comment

by:darrenmcwi
ID: 24099987
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
 
LVL 4

Author Closing Comment

by:LittleOleMeDesigns
ID: 31568210
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

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Send SMS from VB via Sierra Wireless Modem 2 23
Export PDF Form fields to Access  or Excel  in Tab order 16 81
SSIS Start 2 21
MYSQL responding very slow 3 26
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question