Announcements
Notice: Upload of PDF documents is currently unavailable across the Community due to an ongoing issue.

Select one regular block in only one layout

Select one regular block in only one layout

Gorra
Advocate Advocate
994 Views
11 Replies
Message 1 of 12

Select one regular block in only one layout

Gorra
Advocate
Advocate

I feel absurd asking, but I can't seem to get this. I need to select one basic block in a layout as part of a LISP. There is one instance of the block in each layout. I've tried many variations of 

 

(if (setq ss (ssget "_X" '((0 . "INSERT") (2 . "Title Block - To Sheet # anno") (66 . 1))))

  (repeat (1+ (sslength ss))
(setq AdjBlk (ssname ss 0))
  )
)

 

or the simpler

 

(setq insert_sset (ssget "_X" '((0 . "INSERT") (66 . 1) (2 . "Title Block - To Sheet # anno")))) 
(setq AdjBlk insert_sset)

 

or the more complicated

 

(if (setq insert_sset (ssget "_X" (list (cons 410 LytLbl) '(0 . "INSERT")))) 
    (vl-remove-if '(lambda (insert) (/= (strcase "Title Block - To Sheet # anno") (strcase (vla-get-effectivename insert))))
(mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex insert_sset))))
    )
)

 

 

but all I get is a nil value for AdjBlk
If anyone could point out what's probably obvious, I'd appreciate it.
 
Thanks,
Gorra
 
Edited to add:
I think I've figured out the problem, the selection is making a selection set, and I've been trying to work with it using list commands.
 
0 Likes
Accepted solutions (1)
995 Views
11 Replies
Replies (11)
Message 2 of 12

paullimapa
Mentor
Mentor
Accepted solution

The # symbol in the block name is throwing lisp off...try this:

(setq insert_sset (ssget "_X" '((0 . "INSERT") (66 . 1) (2 . "Title Block - To Sheet `# anno")))))

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 12

Sea-Haven
Mentor
Mentor

You can also add "look in current layout" by using (cons 410  (getvar 'ctab)) in conjunction with other ssget filters.

0 Likes
Message 4 of 12

komondormrex
Mentor
Mentor

@Gorra 

check it vlaxed, 

(setq target_block nil)
(vlax-map-collection (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
    '(lambda (object) (if (and (= "AcDbBlockReference" (vla-get-objectname object)) 
                 (= "Title Block - To Sheet # anno" (vla-get-effectivename object))
              )
              (setq target_block object)
            )
   )
)
(print target_block)

 

0 Likes
Message 5 of 12

Gorra
Advocate
Advocate

That was indeed part of the problem, thanks

0 Likes
Message 6 of 12

paullimapa
Mentor
Mentor

you are welcome...cheers!!!


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 7 of 12

Gorra
Advocate
Advocate

Oh that's what the 410 is for. Thanks

0 Likes
Message 8 of 12

Gorra
Advocate
Advocate

Thanks for the method, just need to review it when I have more brain than none

Message 9 of 12

paullimapa
Mentor
Mentor

@komondormrex 

FYI: there is a typo with this:

(vlax-map-collectiom

but should be:

(vlax-map-collection

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 10 of 12

komondormrex
Mentor
Mentor

corrected

0 Likes
Message 11 of 12

komondormrex
Mentor
Mentor

@paullimapa 

no need to strcat parts of the block name, "Title Block - To Sheet `# anno" will nicely do.

Message 12 of 12

paullimapa
Mentor
Mentor

thanks for the feedback. I've revised msg #2


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes