View Full Version : Button to link two lisps
magic_man1
1st Apr 2005, 04:16 am
I don't know anything about lisps yet, but I am trying to create a button that will trigger a revision cloud command, then once the cloud is closed, I want it to trigger a pre-made lisp which inserts a block. Since I know nothing about coding lisp files, I was hoping to create a macro on the button that does this. Is this possible and can someone help me in writing it? I think I just need to know how the code to start the second portion of the macro (inserting the block). Here is how my cloud starts: ^C^Crevcloud then... I want to add a command called revtag then once that is finished, to go back to command line.
Help.
Thanks,
CarlB
1st Apr 2005, 09:30 am
In a macro, a space or a semicolon can be used for an enter. Assuming "revtag" starts that routine, macro would be:
^C^Crevcloud;revtag
magic_man1
1st Apr 2005, 04:15 pm
I probably should have mentioned that I think both revcloud and revtag are individual lisps that both return to a command line once finished. When I use ^C^Crevcloud;revtag for my button macro, my revcloud command works fine and the cloud is completed (returning to it's starting point - closing the cloud). But it does not instantly start the revtag portion of my macro. Again, I know nothing about lisps and I am assuming that this issue is due to both of these commands being separate lisps that have been created by others.
Is there another way of starting this revtag command? Just an FYI... I am using AutoCAD 2004.
Thanks again.
CarlB
2nd Apr 2005, 01:14 am
The only way that I can think of to run 2 lisps from a macro, that require user input, is to run a third lisp routine from the macro. The 3rd routine would run the 2 separate routines. The lisp to combine would be something like:
(defun c:run2 ()
(c:revcloud)
(c:revtag)
(princ)
)
Then your button macro would be(no semicolon after)
^C^Crun2
KES
2nd Apr 2005, 11:09 pm
Hi there have you tried the rev clouds from the design center?
http://www.ukdesignernetwork.com/Design%20center.JPG
they do what you are trying to achive. If you right click on one of the rev clouds with a tag select the edit you can see the command string they use. I tried using this in a button and it seemed to work as well.
Wozza
3rd May 2005, 08:13 am
Magic,
This might be tricky as, by your own admission, you know very little about lisp - but here goes anyway.
If you open up both of your lisp routines, you should see they start and finish something similar to this:
(defun C:xyz ()
........
........
(princ)
);defun
The first line defines the function and the letters after the C: represents the input required at the command line. So if you entered 'xyz' at the command line, the routine would run as written. The fourth line (princ) is just a feature that ends the function neatly. The fifth line ends the routine (the closing bracket pairs the very first one on line 1).
Lines 2 and 3 represent the code that actually runs the routine as written (obviously, there'll be more than 2 lines in both your routines).
Take the second routine, the one that inserts the block, and copy all the lines represented by lines 2 and 3 above. Then go to the first routine and paste them immediately before the line that has (princ).
Now save the new routine under a new name. Make sure you save it as a text file and that the file suffix is *.lsp. I'd also suggest changing the letters after the C: on the first line so that it's completely different to the original (say 'ABC').
Now, if you load this routine and hit ABC, then the first routine will run and before it finishes, it will run the second.
Now, lisp routines being what they are, the chances of getting a bracket or letter or anything at all in the wrong place is quite high, in which case the routine won't work. But give it a go and if it doesn't work, email me the routines and I'll patch them together for you.
royalchill
18th Apr 2007, 06:04 pm
See if this helps just edit to your layer, block etc. The only difference here is that you insert the delta first and then draw the cloud.
^C^Cattreq;0;^C-layer;make;G-ANNO-DLT1;color;yellow;;;ortho;on;-insert;rev1;\(getvar "dimscale");;;-layer;make;G-ANNO-REV1;color;yellow;;;_revcloud;endpoint
ASMI
18th Apr 2007, 07:54 pm
For example this code will react to command "REVCLOUD" and insert block named as "My_Tag" to point specified. Command RON - switch ON revcloud reaction, command ROFF- switch OFF revcloud reaction. 'revcloudReactionFun' is reaction function which insert block.
(defun c:ron()
(vl-load-com)
(if(not revr:Reac)
(progn
(setq revr:Reac
(vlr-command-reactor nil
'((:vlr-commandEnded . revcloudReactionFun))))
(princ "\n<<< REVCLOUD reaction now ON >>> ")
); end progn
); end if
(princ)
); end of c:revr
(defun c:roff()
(if revr:Reac
(progn
(vlr-remove revr:Reac)
(setq revr:Reac nil)
(princ "\n<<< REVCLOUD reaction now OFF >>> ")
); end progn
);end if
(princ)
); end of c:roff
(defun revcloudReactionFun(react args / actDoc spFlg actSp insPt)
(if(eq(car args) "REVCLOUD")
(progn
(setq actDoc
(vla-get-ActiveDocument
(vlax-get-acad-object))
spFlg(vla-get-ActiveSpace actDoc))
(if(eq 1 spFlg)
(setq actSp(vla-get-ModelSpace actDoc))
(setq actSp(vla-get-PaperSpace actDoc))
); end if
(if(tblsearch "BLOCK" "My_Tag")
(progn
(if
(setq insPt(getpoint "\n>>> Specify insertion point > "))
(vla-InsertBlock actSp (vlax-3d-point(trans insPt 1 0))
"My_Tag" 1.0 1.0 1.0 0.0)
); end if
); end progn
(princ "\n<<< Block 'My_Tag' not found >>>")
);end if
); end progn
); end if
(princ)
); end of revcloudReactionFun
It only a short example and it can not consider many requirements.
Powered by vBulletin™ Version 4.1.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.