Most of these routine lisp credit goes to BeeKeeCZ for very useful helps.
Here is my new challenge: I want to insert my blocks into a drawing by using dynamic input. The abc.lsp makes dynamic input entries and the challenge starts here.
1) How can I direct this selection to read from abcFn.lsp and insert appropriate block (by selecting "A" ==> insert block "a" or run "Ma" function, etc.)
2) How can keep dynamic input running until I press Esc. It means after inserting block "a" it doesn't stop and show me dynamic input selection again and it continues until I terminate it.
What I meant was for example if I select "A" to insert my first block, it goes through whole my dynamic block insertion prompts to the end but it starts over again. How can I stop looping it and force it to back to first selection tree after the last prompt (Orientation for selection "A").
(vl-load-com)
(defun c:DDS ( / key input)
(setq input "A"
key "A B C") ; This calls functions c:MA, c:MB, c:MB
(while (progn
(initget key)
(setq input (cond ((getkword (strcat "\nSelect segment [" (vl-string-translate " " "/" key) "] <" input ">: ")))
(input))))
(apply (read (strcat "c:m" input)) nil))
(princ)
)
(defun c:ma nil (princ "\nHello s_plant, I'm 'c:MA' and I'm working pretty well!") (princ))
(defun c:mb nil (princ "\nHello s_plant, I'm 'c:MB' and I'm working pretty well!") (princ))
(defun c:mc nil (princ "\nHello s_plant, I'm 'c:MC' and I'm working pretty well!") (princ))
Then... the problem is inside of DRXA function (and the same in DRXB and C), that you are using att, oCLAYER, oATTREQ and oATTDIA variables (localized), but you set no value in these! Then, when you use these variable it goes into error and does not come back into DDS for next prompt. I tried to fix it.
And, since your M_a block has no attributes you can't have "aA" as a parameter!
First routine working fine, no hassle but second one still is going through a loop on my first selection and after 3 time of asking DB parameters it stops working!
First routine working fine, no hassle but second one still is going through a loop on my first selection and after 3 time of asking DB parameters it stops working!
Hi, glad that at least something works.
Underneath, you can find simplified code for c:DDS, c:MA.,c:MB and c:MC. That should work as it is without causing an error (at least works for me).
BUT, as you can see, there is no reactor in it. And that's the problem I cannot solve - because if I load the reactor, then I run MA, it goes fine just ones. If I run MA second time, then it shows "Unknown command "MA". With normal command such as "-insert", run from Autocad directly, the reactor works fine. But if "-insert" command is run from lisp, it is not terminated correctly. The reactor has to be modified somehow - and I am not a good guy for it.
So... you you need to aks the author of the reactor, or maybe someone else here could help with this one (make a new thread up on this topic).
Ok, not sure about this one. Do you need the reactor for some other stuff? Is your reactor loaded all the time? I recommend don't - then you can use following modification, which works as you want. I modified this reactor routine to lose its reactivity... but if you run the original reactor from some other place then it would be in conflict with each other.
In case you use the original reactor for other stuff you can - erase "-insert" command from list of command to react on (still reacts on (no dash) insert command - use it as regular routine and run it manually just after insert command (it takes last inserted block).
I appreciate any idea of how to put UNDO for the reactor. Where do I need to put start and End of my Undo?
For instance when adding pipe length for the first block M_a and then want to Undo input length to change with different length
Thanks
This is not that simple. You can't call undo command in the middle of another command. You need to adjust your routine (which - since my last adjustment - is not the reactor anymore).
So try this version... anywhere you can type "U" for "Undo" for go 1 step back. If you do this inside your main function then you'll erase last segment drawn. btw The main function can be terminated by typing "+" as well.
As you said it is not that much simple. It works fine with Undo last inserted segment but not within each insertion process by typing "U". I simply added "Undo" option into dynamic input selection to do the last inserted deletion but cannot run Undo for any of my input data because for example after asking Length of pipe, lisp is looking for numeric input not alphabetic(U)
.... I simply added "Undo" option into dynamic input selection to do the last inserted deletion but cannot run Undo for any of my input data because for example after asking Length of pipe, lisp is looking for numeric input not alphabetic(U)
You can do that. And I made this for you. It is defined as a keyword within (initget "Undo") function.
With only exception you can type "U" anywhere you want. The only exception is when you are prompted to place a block - this is autocad's native command which I can't change. But autocad let you know if you try type anything unexpected.
In main function now you can see "Undo" and "Quit" items on a flyout. When you select a dynamic property then "Undo" is not shown, but it is accepted - type it on a keyboard. This works good for me.