User Selection; Block(s) Only

User Selection; Block(s) Only

Anonymous
Not applicable
474 Views
12 Replies
Message 1 of 13

User Selection; Block(s) Only

Anonymous
Not applicable
I am attempting to allow the user to select an object on the screen,
however I would like to filter it so they can only select blocks (and if
at all possible, only a specific type of block). The premise behind this
is that we are allowing the user to place data points along a part with
offset/orientation data (with respect to another block object which
defines the frame). Any ideas? I currently am attempting to use the
SelectOnScreen() method by specifying a FilterType of 0 and a
FilterData of the name of the block object - this is not working. Ok,
thanks in advance.

P.S. I am new to AutoCad - have been using it a week now. So
take it easy on me. 😛

Jonathan Houser
Software Engineer
Robotic Workspace Technologies, Inc.
0 Likes
475 Views
12 Replies
Replies (12)
Message 2 of 13

Anonymous
Not applicable
You need two elements in your filter:

Dim FilterType(1) As Integer
Dim FilterData(1) As Variant

FilterType(0) = 0
FilterData(0) = "INSERT"

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

The value 2 is the DXF code for the block name

"Jonathan Houser" wrote in message
news:040577FE681CA8D2921F1FAECF807DF9@in.WebX.maYIadrTaRb...
> I am attempting to allow the user to select an object on the screen,
> however I would like to filter it so they can only select blocks (and if
> at all possible, only a specific type of block). The premise behind this
> is that we are allowing the user to place data points along a part with
> offset/orientation data (with respect to another block object which
> defines the frame). Any ideas? I currently am attempting to use the
> SelectOnScreen() method by specifying a FilterType of 0 and a
> FilterData of the name of the block object - this is not working. Ok,
> thanks in advance.
>
> P.S. I am new to AutoCad - have been using it a week now. So
> take it easy on me. 😛
>
> Jonathan Houser
> Software Engineer
> Robotic Workspace Technologies, Inc.
>
>
0 Likes
Message 3 of 13

Anonymous
Not applicable
That worked perfectly. Thanks Tony. 🙂 Ok, now that the simplest case is
working, how would I a) go about limiting the number of selections to two
and b) place the items into (or just access them as) actual block objects
for
associated operations (namely for exploding, accessing custom attributes,
etc.)? Oh, also, is there a list of these FilterTypes? I looked up "group
codes" in the AutoCad Developer documentation and came up with a very
sparse table of them - which did not include 2 (now that I've gone back and
looked again). Thanks again for your help.

Jon

P.S. Is there some book you could suggest that would have been able to
answer all of the questions I've had so far? I am actually working in
Mechanical Desktop on a 3D part, but from what I can see, the AutoCad
VBA is better implemented and is for certain better documented. Can't
even find a VBA book *on* Mechanical Desktop.
0 Likes
Message 4 of 13

Anonymous
Not applicable
Jonathan,

Everything that has discussed thus far is well documented in the bestselling book on AutoCAD VBA which you can find out more about at the following

http://www.amazon.com/exec/obidos/ASIN/B00005YU70/qid%3D1012252798/sr%3D8-1/ref%3Dsr%5F8%5F7%5F1/104-5158830-2188764
0 Likes
Message 5 of 13

Anonymous
Not applicable
Thanks Joe. You wouldn't happen to be the author, would you? 🙂 (On a
more
serious note, is there anything new and exciting in AutoCad 2002 that would
be
missed by an AutoCad 2000 book?)
0 Likes
Message 6 of 13

Anonymous
Not applicable
"Jonathan Houser" wrote in message
news:EB542D2153C615B797499A4BC9183BB7@in.WebX.maYIadrTaRb...
>
> how would I a) go about limiting the number of selections to two

You can't limit the number of objects found by the call
to Select or SelectOnScreen. Perhaps your intention is
to only allow the user to select two blocks?

If so, doing that using a selection set object is not
going to work, and you should use the GetEntity() method
of AcadUtility, and manually verify whether the selected
object is one of the blocks.

If you need help with that, there are plenty of examples
that have been posted in these newsgroups that should help
you with using GetEntity. My suggestion would be to search
the newsgroup with Google using the keyword "GetEntity".

> place the items into (or just access them as) actual
> block objects for

After you get the entity using GetEntity, you just assign
it to a variable declared as AcadBlockReference, and if
there is no error then it's a block reference, and you can
invoke all of the method of the BlockReference object.

> Oh, also, is there a list of these FilterTypes? I looked up "group
> codes" in the AutoCad Developer documentation and came up with a very
> sparse table of them - which did not include 2 (now that I've gone
> back and looked again). Thanks again for your help.

