?
Solved

Automating AutoCAD SelectionSets...

Posted on 2009-04-08
12
Medium Priority
?
2,155 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 2
12 Comments
 
LVL 11

Accepted Solution

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

Assisted Solution

by:borgunit
borgunit earned 1000 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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
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

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month10 days, 8 hours left to enroll

765 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