- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to select a specific dynamic block in Layout space and change its visibility state using LISP. Something that I'm doing isn't working because it just states the block is not in layout space, however it clearly is. Basically I need to be able to print the cover sheet for plans twice, once with the standard energy code selections, and a second time with solar energy credit selections.
Block name: WSEC ENERGY SELECTIONS - 2021 - MV4
Visibility Parameter name: ENERGY CREDITS
Visibility State (to change to): SOLAR INSTALLATION
By default the visibility state is typically set to MV4, I want to switch this to SOLAR INSTALLATION so I can print the sheet, then I'll add code to switch it back after printing later.
Code sample:
(defun c:c2solar ( / blkname visstate ss i ent obj props propname )
(vl-load-com)
(setq blkname "WSEC ENERGY SELECTIONS - 2021 - MV4")
(setq visstate "SOLAR INSTALLATION")
;; Select all inserts of the block in paper space (layout space)
(setq ss (ssget "_X"
(list
'(0 . "INSERT")
(cons 2 blkname)
(cons 410 "A0.0 Right - Cover")
)
)
)
(if ss
(progn
(setq i 0)
(while (< i (sslength ss))
(setq ent (ssname ss i))
(setq obj (vlax-ename->vla-object ent))
;; Get dynamic block properties
(if (vlax-property-available-p obj 'EffectiveName)
(progn
(setq props (vlax-invoke obj 'GetDynamicBlockProperties))
(foreach prop props
(setq propname (strcase (vla-get-PropertyName prop)))
(if (wcmatch propname "ENERGY CREDITS")
(vla-put-Value prop visstate)
)
)
)
)
(setq i (1+ i))
)
(princ (strcat "\nAll matching blocks updated to visibility: " visstate))
)
(princ "\nBlock not found in layout space.")
)
(princ)
)
Any assistance to get this functioning would be much appreciated.
Solved! Go to Solution.