Author Topic: Remove "select block" prompt to automatically choose a block name  (Read 2496 times)

0 Members and 1 Guest are viewing this topic.

kameron1967

  • Guest
Hi guys,

I'm looking to replace the selection option to it automatically selecting "BlockA".  How would you change this, please.
Code: [Select]

(setq ss (nth 3
  (vlax-invoke
    (vlax-ename->vla-object (car (entsel "\nSelect Block: ")))
    'GetAttributes)))
 

Lee Mac

  • Seagull
  • Posts: 12921
  • London, England
Re: Remove "select block" prompt to automatically choose a block name
« Reply #1 on: March 14, 2011, 01:41:04 PM »
Look into using ssget using the "_X" mode to search the drawing database with an appropriate filter list to filter for objects you wish to collect.

You should filter for Inserts (DXF 0) with the desired block name (DXF 2), and perhaps only those with Attributes (DXF 66 = 1) then use ssname to acquire the entity name of an entity in the SelectionSet and convert it to a VLA-Object using vlax-ename->vla-object as demonstrated in the code you have written.

Start by looking up and reading about the ssget function in the VLIDE Help Documentation <-- Not sure how to do this? See here.

Lee

kameron1967

  • Guest
Re: Remove "select block" prompt to automatically choose a block name
« Reply #2 on: March 14, 2011, 03:03:18 PM »
Lee,

I understand that this code here obtains the information about BLOCKA.  However, I still am unclear how I could use that information so that the routine reads it, rather than prompt me to select it.  I'm not familiar with this "vlax-name...entsel", I wonder how I could use the ss so that the code reads the ss instead of the entsel, which requires me to select BLOCKA.  It's not possible to type SS in place of the (entsel "\Select Block:" line?  Thanks.

Code: [Select]
(setq ss (ssget "_X" '((0 . "INSERT") (66 . 1) (2 . "BLOCKA"))))

 (setq ss (nth 3
 (vlax-invoke
   (vlax-ename->vla-object (car (entsel "\nSelect Block: ")))
   'GetAttributes)))

Lee
« Last Edit: March 17, 2011, 08:44:53 AM by CAB »

Lee Mac

  • Seagull
  • Posts: 12921
  • London, England
Re: Remove "select block" prompt to automatically choose a block name
« Reply #3 on: March 14, 2011, 03:04:41 PM »
...then use ssname to acquire the entity name of an entity in the SelectionSet and convert it to a VLA-Object using vlax-ename->vla-object as demonstrated in the code you have written.

Have you studied the ssname function?

kameron1967

  • Guest
Re: Remove "select block" prompt to automatically choose a block name
« Reply #4 on: March 14, 2011, 03:23:01 PM »
Lee, the group code 2 that can be called in the ssget function says this:

2  Name (attribute tag, block name, and so on)

Can I specify the tag name instead of the block name?
(setq ss (ssget "_X" '((0 . "INSERT") (66 . 1) (2 . "R2NO"))))

I'm still lost how you could use that information in place of the code that prompts me to choose BLOCKA.  Sorry. :)

Lee Mac

  • Seagull
  • Posts: 12921
  • London, England
Re: Remove "select block" prompt to automatically choose a block name
« Reply #5 on: March 14, 2011, 03:41:57 PM »
Can I specify the tag name instead of the block name?
(setq ss (ssget "_X" '((0 . "INSERT") (66 . 1) (2 . "R2NO"))))

No, with ssget you can only filter for primary entities.

I'm still lost how you could use that information in place of the code that prompts me to choose BLOCKA.  Sorry. :)

You didn't answer my question:

...then use ssname to acquire the entity name of an entity in the SelectionSet and convert it to a VLA-Object using vlax-ename->vla-object as demonstrated in the code you have written.

Have you studied the ssname function?


kameron1967

  • Guest
Re: Remove "select block" prompt to automatically choose a block name
« Reply #6 on: March 14, 2011, 04:51:10 PM »
Yes, I read about ssget function, the filter list and the selection set manipulation, along with the rational test one can perform on the selection set.

It's interesting read.  

Sorry - I didn't see the ssname portion.  Yes, that is great information.  I could definitely use that.  I'll need to spend an afternoon reading it, as it's pretty thorough.  Thanks for pointing that out to me, Lee. :)

pBe

  • Bull Frog
  • Posts: 402
Re: Remove "select block" prompt to automatically choose a block name
« Reply #7 on: March 15, 2011, 05:56:48 AM »
Kameron
I've posted that snippet for you to understand what i meant by "position", granting you already have a selection set, as your question before pertains to TAG name search.
You could easily retrieve the Tag and Value with this using single selection

Code: [Select]
(vla-get-tagstring (vlax-ename->vla-object (car (nentsel))))
Hope this is clear

 :-)

AND
you posted this same question in 3 different forum.
it will only make your head spin and confuse you more





« Last Edit: March 15, 2011, 06:07:46 AM by pBe »

kameron1967

  • Guest
Re: Remove "select block" prompt to automatically choose a block name
« Reply #8 on: March 15, 2011, 09:58:40 AM »
Thanks, pbe!  It's amazing how many variations people come up with the solution.  Yes, it does spin my head around.  But it gives me insight into this programming madness.  I've actually come to understand a lot since I starting posting in the forums.  Lee pointed out something that I never knew existed - the ssname function.  I will definitely read into it, as soon as I get a chance.  Thanks again!