jdofboise Posted November 28, 2012 Posted November 28, 2012 I execute this routine to add the dimension. It only allows me to add one dimension and then exits. If I try to run the routine a second time it does noting. I've tried a "while" statement placed in front of the first (setq...). That looped continously at the command prompt. ---------------------------------------------------- (defun c:RedOrdDim (/ scmde RedOrd) (setq scmde (getvar "cmdecho")) (setvar "cmdecho" 0) (if (tblsearch "UCS" "PnlRear") (command "_ucs" "restore" "PnlRear") (progn (command "_ucs" "New" "174.3125,68.00,0.0") (command "_ucs" "Named" "Save" "PnlRear") (command "_ucs" "Restore" "PnlRear") ) ) (if (tblsearch "DimStyle" "Red_Ordinate"); if Red_Ordinate exists, (command "DimStyle" "Restore" "Red_Ordinate"); activate DimStyle (progn (setvar "DIMADEC" 0) (setvar "DIMALT" 0) (setvar "DIMALTD" 2) (setvar "DIMALTF" 25.4000) (setvar "DIMALTRND" 0.0000) (setvar "DIMALTTD" 2) (setvar "DIMALTTZ" 0) (setvar "DIMALTU" 2) (setvar "DIMALTZ" 0) (setvar "DIMAPOST" "") (setvar "DIMASSOC" 1) (setvar "DIMASZ" 0.1250) (setvar "DIMATFIT" 3) (setvar "DIMAUNIT" 0) (setvar "DIMAZIN" 0) (setvar "DIMBLK" "") (setvar "DIMBLK1" "") (setvar "DIMBLK2" "") (setvar "DIMCEN" 0.093 (setvar "DIMCLRD" 1) (setvar "DIMCLRE" 1) (setvar "DIMCLRT" 1) (setvar "DIMDEC" 2) (setvar "DIMDLE" 0.0000) (setvar "DIMDLI" 0.3750) (setvar "DIMDSEP" ".") (setvar "DIMEXE" 0.093 (setvar "DIMEXO" 0.1250) (setvar "DIMFIT" 3) (setvar "DIMFRAC" 2) (setvar "DIMGAP" 0.0625) (setvar "DIMJUST" 0) (setvar "DIMLDRBLK" "") (setvar "DIMLFAC" 1.0000) (setvar "DIMLIM" 0) (setvar "DIMLUNIT" 5) (setvar "DIMLWD" -2) (setvar "DIMLWE" -2) (setvar "DIMPOST" "\"") (setvar "DIMRND" 0.0000) (setvar "DIMSAH" 0) (setvar "DIMSCALE" 8.0000) (setvar "DIMSD1" 0) (setvar "DIMSD2" 0) (setvar "DIMSE1" 0) (setvar "DIMSE2" 0) (setvar "DIMSHO" 1) (setvar "DIMSOXD" 0) (setvar "DIMTAD" 0) (setvar "DIMTDEC" 4) (setvar "DIMTFAC" 1.0000) (setvar "DIMTIH" 0) (setvar "DIMTIX" 1) (setvar "DIMTM" 0.0000) (setvar "DIMTMOVE" 0) (setvar "DIMTOFL" 0) (setvar "DIMTOH" 0) (setvar "DIMTOL" 0) (setvar "DIMTOLJ" 1) (setvar "DIMTP" 0.0000) (setvar "DIMTSZ" 0.0000) (setvar "DIMTVP" 0.0000) ;;(setvar "DIMTXSTY" "DIMEN") ;;(setvar 4 . "\"") (setvar "DIMTXT" 0.1250) (setvar "DIMTZIN" 0) (setvar "DIMUNIT" 7) (setvar "DIMUPT" 0) (setvar "DIMZIN" 3) (command "_.-dimstyle" "Save" "Red_Ordinate") (command "_.-dimstyle" "Restore" "Red_Ordinate") (command "dimordinate" "") ) ;end progn ) ;end if (princ) ) ;end defun -------------------------------------------------------- jdofboise Quote
irneb Posted November 29, 2012 Posted November 29, 2012 You had some parenthesis in the wrong place, and was missing 2 closing parens. (defun c:RedOrdDim (/ scmde RedOrd) (setq scmde (getvar "cmdecho")) (setvar "cmdecho" 0) (if (tblsearch "UCS" "PnlRear") (command "_ucs" "restore" "PnlRear") (progn (command "_ucs" "New" "174.3125,68.00,0.0") (command "_ucs" "Named" "Save" "PnlRear") (command "_ucs" "Restore" "PnlRear"))) (if (tblsearch "DimStyle" "Red_Ordinate") ; if Red_Ordinate exists, (command "DimStyle" "Restore" "Red_Ordinate") ; activate DimStyle (progn (setvar "DIMADEC" 0) (setvar "DIMALT" 0) (setvar "DIMALTD" 2) (setvar "DIMALTF" 25.4000) (setvar "DIMALTRND" 0.0000) (setvar "DIMALTTD" 2) (setvar "DIMALTTZ" 0) (setvar "DIMALTU" 2) (setvar "DIMALTZ" 0) (setvar "DIMAPOST" "") (setvar "DIMASSOC" 1) (setvar "DIMASZ" 0.1250) (setvar "DIMATFIT" 3) (setvar "DIMAUNIT" 0) (setvar "DIMAZIN" 0) (setvar "DIMBLK" "") (setvar "DIMBLK1" "") (setvar "DIMBLK2" "") (setvar "DIMCEN" 0.093) (setvar "DIMCLRD" 1) (setvar "DIMCLRE" 1) (setvar "DIMCLRT" 1) (setvar "DIMDEC" 2) (setvar "DIMDLE" 0.0000) (setvar "DIMDLI" 0.3750) (setvar "DIMDSEP" ".") (setvar "DIMEXE" 0.093) (setvar "DIMEXO" 0.1250) (setvar "DIMFIT" 3) (setvar "DIMFRAC" 2) (setvar "DIMGAP" 0.0625) (setvar "DIMJUST" 0) (setvar "DIMLDRBLK" "") (setvar "DIMLFAC" 1.0000) (setvar "DIMLIM" 0) (setvar "DIMLUNIT" 5) (setvar "DIMLWD" -2) (setvar "DIMLWE" -2) (setvar "DIMPOST" "\"") (setvar "DIMRND" 0.0000) (setvar "DIMSAH" 0) (setvar "DIMSCALE" 8.0000) (setvar "DIMSD1" 0) (setvar "DIMSD2" 0) (setvar "DIMSE1" 0) (setvar "DIMSE2" 0) (setvar "DIMSHO" 1) (setvar "DIMSOXD" 0) (setvar "DIMTAD" 0) (setvar "DIMTDEC" 4) (setvar "DIMTFAC" 1.0000) (setvar "DIMTIH" 0) (setvar "DIMTIX" 1) (setvar "DIMTM" 0.0000) (setvar "DIMTMOVE" 0) (setvar "DIMTOFL" 0) (setvar "DIMTOH" 0) (setvar "DIMTOL" 0) (setvar "DIMTOLJ" 1) (setvar "DIMTP" 0.0000) (setvar "DIMTSZ" 0.0000) (setvar "DIMTVP" 0.0000) ;;(setvar "DIMTXSTY" "DIMEN") ;;(setvar 4 . "\"") (setvar "DIMTXT" 0.1250) (setvar "DIMTZIN" 0) (setvar "DIMUNIT" 7) (setvar "DIMUPT" 0) (setvar "DIMZIN" 3) (command "_.-dimstyle" "Save" "Red_Ordinate") (command "_.-dimstyle" "Restore" "Red_Ordinate"))) (command "dimordinate" "") (princ)) Please use code tags in the future to surround your code. Otherwise it's difficult to read. Quote
SLW210 Posted November 29, 2012 Posted November 29, 2012 jdofboise, Please read the CODE POSTING GUIDELINES and edit your post to include Code Tags! Quote
BIGAL Posted November 30, 2012 Posted November 30, 2012 A bit of help a liitle one I wrote a long time ago or use VLIDE and use check code will check brackets na dgive an idea of were wrong (defun c:chkbrk (/ opf bkt chekdfile rdctl wkfile currentln wln ltr ncln) (setvar "cmdecho" 0) (prompt "\nlook at end of line") ;(setq chekdfile (getstring "enter name of file :")) (SETQ chekdfile (getfiled "Enter file name:" " " "LSP" 4)) (setq opf (open chekdfile "r")) (setq bkt 0) (setq blkl 0) (setq rdctl 1) (setq wkfile (open "c:\temp\wow.lsp" "w")) (setq currentln "a") (while (/= blkl 6) (setq currentln (read-line opf)) (if (= currentln nil)(setq currentln "")) (if (= currentln "")(setq blkl (+ 1 blkl))(setq blkl 1)) (setq wln currentln) (while (/= wln "") (setq ltr (substr wln 1 1)) (setq wln (substr wln 2)) (cond ((= (ascii ltr) 34) (if (= rdctl 0)(setq rdctl 1)(setq rdctl 0))) ((and (= ltr "(")(= rdctl 1))(setq bkt (+ bkt 1))) ((and (= ltr ")")(= rdctl 1))(setq bkt (- bkt 1))) ((and (= ltr ";")(= rdctl 1))(setq wln "")) ;(t (prompt ltr)) ) ) (setq ncln (strcat currentln ";" (itoa bkt) (princ (itoa bkt)) (if (= rdctl 0) "string open" ""))) (if (/= currentln "")(write-line ncln wkfile)) ) (close wkfile) (close opf) (prompt (strcat "open brakets= " (itoa bkt) ".")) ) (setq ang1 nil pt1 nil pt2 nil pt3 nil pt4 nil pt5 nil) (princ) Quote
jdofboise Posted November 30, 2012 Author Posted November 30, 2012 SLW - Sorry about missing the wrap on the code. I looked at every button to see which one did jus that. Must have skpped over it. BIGAL - I'll give this a shot. I started reading the help file for checking brackets in code using the Visual lisp tools. We'll see if I learn anything. irneb - Thanks for the check on the code. Much appreciated. My intent for using this routine is to start the command and have a dimstyle and UCS set to a specific spot. I've created 4 seperate routines to handle 2 different UCS locations with 2 different Dimstyles. One Dimstyle being all red and the other being bylayer. I can't figure out how to reset the UCS back to the drawings original UCS ("World" or 0,0 of border) after using the command. If I go to one UCS and dimension and then try to run the lisp for the other UCS it moves it as if the current UCS is my original UCS of the sht. border. How do I reset the Original border UCS to then reset my 2nd new UCS? I've tried... (if (tblsearch... at the beginning just after the first setvar. or (commmand "ucs" "World")...in the same place or (command "ucs" "World")...at the bottom below the last (command... with no favorable results. Should I create both new UCS' in the same routine so that it exists as a known point relative to the sht. border? I just can't see it. (defun c:fgd (/ scmde RedOrd) (setq scmde (getvar "cmdecho")) (setvar "cmdecho" 0) (if (tblsearch "UCS" "PnlFront") (command "_ucs" "restore" "PnlFront") (progn (command "_ucs" "New" "236.3125,68.00,0.0") (command "_ucs" "Named" "Save" "PnlFront") (command "_ucs" "Restore" "PnlFront") (command "_ucsicon" "on" "" "ORigen") ) ) (if (tblsearch "DimStyle" "Ordinate") ; if Ordinate exists, (command "DimStyle" "Restore" "Ordinate") ; activate DimStyle (progn (setvar "DIMADEC" 0) (setvar "DIMALT" 0) (setvar "DIMALTD" 2) (setvar "DIMALTF" 25.4000) (setvar "DIMALTRND" 0.0000) (setvar "DIMALTTD" 2) (setvar "DIMALTTZ" 0) (setvar "DIMALTU" 2) (setvar "DIMALTZ" 0) (setvar "DIMAPOST" "") (setvar "DIMASSOC" 1) (setvar "DIMASZ" 0.1250) (setvar "DIMATFIT" 3) (setvar "DIMAUNIT" 0) (setvar "DIMAZIN" 0) (setvar "DIMBLK" "") (setvar "DIMBLK1" "") (setvar "DIMBLK2" "") (setvar "DIMCEN" 0.0938) (setvar "DIMCLRD" 2) (setvar "DIMCLRE" 2) (setvar "DIMCLRT" 3) (setvar "DIMDEC" 2) (setvar "DIMDLE" 0.0000) (setvar "DIMDLI" 0.3750) (setvar "DIMDSEP" ".") (setvar "DIMEXE" 0.0938) (setvar "DIMEXO" 0.1250) (setvar "DIMFIT" 3) (setvar "DIMFRAC" 2) (setvar "DIMGAP" 0.0625) (setvar "DIMJUST" 0) (setvar "DIMLDRBLK" "") (setvar "DIMLFAC" 1.0000) (setvar "DIMLIM" 0) (setvar "DIMLUNIT" 5) (setvar "DIMLWD" -2) (setvar "DIMLWE" -2) (setvar "DIMPOST" "\"") (setvar "DIMRND" 0.0000) (setvar "DIMSAH" 0) (setvar "DIMSCALE" 8.0000) (setvar "DIMSD1" 0) (setvar "DIMSD2" 0) (setvar "DIMSE1" 0) (setvar "DIMSE2" 0) (setvar "DIMSHO" 1) (setvar "DIMSOXD" 0) (setvar "DIMTAD" 0) (setvar "DIMTDEC" 4) (setvar "DIMTFAC" 1.0000) (setvar "DIMTIH" 0) (setvar "DIMTIX" 1) (setvar "DIMTM" 0.0000) (setvar "DIMTMOVE" 0) (setvar "DIMTOFL" 0) (setvar "DIMTOH" 0) (setvar "DIMTOL" 0) (setvar "DIMTOLJ" 1) (setvar "DIMTP" 0.0000) (setvar "DIMTSZ" 0.0000) (setvar "DIMTVP" 0.0000) ;;(setvar "DIMTXSTY" "DIMEN") ;;(setvar 4 . "\"") (setvar "DIMTXT" 0.1250) (setvar "DIMTZIN" 0) (setvar "DIMUNIT" 7) (setvar "DIMUPT" 0) (setvar "DIMZIN" 3) (command "_.-dimstyle" "Save" "Ordinate") (command "_.-dimstyle" "Restore" "Ordinate") ) ) (command "dimordinate") (princ) ) ;end defun thanks for the help J. You know we're screwed when Congress says pizza is a vegetable. 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.