asos2000 Posted February 25, 2010 Posted February 25, 2010 Whats wrong with this code? (initget "1:20 1:25 1:50 1:100 1:150") (setq DwgScl (getkword "\n What is Drawing Scale? [1:20/1:25/1:50/1:100/1:150]")) (setq StyleName (strcat "EC-22-" (rtos DwgScl))) (setq DimName (strcat "EC-" (rtos dwgscl))) (if (= DwgScl 1:20) (progn (command "-style" EC-22-020 "" "" "" "" "" "" "") (command "-dimstyle" "save" EC-020) (if (= DwgScl 1:25) (progn (command "-style" EC-22-025 "" "" "" "" "" "" "") (command "-dimstyle" "save" EC-025) (if (= DwgScl 1:50) (progn (command "-style" EC-22-050 "" "" "" "" "" "" "") (command "-dimstyle" "save" EC-050) (if (= DwgScl 1:100) (progn (command "-style" EC-22-100 "" "" "" "" "" "" "") (command "-dimstyle" "save" EC-100) (if (= DwgScl 1:150) (progn (command "-style" EC-22-150 "" "" "" "" "" "" "") (command "-dimstyle" "save" EC-150))))))))))) Quote
MSasu Posted February 25, 2010 Posted February 25, 2010 All PROGN are closed at end. So each IF statement receive three expresions instead of two as supported. This is at first glance. But why don't you use COND statement instead? Regards, Quote
asos2000 Posted February 25, 2010 Author Posted February 25, 2010 (initget "1:20 1:25 1:50 1:100 1:150") (setq DwgScl (getkword "\n What is Drawing Scale? [1:20/1:25/1:50/1:100/1:150]")) (setq StyleName (strcat "EC-22-" (rtos DwgScl))) (setq DimName (strcat "EC-" (rtos dwgscl))) (cond ((= DwgScl 1:20) (command "-style" EC-22-020 "" "" "" "" "" "" "") (command "-dimstyle" "save" EC-020)) ((= DwgScl 1:25) (command "-style" EC-22-025 "" "" "" "" "" "" "") (command "-dimstyle" "save" EC-025)) ((= DwgScl 1:50) (command "-style" EC-22-050 "" "" "" "" "" "" "") (command "-dimstyle" "save" EC-050)) ((= DwgScl 1:100) (command "-style" EC-22-100 "" "" "" "" "" "" "") (command "-dimstyle" "save" EC-100)) ((= DwgScl 1:150) (command "-style" EC-22-150 "" "" "" "" "" "" "") (command "-dimstyle" "save" EC-150)) (t (coldim))) but reutrn this errormessage What is Drawing Scale? [1:20/1:25/1:50/1:100/1:150]1:50 ** Error: bad argument type: numberp: "1:50" ** Quote
MSasu Posted February 25, 2010 Posted February 25, 2010 GETKWORD statement will return a string - but you are trying to treat it as a real. To get scale factor from user input may use: (substr DwgScl 3) May want to adjust style names accordingly or add "0" to input where scale factor is two digits only. Regards, Quote
asos2000 Posted February 25, 2010 Author Posted February 25, 2010 I didnt get it more explanation please This code is a part of the routine I was thinking to set all variables to match the company standards create from the bigining but the isuue is i didnt to choose the text this lisp a part of a menu so who has this lisp but the problem which I faced is to choose textstyle for dimstyle (setq DwgScl (getreal "\n What is Drawing Scale: 1:")) (command "-units" "2" "0" "1" "0" "0" "n") (setq StyleName (strcat "EC-22-" (rtos DwgScl))) (setq DimName (strcat "EC-" (rtos dwgscl))) (command "-units" "2" "2" "1" "0" "0" "n") (setq TextHeight (* DwgScl 2.2)) (command "-style" StyleName "romans.shx" TextHeight "08" "0" "n" "n" "n") (command "-dimstyle" "save" DimName) (command "DIMSAH" "on") (command "DIMTIX" On) (command "insunits" "4") (setvar "DIMALTF" 25.4) (setvar "DIMALTTD" 2) (setvar "DIMASZ" (* 0.2 DwgScl)) (setvar "DIMBLK1" "_OBLIQUE") (setvar "DIMBLK2" "_OBLIQUE") (setvar "DIMCEN" 0) (setvar "DIMCLRD" (setvar "DIMCLRE" (setvar "DIMCLRT" 10) (setvar "DIMDEC" 0) (setvar "DIMDLE" (* 1 DwgScl)) (setvar "DIMDLI" (setvar "DIMDSEP" ".") (setvar "DIMEXE" (* 1 DwgScl)) (setvar "DIMEXO" (* 3 DwgScl)) (setvar "DIMGAP" (* 1 DwgScl)) ;(setvar "DIMLDRBLK" "") (setvar "DIMTDEC" 0) (setvar "DIMTMOVE" 1) (setvar "DIMTOLJ" 1) (setvar "DIMTXT" 12) (setvar "DIMTZIN" 0) (setvar "DIMZIN" 0) as what will you see I changed the strategy, The lisp will insert a dwg file has company standards so I want to make one of them as a default to use in the main part of the routine. ;To add the vertical ad horizantal dimensions ;which shoing the relation between columns and axes (defun c:coldim (/ *error* DwgScl P1 P2 P3 P4 SPC TXT UFLAG) (vl-load-com) (defun *error* (msg) (and uFlag (vla-EndUndoMark doc)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ)) (setq OldOS (getvar "osmode")) (setq OldDynmode (getvar "dynmode")) (setq OldDynprompt (getvar "dynprompt")) (setvar "osmode" 33) (setvar "dynmode" 1) (setvar "dynprompt" 1) (command "-insert" "C:/EC-Menu/Blocks/EC-standards.dwg" "0,0,0" "1" "1" "0" "explode" "") (initget "1:20 1:25 1:50 1:100 1:150") (setq DwgScl (getkword "\n What is Drawing Scale? [1:20/1:25/1:50/1:100/1:150]")) ;(setq StyleName (strcat "EC-22-" (rtos DwgScl))) ;(setq DimName (strcat "EC-" (rtos dwgscl))) (cond ((= DwgScl 1:20) (command "-style" EC-22-020 "" "" "" "" "" "" "") (command "-dimstyle" "save" EC-020)) ((= DwgScl 1:25) (command "-style" EC-22-025 "" "" "" "" "" "" "") (command "-dimstyle" "save" EC-025)) ((= DwgScl 1:50) (command "-style" EC-22-050 "" "" "" "" "" "" "") (command "-dimstyle" "save" EC-050)) ((= DwgScl 1:100) (command "-style" EC-22-100 "" "" "" "" "" "" "") (command "-dimstyle" "save" EC-100)) ((= DwgScl 1:150) (command "-style" EC-22-150 "" "" "" "" "" "" "") (command "-dimstyle" "save" EC-150)) (t (coldim))) (setq doc (cond (doc) ((vla-get-ActiveDocument (vlax-get-Acad-Object)))) spc (if (zerop (vla-get-activespace doc)) (if (= (vla-get-mspace doc) :vlax-true) (vla-get-modelspace doc) (vla-get-paperspace doc)) (vla-get-modelspace doc))) (while (and (setq p1 (getpoint "\nPick Axes Crossing Point: ")) (setq p2 (getpoint "\nPick Corner Point: "))) (setq uFlag (not (vla-StartUndoMark doc))) (apply (function vla-AddDimRotated) (append (list spc) (mapcar (function vlax-3D-point) (list (setq p3 (list (car p1) (cadr p2) (caddr p1))) p2 (polar p3 (angle p1 p3) (* DwgScl ))) '(0.))) (apply (function vla-AddDimRotated) (append (list spc) (mapcar (function vlax-3D-point) (list p2 (setq p4 (list (car p2) (cadr p1) (caddr p1))) (polar p4 (angle p1 p4) (* DwgScl ))) (list (/ pi 2.)))) (setq uFlag (vla-EndUndoMark doc)) ) ; while ; Restore OSmode (setq *error* TERR$) (setvar "osmode" OldOS) (setvar "dynmode" OldDynmode) (setvar "dynprompt" OldDynprompt) (princ "\nProgram completed and will now restore the user settings and exit.") ) This is the story. Quote
rkmcswain Posted February 25, 2010 Posted February 25, 2010 I didnt get itmore explanation please msasu put it about as plainly as possible. (getkword) returns a STRING, but in the next line you are using that variable in the (rtos) function which expects a REAL. If you are not already, do yourself a favor and use the VLIDE to edit and debug your code. Errors like this can easily be identified and corrected. Quote
alanjt Posted February 25, 2010 Posted February 25, 2010 (initget 0 "20 25 50 100 150") (if (setq DwgScl (getkword "\nSpecify Drawing Scale [20/25/50/100/150]: 1:")) (progn (command "_.-style" (strcat "EC-22-" DwgScl) "" "" "" "" "" "" "") (if (> 3 (strlen DwgScl)) (command "_.-dimstyle" "_save" (strcat "EC-0" DwgScl)) (command "_.-dimstyle" "_save" (strcat "EC-" DwgScl))))) Wouldn't something like this make things a little easier? Quote
asos2000 Posted February 25, 2010 Author Posted February 25, 2010 ALAN yes its easyer than before I tried to do that but I didnt find DXF dimstyle code (or variable) to set textstyle 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.