Author Topic: Modify Dynamic Block parameters  (Read 5080 times)

0 Members and 1 Guest are viewing this topic.

VELI555

  • Guest
Modify Dynamic Block parameters
« on: January 16, 2013, 05:39:15 AM »
Hi everybody

I have problem with a dynamic block. I would like to change a dynamic block parameters using LISP code. In the block there are two parameters and when I change those parameters I stretch some parts in that dynamic block. And now I would like change thouse parameters using LISP code. Is this possible trough LISP? I would be very grateful about your help.

Best regards
Veli from Finland

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Modify Dynamic Block parameters
« Reply #1 on: January 16, 2013, 05:58:21 AM »
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Modify Dynamic Block parameters
« Reply #2 on: January 16, 2013, 06:06:29 AM »
for test:
Code - Auto/Visual Lisp: [Select]
  1. (defun test-put-value (o l)
  2.   (setq l '(("X" . 500.) ("Y" . 800.))
  3.         o (vlax-ename->vla-object (car (entsel "\n select dynamic block")))
  4.   )
  5.   (foreach a (vlax-safearray->list (vlax-variant-value (vla-GetDynamicBlockProperties o)))
  6.     (if (setq e (assoc (vla-get-PropertyName a) l))
  7.       (vla-put-value a (vlax-make-variant (cdr e) 5))
  8.     )
  9.   )
  10. )

VELI555

  • Guest
Re: Modify Dynamic Block parameters
« Reply #3 on: January 16, 2013, 07:19:33 AM »
Hi

Thanks for the quick replay, I really appreciate your help. I am not familiar whith LISP and I am not quite sure that where I have to put the LISP code. Can I just wrote it on the command column?

Thanks for your help

Best regards
Veli from Finland

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Modify Dynamic Block parameters
« Reply #4 on: January 16, 2013, 07:39:15 AM »
If you mean Elpanov's code, then change the 1st line to:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:TestPutValue (/ o l)
Then you can save it into a text file with a LSP extension and have acad load it. Thereafter you have a "normal" command called TestPutValue.

Note the 2nd line in that code is saving a list of DB-Param names with their values. You might need to change them to accommodate your needs.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

VELI555

  • Guest
Re: Modify Dynamic Block parameters
« Reply #5 on: January 16, 2013, 08:14:04 AM »
Thank you irneb for your advices.

There must be something that I still do wrong. I have changed the first line, and done the acad load instructions from Lee MAC website. But when I try to use the command TestPutValue but I get error message Unknown command "TESTPUTVALUE". I also tried to type the name of the LISP file. Didint work. What I finally  try to do is to get this kind of LISP code inside of a script file so that when I use the scrpit file it would also do the LISP routine. We have managed to do that kind of thing where a script contained a LISP code which turned snap on then a script inserted some blocks and after that LISP put snap back on. I have understood that there are LISP code that can be wrote to the command column so it could be used like script. I hope you understood what I wrote.

Thank you

Best regards
Veli From Finland

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Modify Dynamic Block parameters
« Reply #6 on: January 17, 2013, 01:25:25 AM »
You can copy-paste it into the command line yes or add it into a SCR file if you wish. That should work fine. Many ways to skin a cat  :lmao:

BTW, is there an error message when you tried to load the LSP file? Note the 1. 2. 3. line numbers in the code listing should not form part of the file - internet Explorer has an issue with including these when you copy-paste, not so in FireFox/Chrome.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.