Dynamic Block - LISP(vlax) editing

Discussion in 'AutoCAD' started by C Witt, Apr 8, 2005.

  1. C Witt

    C Witt Guest

    After a lot of help from Herman Mayfarth, I have come up with 2 lisp
    commands that should help everyone edit their Dynamic Blocks AFTER they
    are inserted in a drawing. (see attached file)

    The first lisp will list all the DB properties so you can determine what
    needs to be changed.

    The second lisp will search a selected block and change the setting you
    specify.

    I hope someone can make good use of them.
    C Witt

    (BTW, i'm x posting this due to the lack of a true dynamic block NG)

    ; testing code, to see what variables there are in your block
    (defun c:tdb ()
    (setq obj (vlax-ename->vla-object (car (entsel))))
    (setq v (vla-getdynamicblockproperties obj))
    (setq vval (vlax-variant-value v))
    (setq sal (vlax-safearray->list vval))
    (setq salnth (length sal))
    (setq count 0)
    (while (/= count salnth)
    (vlax-dump-object (nth count sal))
    (setq count (+ count 1))
    )
    (setq count nil)
    (princ)
    )
    ;
    ; alteration code, to change a given variable in your block
    (defun c:sdb (/ esb v vval sal salnth count)
    (vl-load-com)
    (setq esb nil)
    (while (= esb nil)
    (setq esb (entsel))
    (if (/= (vlax-get-property (vlax-ename->vla-object (car esb)) "effectivename") "YOUR BLOCK NAME HERE")
    (setq esb nil)
    )
    )
    (setq obj (vlax-ename->vla-object (car esb)))
    (setq v (vla-getdynamicblockproperties obj))
    (setq vval (vlax-variant-value v))
    (setq sal (vlax-safearray->list vval))
    (setq salnth (length sal))
    (setq count 0)
    (while (< count salnth)
    (if (= (vlax-get-property (nth count sal) "PropertyName") "YOUR VARIABLE NAME HERE")
    (progn
    (vlax-put-property (nth count sal) "Value" "YOUR SETTING HERE")(princ)
    (setq count salnth)
    )
    (setq count (+ count 1))
    )
    )
    (princ)
    )
     
    C Witt, Apr 8, 2005
    #1
    1. Advertisements

  2. C Witt

    michael

    Joined:
    Feb 26, 2015
    Messages:
    1
    Likes Received:
    0
    So I downloaded your lisp loaded it...and the SDB's working up to the point of picking the obj. When I select a dynamic block...it prompts me to me an obj. Any ideas of why this could be occurring. I also get this error when I use the tdb.



    Command: TDB
    Select object: ; error: ActiveX Server returned an error: Invalid index
    Command:
    Command: Specify opposite corner or [Fence/WPolygon/CPolygon]:
    Command: SDB
    Select object:
    Select object:
    Select object:
    Select object:
    Select object:
    ; error: bad argument type: lentityp nil
    Command:
     
    michael, Feb 26, 2015
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.