The DXF documentation contains all of the group codes, and
the AutoCAD help file should list them by entity type. For
block reference, search the help index for "insert group codes".
0 Likes
Message 6 of 13

Anonymous
Not applicable
"Jonathan Houser" wrote in message
news:EB542D2153C615B797499A4BC9183BB7@in.WebX.maYIadrTaRb...
> I looked up "group
> codes" in the AutoCad Developer documentation and came up with a very
> sparse table of them - which did not include 2 (now that I've gone back
and
> looked again).

Try here:
http://www.autodesk.com/techpubs/autocad/acad2000/dxf/index.htm
0 Likes
Message 8 of 13

Anonymous
Not applicable
Not to rain on anyone's parade, but the fact of the
matter is that you can learn much more than what can
be contained in a dozen books, right here, by just
asking questions, and searching the newsgroup archives
using Goggle.


"Jonathan Houser" wrote in message
news:8C3FC814F9D4C8E775790C0461BC09AE@in.WebX.maYIadrTaRb...
> Thanks Joe. You wouldn't happen to be the author, would you? 🙂 (On a
> more
> serious note, is there anything new and exciting in AutoCad 2002 that
would
> be
> missed by an AutoCad 2000 book?)
>
>
0 Likes
Message 9 of 13

Anonymous
Not applicable
Tony, you're absolutely right. A good book does however serve as a foundation for further indulging. Many of the subjects that are discussed here are not in mine book [or anyone else's for that matter].

Jonathan, very little changed between 2000 and 2002 [most of which you could easily find in the AutoCAD help files].

Joe
--
0 Likes
Message 10 of 13

Anonymous
Not applicable
Tony: Yeah, had forgotten about the newsgroup search for Google. Thanks for
reminding me. 😛

Joe/Tony: I use books when I can as they are guaranteed to be there, just
not guaranteed to have the answer. After that I do web searches (which
haven't been really turning out well for my AutoCad VBA questions) and
finally I go for newsgroups. So as far as I am concerned - they are all
valuable. It just generally depends on the difficulty of the problem for
which you turn to. I have been writing code for many, many years now
(including Visual Basic and VBA), and thus would probably only really need a
quality AutoCad VBA book to show me the new objects and techniques. Thus
far I've been very depressed by the bundled documentation. I have 4 help
files possible that the answer could be in (since it could relate to AutoCad
or Mechanical Desktop, the user method - SendCommand() - or the VBA one).
So it'd be nice to have some central source for information, hence my asking
on a book.
0 Likes
Message 11 of 13

Anonymous
Not applicable
Thanks Adam, looks like a really good source of information on the DXF
format. 😛
0 Likes
Message 12 of 13

Anonymous
Not applicable
> You can't limit the number of objects found by the call
> to Select or SelectOnScreen. Perhaps your intention is
> to only allow the user to select two blocks?

Ok, will do so progmatically as you suggested. Yes,
my intention is to only select two blocks (for this case -
the number allowed may change for other macros I will
be writing).

> If so, doing that using a selection set object is not
> going to work, and you should use the GetEntity() method
> of AcadUtility, and manually verify whether the selected
> object is one of the blocks.

Yeah, looks a lot like the Pick() method I was using
at the very start, only with differing capabilities. Thanks
for pointing me to it - should do what I need.

> The DXF documentation contains all of the group codes, and
> the AutoCAD help file should list them by entity type. For
> block reference, search the help index for "insert group codes".

I did manage to find the full list after some more
looking. Once again it's minimal in its usefulness as it
tells you what the numbers stand for, but not in any way
how you should use them. Ah, I already complained
about the documentation in another post, will not do so
again. 😛
0 Likes
Message 13 of 13

Anonymous
Not applicable
"Jonathan Houser" wrote in message
news:496578FDD74AF8142F06B1C4174C9A8C@in.WebX.maYIadrTaRb...
> Tony: Yeah, had forgotten about the newsgroup search for Google. Thanks
for
> reminding me. 😛
>
> Joe/Tony: I use books when I can as they are guaranteed to be there, just
> not guaranteed to have the answer.

> After that I do web searches (which haven't been really turning
> out well for my AutoCad VBA questions).

General web searches aren't going to turn up much.

However, Google newsgroup searches almost always turn up
a wealth of information. The trick is to learn how to
search, and what to search for, and where to search for
it.

For example, here is the results of a search for GetEntity,
that was done from the Goggle 'Advanced Groups Search' page.

http://groups.google.com/groups?as_q=GetEntity&as_ugroup=*autodesk*&lr=&num=
100&hl=en
0 Likes