Author Topic: VLA only select blocks in current space  (Read 2783 times)

0 Members and 2 Guests are viewing this topic.

ChrisCarlson

  • Guest
VLA only select blocks in current space
« on: November 13, 2014, 08:25:36 AM »
http://www.lee-mac.com/selsetprocessing.html

Code - Auto/Visual Lisp: [Select]

Will select all blocks in model space / paper space. My google-fu is not up to par this morning in finding the vla methods to only select blocks in the current space eg; model space, paper space, within a viewport.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: VLA only select blocks in current space
« Reply #1 on: November 13, 2014, 08:41:25 AM »
I use the following ssget filter:
Code: [Select]
(ssget "_X" (if (= 1 (getvar 'cvport)) (list (cons 410 (getvar 'ctab))) '((410 . "Model"))))
If you necessary require a VLA method, the above filter would need to be converted to an appropriate safearray variant and supplied to the vla-select function, along with the acselectionsetall enum.

ChrisCarlson

  • Guest
Re: VLA only select blocks in current space
« Reply #2 on: November 13, 2014, 09:14:36 AM »
So selecting block variable A, only in the current space would go something like this?

(ssget "_X" (if (= 1 (getvar 'cvport))(list (cons 410 (getvar 'ctab))(cons 0 "INSERT")(cons 2 A)) '((410 . "Model")(cons 0 "INSERT")(cons 2 A))))

Makes sense to me, CVPORT returns 1 or 2 based on model space or paper space. If it returns 1 the selection set filters based on 410 to the layout name and if it returns 2 the line filters based on 410 being named Model?

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: VLA only select blocks in current space
« Reply #3 on: November 13, 2014, 09:26:16 AM »
So selecting block variable A, only in the current space would go something like this?

(ssget "_X" (if (= 1 (getvar 'cvport))(list (cons 410 (getvar 'ctab))(cons 0 "INSERT")(cons 2 A)) '((410 . "Model")(cons 0 "INSERT")(cons 2 A))))

Correct, though the code could be condensed to:
Code: [Select]
(ssget "_X" (list '(0 . "INSERT") (cons 2 a) (if (= 1 (getvar 'cvport)) (cons 410 (getvar 'ctab)) '(410 . "Model"))))
to avoid repeating the list items.

Just be aware that anonymous block references will need to be included if the block whose name is assigned to variable 'a' is dynamic.

Makes sense to me, CVPORT returns 1 or 2 based on model space or paper space. If it returns 1 the selection set filters based on 410 to the layout name and if it returns 2 the line filters based on 410 being named Model?

Correct - the CVPORT system variable returns the ID of the active viewport - this is always 1 for the paperspace viewport.