Change Block Properties Table option with autolisp

Change Block Properties Table option with autolisp

mark.jollyR7W78
Participant Participant
280 Views
2 Replies
Message 1 of 3

Change Block Properties Table option with autolisp

mark.jollyR7W78
Participant
Participant

We have a dynamic block that uses a block properties table to change the position of the block in predefined locations (i.e. Top Left, Top Right, etc)

Image below shows the table (header "Location") and how it appears in the properties table.

 

markjollyR7W78_0-1741339165213.png

 

We're want to quick change locations of multiple blocks at once, rather than having to change individual blocks.

You can't highlight multiple blocks and alter in the properties tables. Something you can do with visibility settings but have gone the BPT routine due to regen time issues when using visibility settings. 

 

We started with a crude lisp routine to try proof of concept but quickly hit a problem. We can change the  'Location' value to 'Top Left' in a selected block but the position doesn't alter to suit the change. [image below still positioning the block at Top Right despite the 'Location' value appearing as 'Top Left']

 

markjollyR7W78_1-1741339688701.png

crude lisp routine used -

;------

(defun c:Fpos ()
  (vl-load-com)
 
  (setq ent (car (entsel "\Select Block: ")))
 
  (setpropertyvalue ent "AcDbDynBlockPropertyLocation" "Top Left")
 
)

;------------

Can you please provide assistance? Not sure if there's a function required to refresh / regen the block whilst running the autolisp routine.

 

Thanks in advance

 

Mark

0 Likes
281 Views
2 Replies
Replies (2)
Message 2 of 3

Sea-Haven
Mentor
Mentor

Ok the real answer is from the great code by Lee-mac Dynamic block, do a google. 

 

I have a read a dynamic block visibility and show the choices in a dcl so choose, its a global function so could be used as a front end to a selection of blocks.

 

; Change dynamic block properties when inserting look at properties available.
; By Alan H June 2022

;; Get Dynamic Block Property Allowed Values  -  Lee Mac
;; Returns the allowed values for a specific Dynamic Block property.
;; Set Dynamic Block Visibility State  -  Lee Mac
;; Sets the Visibility Parameter of a Dynamic Block (if present) to a specific value (if allowed)
;; Get Visibility Parameter Name  -  Lee Mac
;; Returns the name of the Visibility Parameter of a Dynamic Block (if present)

(defun insdynv (blkname / pt obj lst ans)
(if (not LM:setdynpropvalue )(load "Lee-mac Dynamic block get-put"))
(setq pt (getpoint "\nPick a pt for block "))
(command "-insert" blkname "s" 1.0  pt 0)
(setq obj (vlax-ename->vla-object (entlast)))
(setq visval (LM:getvisibilityparametername obj))
(setq lst (LM:getdynpropallowedvalues obj visval))
(setq lst (cons "Please choose" lst))
(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(if (not AHbut)(setq AHbut 1))
(setq ans (ah:butts 1 "v"  lst))
(LM:SetVisibilityState obj ans)
(princ)
)

; set existing block visibilty

(defun insdyne (blkname / pt obj lst ans)
(if (not LM:setdynpropvalue )(load "Lee-mac Dynamic block get-put"))
(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(setq obj (vlax-ename->vla-object (car (entsel "\nPick a dynamic block "))))
(setq visval (LM:getvisibilityparametername obj))
(setq lst (LM:getdynpropallowedvalues obj visval))
(setq lst (cons "Please choose" lst))
(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(if (not AHbut)(setq AHbut 1))
(setq ans (ah:butts 1 "v"  lst))
;(LM:SetVisibilityState obj ans)
(princ)
)

 

Note the commented line in insdyne use that in a loop for your blocks you will need to select a block check its effective name and make a list then of entities that have that "Effectivename" , you can not search directly for an effectivename using ssget.

0 Likes
Message 3 of 3

mark.jollyR7W78
Participant
Participant

Many thanks for your reply. I'll look into your suggestion, and Lee Mac's site as soon as I get a chance.

Shall report back and let you know how I got on.

0 Likes