[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Automating AutoCAD SelectionSets...

Posted on 2009-04-08
12
Medium Priority
?
2,180 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 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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month19 days, 13 hours left to enroll

873 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