Author Topic: Create Dynamic Block With Autolisp/Vlisp  (Read 3161 times)

0 Members and 1 Guest are viewing this topic.

Ben Clark

  • Newt
  • Posts: 94
Create Dynamic Block With Autolisp/Vlisp
« on: March 15, 2017, 04:19:23 PM »
Can a dynamic block be created and given dynamic parameters using autolisp/vlisp? I've been searching for a while and have not found a way to achieve this. I already have a way to select the objects I want in the block, just can't figure out how to usie lisp to make the dynamic block.

I've tried using (command "_-bedit" "blockname"), but it forces you to the edito, when I really want to add parameters using lisp only.
« Last Edit: March 15, 2017, 04:35:42 PM by barnjart42 »

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Create Dynamic Block With Autolisp/Vlisp
« Reply #1 on: March 15, 2017, 06:33:22 PM »
Can a dynamic block be created and given dynamic parameters using autolisp/vlisp?

No - this functionality was never officially exposed to the LISP API.

It may be possible to reverse engineer a dynamic block by entmake'ing all of the appropriate dictionary entries, but I would strongly advise against this as the stability of the resulting block could be questionable given that there may be data necessary for the dynamic block to operate but which is inaccessible to LISP.

Ben Clark

  • Newt
  • Posts: 94
Re: Create Dynamic Block With Autolisp/Vlisp
« Reply #2 on: March 16, 2017, 09:56:35 AM »
Lee, thanks so much for the reply. Very helpful. Kind of a disappointing that it's not possible, but I feel slightly privileged that Lee Mac himself answered my question.

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: Create Dynamic Block With Autolisp/Vlisp
« Reply #3 on: March 16, 2017, 12:48:10 PM »
Here are the threads I've created, regarding this issue (you may find something useful) :
https://www.theswamp.org/index.php?topic=52256.msg572297#msg572297
https://www.theswamp.org/index.php?topic=52463.msg573944#msg573944

Like Lee said, you could try entmaking the parameters - which means digging into the dictionaries.

In VLISP I did not found any method to create a dynamic parameter, but you could easily access them (if they are created already) with:
Code: [Select]
(vlax-invoke objblk 'GetDynamicBlockProperties)
On the other side, using vanilla (to acess the parameters) - quoting Lee:
Hint: here's your entry point:
Code - Auto/Visual Lisp: [Select]
  1. (dictsearch (cdr (assoc 360 (entget (cdr (assoc 330 (entget (tblobjname "block" "YourDynamicBlock"))))))) "acad_enhancedblock")
So the conclusion is: that its impossible to create them using visual lisp (atleast I think so).
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg