Author Topic: Manipulate dynamic blocks by code  (Read 1288 times)

0 Members and 1 Guest are viewing this topic.

FOUAD ABOU RJEILY

  • Guest
Manipulate dynamic blocks by code
« on: May 23, 2013, 03:56:18 AM »
I am trying to insert a Dynamic block and manipulate its parameters programmaticaly:  'width', 'length', etc...
The block has linear parameters and stretch actions.  After inserting the block, how can I, by using lisp, update the specific parameters value to get it properly displayed
Your support is really appreciated. Thanks

Lee Mac

  • Seagull
  • Posts: 12928
  • London, England
Re: Manipulate dynamic blocks by code
« Reply #1 on: May 23, 2013, 06:16:25 AM »
You might find these functions helpful: Dynamic Block Functions

Crank

  • Water Moccasin
  • Posts: 1503
Re: Manipulate dynamic blocks by code
« Reply #2 on: May 25, 2013, 08:38:59 PM »
Code: [Select]
(defun PushDBProps (objent lst / blkprops propname propvalue n )
;; (PushDBProps ename|object '(("Visibility" . "No Shelves")("Width" . 36.0)...))
;; objent: ename or object of dynamicblock
;; lst: list of dotted pairs '((propname1 . newvalue1)(propname2 . newvalue2)...)
(if (= 'ENAME (type objent))(setq objent (vlax-ename->vla-object objent)))
(setq blkprops
(vlax-safearray->list
(vlax-variant-value (vla-getdynamicblockproperties objent))
)
)
(foreach prop lst
(setq n 0)
(setq propname (car prop))
(setq propvalue (cdr prop))
(while (< n (length blkprops))
(if (= propname (vlax-get-property (nth n blkprops) "PropertyName"))
(progn
(vlax-put-property (nth n blkprops) "Value" propvalue)
(setq n (length blkprops))
)
(setq n (1+ n))
)
)
)
)
Vault Professional 2023     +     AEC Collection

FOUAD ABOU RJEILY

  • Guest
Re: Manipulate dynamic blocks by code
« Reply #3 on: May 28, 2013, 10:03:02 AM »
Thanks a lot.