yrnomad Posted November 29, 2007 Posted November 29, 2007 I'm trying to create a lisp to: Ask what revision number I am working on: (setq RN) for this example I will use 8 Take that value and use it in creating a layer name for a revision tag (PE_Rev8-Delta) Use that layer to insert the revision delta on Use that value for the attribute in the delta block. Use the RN value for creating a layer name for revision cloud (PE_Rev8-Cloud) and make it current Start revcloud command. My problems that I know of are: I don't know how to take the "RN" value and use it as part of the layer name creation. I don't know how to make my insertion scale factor (setq SF) a product of my dimscale (setq DS) times .1 (for some reason the company I work for inserts all their blocks at .1 of the dimscale, seems like a future task should be rescale the master blocks...) Below is a portion of my code, I've highlighted my problem areas with red text and *s. If you see anything else I should think of let me know. Thanks for your help and input! (defun c:PE_rev () (setq oldlayer (getvar "clayer")) (setvar "cmdecho" 0) ; create revision tag layer then insert tag ;Get Revision number (SETQ RN (GETREAL "Revision number")) ;[b][color=Red]**Problem 1**[/color][/b] (COMMAND "_.LAYER" "M" "PE_Rev[b][color=Red]8[/color][/b]-Delta" "C" "40" "PE_Rev[color=Red][b]8[/b][/color][b][color=Red][/color][/b]-Delta" "S" "PE_Rev[b][color=Red]8[/color][/b]-Delta" "") (SETQ DS (GETVAR "DIMSCALE")) ;[color=Red][b]**Problem 2**[/b][/color] (SETQ SF ([b][color=Red]***[/color][/b])) (TERPRI) (SETQ PT (GETPOINT "SELECT INSERTION POINT:")) (TERPRI) ; (SETQ RA (GETPOINT "0")) ; ; EY_Rev is the revision tag symbol located at H:\Eng\a_blocks\Symbols; ; (COMMAND "-INSERT" "EY_REV" "S" PT SF "" "" RN "" "0")) Quote
lpseifert Posted November 29, 2007 Posted November 29, 2007 1. (setq LN (strcat "PE_Rev"(rtos RN)"-Delta")) ; use LN for your layer name; if you use (rtos RN 2 0) it will return an integer, (rtos RN 2 1) will return 1 decimal point. 2. (setq SF (* DS 0.1)) ; SF will be 0.1 times the dimscale, could be shortened to (* (getvar "dimscale") 0.1) I didn't test your code with these but I think it should work Quote
yrnomad Posted November 29, 2007 Author Posted November 29, 2007 Ok, I made some modifications to follow what I think you were saying but I'm getting a couple other issues now. when I answered 24 to the revision number question the layer was named "PE_Rev2'-delta and the number in the delta was 24.00000000000000 Is there a way to suppress the decimal and 14 0s that come in in my tag? When I entered 7 for the rev# I get: Command: pe_rev Enter Revision number: 7 -LAYER Current layer: "PE_xref" Enter an option [?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck/Unlock /stAte]: M Enter name for new layer (becomes the current layer) : PE_Rev7.0000"-Delta Invalid layer name. ; error: Function cancelled Here is my updated code: (defun c:PE_rev () (setq oldlayer (getvar "clayer")) (setvar "cmdecho" 1) ; create revision tag layer then insert tag portion;;;;;;;;;;;;;;;;;; ;Get Revision number (SETQ RN (GETREAL "Enter Revision number: ")) (Setq LND (strcat "PE_Rev"(rtos RN)"-Delta")) ; if you use (rtos RN 2 0) it will return an integer, (rtos RN 2 1) (SETQ SF (* (getvar "dimscale") 0.1)) ` (TERPRI) (COMMAND "-LAYER" "M" LND "C" "40" LND "S" LND "") (SETQ PT (GETPOINT "SELECT INSERTION POINT:")) (TERPRI) ; ; EY_Rev is the revision tag symbol located at H:\Eng\a_blocks\Symbols; (COMMAND "-INSERT" "H:\\Eng\\a_blocks\\Symbols\\EY_REV" PT SF "" "" RN) ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Revision cloud portion;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; create revision layer then cloud ; (if (null (tblsearch "layer" "PE_revT-1")) (Setq LNC (strcat "PE_Rev"(rtos RN)"-Cloud")) (COMMAND "-LAYER" "M" LNCD "C" "40" LNC "S" LNC "") (c:revcloud) (setvar "clayer" oldlayer) (princ) ) Quote
lpseifert Posted November 29, 2007 Posted November 29, 2007 ^^^^^^^^^^^ 1. (setq LN (strcat "PE_Rev"(rtos RN)"-Delta")) ; use LN for your layer name; if you use (rtos RN 2 0) it will return an integer, (rtos RN 2 1) will return 1 decimal point. Or if you have no need for decimal points in the revision number, use (getint) instead of (getreal), and use (itoa) instead of (rtos). ****edit**** actually...if you use (rtos RN 2 0) it will return a string of a number with no decimal points, not an integer Also, I don't think you have LNCD set as a variable in the Revision cloud portion of your code ****edit**** Now that I think of it, why not try using (setq RN (Getstring "Enter Revision Number: ")) and eliminate the (rtos)/(itoa) all together. Quote
yrnomad Posted November 29, 2007 Author Posted November 29, 2007 Ok, that did it... Now a few final questions: Can I have the RN default to the last one entered, so if I do a bunch in a row, I don't have to keep re-entering it? When I start and when I end the cloud, can I automate the routine to choose a midpoint osnap on the tag, or should I wait and use some sort of trim function to trim the cloud using the tag's lines? When I run the whole routine, and I finish the cloud, I don't switch back to the original layer. I can't remember how to get it to take that next step after completing the REVCLOUD command. Thanks so much for your help! (defun c:PE_rev () (setq OL (getvar "clayer")) (setvar "cmdecho" 1) ; create revision tag layer then insert tag portion;;;;;;;;;;;;;;;;;; ;Get Revision number (SETQ RN (GETINT "Enter Revision number: ")) (Setq LND (strcat "PE_Rev"(itoa RN)"-Delta")) ; if you use (rtos RN 2 0) it will return an integer, (rtos RN 2 1) (SETQ SF (* (getvar "dimscale") 0.1)) ` (TERPRI) (COMMAND "-LAYER" "M" LND "C" "40" LND "S" LND "") (SETQ PT (GETPOINT "SELECT INSERTION POINT:")) (TERPRI) ; ; EY_Rev is the revision tag symbol located at H:\Eng\a_blocks\Symbols; (COMMAND "-INSERT" "H:\\Eng\\a_blocks\\Symbols\\EY_REV" PT SF "" "" RN) ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Revision cloud portion;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; create revision layer then cloud (Setq LNC (strcat "PE_Rev"(itoa RN)"-Cloud")) ; (if (null (tblsearch "layer" LNC)) (COMMAND "-LAYER" "M" LNC "C" "40" LNC "S" LNC "") (comand revcloud) (setvar "clayer" OL) (princ) ) Quote
wizman Posted December 1, 2007 Posted December 1, 2007 (defun c:PE_rev () (INITERR) (setvar "cmdecho" 1) ; create revision tag layer then insert tag portion;;;;;;;;;;;;;;;;;; ;Get Revision number (if (null *GLOBALRN*) (setq *GLOBALRN* 1) ) (initget 6) (SETQ RN (GETINT (STRCAT "Enter Revision number: : ") ) ) (if (NOT RN) (setq RN *GLOBALRN*) (SETQ *GLOBALRN* RN) ) (Setq LND (strcat "PE_Rev" (itoa RN) "-Delta")) ; if you use (rtos RN 2 0) it will return an integer, (rtos RN 2 1) (SETQ SF (* (getvar "dimscale") 0.1)) ` (TERPRI) (COMMAND "-LAYER" "M" LND "C" "40" LND "S" LND "") (SETQ PT (GETPOINT "SELECT INSERTION POINT:")) (TERPRI) ; ; EY_Rev is the revision tag symbol located at H:\Eng\a_blocks\Symbols; (COMMAND "-INSERT" "H:\\Eng\\a_blocks\\Symbols\\EY_REV" PT SF "" "" RN ) ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Revision cloud portion;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; create revision layer then cloud (Setq LNC (strcat "PE_Rev" (itoa RN) "-Cloud")) ; (if (null (tblsearch "layer" LNC)) (COMMAND "-LAYER" "M" LNC "C" "40" LNC "S" LNC "") (comand revcloud) (while (> (getvar "CmdActive") 0) (command pause)) (RESET) (princ) ) (defun initerr () ;init error (setq oldlayer (getvar "clayer")) ;save settings (setq oldsnap (getvar "osmode")) (setq oldpick (getvar "pickbox")) (setq temperr *error*) ;save *error* (setq *error* trap) ;reassign *error* (princ) ) ;defun ;;;*=========================================================== (defun trap (errmsg) ;define trap (command nil nil nil) (if (not (member errmsg '("console break" "Function Cancelled")) ) (princ (strcat "\nError: " errmsg)) ;print message ) ; (command "undo" "b") ;undo back (THIS IS OPTIONAL BY RON) (setvar "clayer" oldlayer) ;reset settings (setvar "blipmode" 1) (setvar "menuecho" 0) (setvar "highlight" 1) (setvar "osmode" oldsnap) (setvar "pickbox" oldpick) (princ "\nError Resetting Enviroment ") ;inform user (terpri) (setq *error* temperr) ;restore *error* (princ) ) ;defun ;;;*=========================================================== (defun reset () ;define reset (setq *error* temperr) ;restore *error* (setvar "clayer" oldlayer) ;reset settings (setvar "blipmode" 1) (setvar "menuecho" 0) (setvar "highlight" 1) (setvar "osmode" oldsnap) (setvar "pickbox" oldpick) (princ) ) ;defun ;;; FOR THE TRIM THAT YOU WANT BETTER TO USE WIPEOUT INSIDE ;;;YOUR BLOCK Quote
p0026376 Posted February 23, 2011 Posted February 23, 2011 Hi, I'm trying to use wizman's lisp, but I'm having two issues, 1) I'm not sure how the lisp passes the revision number to the block attribute for the delta, so I'm not sure how to create my revision block for this. 2) Once the delta gets inserted the script seems to end and the cloud is never created. Would it be possible to draw the cloud first *then choose the insertion point of the delta? thanks!! Quote
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.