dan03432 Posted March 30, 2012 Share Posted March 30, 2012 I am trying to write a lisp that will change the current color (not layer color), execute a user input command, then change it back to bylayer. (defun C:revc () (command "color" "240") (command "revcloud") (command "color" "bylayer") ) ;end_defun If I remove the command to change the color back to bylayer it will execute fine. I think it is having an issue when I don't pause it and wait for the user to finish the "revcloud" command. Quote Link to comment Share on other sites More sharing options...
MSasu Posted March 30, 2012 Share Posted March 30, 2012 You may use the CECOLOR system variable instead: (setvar "CECOLOR" "240") ;your code here (setvar "CECOLOR" "ByLayer") Regards, Mircea Quote Link to comment Share on other sites More sharing options...
pBe Posted March 30, 2012 Share Posted March 30, 2012 (defun c:revc nil (setvar 'Cecolor "240") (command "_.Revcloud") (while (> (getvar 'Cmdactive) 0) (command pause)) (setvar 'Cecolor "256")(princ) ) EDIT: Ooops.. didnt see your post there Mircea Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 30, 2012 Share Posted March 30, 2012 No matter what the layer status color is . (defun c:TesT nil (command "_.revcloud") (while (= (getvar 'cmdactive) 1) (command pause) ) (command "_.chprop" (entlast) "" "_color" 240 "") (princ) ) Quote Link to comment Share on other sites More sharing options...
BlackBox Posted March 30, 2012 Share Posted March 30, 2012 Be careful... Command: revc _.Revcloud Minimum arc length: 0.5000 Maximum arc length: 0.5000 Style: Normal Specify start point or [Arc length/Object/Style] <Object>: [color=red]*Cancel*[/color] Command: [color=red]; error: Function cancelled[/color] Quote Link to comment Share on other sites More sharing options...
pBe Posted March 30, 2012 Share Posted March 30, 2012 Busted!! Quote Link to comment Share on other sites More sharing options...
BlackBox Posted March 30, 2012 Share Posted March 30, 2012 No matter what the layer status color is . I believe the intent is to draw the revcloud in the desired color, and not change afterward. Busted!! Example with error handling: (defun c:revc ( / *error*) (defun *error* (msg) (and oldCecolor (setvar 'cecolor oldCecolor)) (cond ((not msg)) ; Normal exit ((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit) ((princ (strcat "\n** Error: " msg " ** ")))) ; Fatal error, display it (princ)) ((lambda (oldCecolor) (setvar 'cecolor "240") (command "._revcloud") (while (= (logand 1 (getvar 'cmdactive)) 1) (command pause)) (*error* nil)) (getvar 'cecolor))) ** Edit - This way, both when the command is completed, and if the user escapes out, the original Cecolor is restored. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 30, 2012 Share Posted March 30, 2012 Another: (vl-load-com) (if (null *revcloudreactor*) (setq *revcloudreactor* (vlr-command-reactor nil '( (:vlr-commandwillstart . revcloudstore) (:vlr-commandended . revcloudrestore) (:vlr-commandfailed . revcloudrestore) (:vlr-commandcancelled . revcloudrestore) ) ) ) ) (defun revcloudstore ( reactor params ) (if (wcmatch (strcase (car params)) "*REVCLOUD") (progn (setq *cecolor* (getvar 'CECOLOR)) (setvar 'CECOLOR "240") ) ) (princ) ) (defun revcloudrestore ( reactor params ) (if (and *cecolor* (wcmatch (strcase (car params)) "*REVCLOUD")) (progn (setvar 'CECOLOR *cecolor*) (setq *cecolor* nil) ) ) (princ) ) (princ) Quote Link to comment Share on other sites More sharing options...
pBe Posted March 30, 2012 Share Posted March 30, 2012 Example with error handling: (defun c:revc ( / *error*) (defun *error* (msg) (and oldCecolor (setvar 'cecolor oldCecolor)) ..... This way, both when the command is completed, and if the user escapes out, the original Cecolor is restored. Yup I knew i couldnt type and code as fast as your Renderman so i didnt even try Quote Link to comment Share on other sites More sharing options...
BlackBox Posted March 30, 2012 Share Posted March 30, 2012 Using a Command Reactor is my preferred method of standardizing active layer, color, etc. for multiple commands. Very concise, Lee. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 30, 2012 Share Posted March 30, 2012 Cheers dude Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 30, 2012 Share Posted March 30, 2012 Fantastic code Lee . I wish I could deal with reactors one day . Quote Link to comment Share on other sites More sharing options...
BlackBox Posted March 30, 2012 Share Posted March 30, 2012 I knew i couldnt type and code as fast as your Renderman so i didnt even try That is kind of you to say, but please know that trying to both offer the (or at least a) solution to a post, and do so before Lee, etc. beat me to it is what helped me learn all that I have... A little friendly, and respectful competition can be a good thing. Don't ever feel that you couldn't, or shouldn't contribute because I or others have jumped in... Helping others is a great way to learn yourself. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted March 30, 2012 Share Posted March 30, 2012 I wish I could deal with reactors one day . Who are you, and what have you done with the Tharwat that I know!?!? You can tackle reactors - just know the rules, and plan for contingencies the way you would with any other routine. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 30, 2012 Share Posted March 30, 2012 Who are you, and what have you done with the Tharwat that I know!?!? You can tackle reactors - just know the rules, and plan for contingencies the way you would with any other routine. I am overwhelmed by work nowadays , and reactor need a very calm mind to avoid getting crazy . Sooner or later will get through it deeply . Thanks mate for the head up . Quote Link to comment Share on other sites More sharing options...
pBe Posted March 30, 2012 Share Posted March 30, 2012 That is kind of you to say, but please know that trying to both offer the (or at least a) solution to a post, and do so before Lee, etc. beat me to it is what helped me learn all that I have... A little friendly, and respectful competition can be a good thing. Don't ever feel that you couldn't, or shouldn't contribute because I or others have jumped in... Helping others is a great way to learn yourself. Wilco, Thank you Renderman and Cheers Quote Link to comment Share on other sites More sharing options...
BlackBox Posted March 30, 2012 Share Posted March 30, 2012 ... Anytime. Quote Link to comment Share on other sites More sharing options...
dan03432 Posted March 30, 2012 Author Share Posted March 30, 2012 Wow, hijacked forum post jk, thanks guys, got it working now Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.