** Error: Too many actual para
Hi there,I have a problem with lisp routine in CAD 2011 (and Civil 3d 2011).
Attached lisp is working perfectly in CAD and Civil 2010 but when I'm trying to run it in 2011 I have an error message in command line:
** Error: Too many actual parameters **
I've searched on web but couldn't find answer. Does anybody know what is wrong?
Thanks for all help in advance
a2f.lsp Hi Tomjas,
I see that is one of mine, hence I am intrigued as to the root of the problem...
If you run the code through the VLIDE in 2011 with the 'Break on Error' option ticked, then go to 'Last Break Source' when the error occurs, what line is highlighted? Hi Lee Mac,
Yes- it's one of your great lisps
Below I made the code highlighted in vlide in red:
(defun c:a2f (/ *error* Stringify ENT OBJ PT TMP TOBJ TYP UFLAG) ;; Lee Mac~13.01.10 (vl-load-com) (defun *error* (msg) (and uFlag (vla-EndUndoMark *doc*)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ))(defun Stringify (x / typ) (cond ((eq 'REAL (setq typ (type x))) (rtos x)) ((eq 'INT typ) (itoa x)) ((eq 'STR typ) x) (t (vl-princ-to-string x))))(setq *doc* (cond (*doc*) ((vla-get-ActiveDocument (vlax-get-acad-object)))) *spc* (cond (*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*))))) (setq *a2f_Uni 2)) (or *a2f_Pre (setq *a2f_Pre 0)) (or *a2f_Con (setq *a2f_Con 1.)) (or *a2f_Hgt (setq *a2f_Hgt (getvar 'TEXTSIZE))) (setq *a2f_Rot 0.)) (or *a2f_Suf (setq *a2f_Suf "m2")) (mapcar (function set) '(*a2f_Pre *a2f_Con *a2f_Hgt *a2f_Suf) (mapcar (function (lambda (ini foo msg x) (and ini (initget ini)) (cond ((and (setq tmp ((eval foo) (strcat "\n" msg ": "))) (/= "" tmp)) tmp) (x)))) (list 4 6 6 nil) '(GetInt GetReal GetDist GetString) '("Specify Precision" "Specify Conversion Factor" "Specify Text Height" "Specify Suffix") (list *a2f_Pre *a2f_Con *a2f_Hgt *a2f_Suf))) (while (progn (setq ent (car (entsel "\n>> Pick Hatch >>"))) (cond ((eq 'ENAME (type ent)) (if (and (eq "AcDbHatch" (vla-get-ObjectName (setq obj (vlax-ename->vla-object ent)))) (vlax-property-available-p obj 'Area)) (if (setq pt (getpoint "\nPick Point for Field: ")) (progn (setq uFlag (not (vla-StartUndoMark *doc*))) (setq tObj (vla-AddMText *spc* (vlax-3D-point pt) 0.0 (strcat "%%"))) (mapcar (function (lambda (property value) (vlax-put-property tObj property value))) '(Height Rotation Layer Color) (list *a2f_Hgt *a2f_Rot (vlax-get-property obj 'Layer) (vlax-get-property obj 'Color))) (setq uFlag (vla-EndUndoMark *doc*)) t) ;; repeat ) (princ "\n** Invalid Object Selected **")))))) (princ))
Thanks for your help in advance! Ah - that's a typo on my part - I should've spotted that
Please try this instead:
(defun c:a2f (/ *error* Stringify ENT OBJ PT TMP TOBJ TYP UFLAG) ;; Lee Mac~13.01.10 (vl-load-com) (defun *error* (msg) (and uFlag (vla-EndUndoMark *doc*)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ))(defun Stringify (x / typ) (cond ((eq 'REAL (setq typ (type x))) (rtos x)) ((eq 'INT typ) (itoa x)) ((eq 'STR typ) x) (t (vl-princ-to-string x))))(setq *doc* (cond (*doc*) ((vla-get-ActiveDocument (vlax-get-acad-object)))) *spc* (cond (*spc*) ((if (zerop (vla-get-activespace *doc*)) (if (eq (vla-get-mspace *doc*) :vlax-true) (vla-get-modelspace *doc*) (vla-get-paperspace *doc*)) (vla-get-modelspace *doc*))))) (setq *a2f_Uni 2)) (or *a2f_Pre (setq *a2f_Pre 0)) (or *a2f_Con (setq *a2f_Con 1.)) (or *a2f_Hgt (setq *a2f_Hgt (getvar 'TEXTSIZE))) (setq *a2f_Rot 0.)) (or *a2f_Suf (setq *a2f_Suf "m2")) (mapcar (function set) '(*a2f_Pre *a2f_Con *a2f_Hgt *a2f_Suf) (mapcar (function (lambda (ini foo msg x) (and ini (initget ini)) (cond ((and (setq tmp ((eval foo) (strcat "\n" msg ": "))) (/= "" tmp)) tmp) (x)))) (list 4 6 6 nil) '(GetInt GetReal GetDist GetString) '("Specify Precision" "Specify Conversion Factor" "Specify Text Height" "Specify Suffix") (list *a2f_Pre *a2f_Con *a2f_Hgt *a2f_Suf))) (while (progn (setq ent (car (entsel "\n>> Pick Hatch >>"))) (cond ((eq 'ENAME (type ent)) (if (and (eq "AcDbHatch" (vla-get-ObjectName (setq obj (vlax-ename->vla-object ent)))) (vlax-property-available-p obj 'Area)) (if (setq pt (getpoint "\nPick Point for Field: ")) (progn (setq uFlag (not (vla-StartUndoMark *doc*))) (setq tObj (vla-AddMText *spc* (vlax-3D-point pt) 0.0 (strcat "%%"))) (mapcar (function (lambda (property value) (vlax-put-property tObj property value))) '(Height Rotation Layer Color) (list *a2f_Hgt *a2f_Rot (vlax-get-property obj 'Layer) (vlax-get-property obj 'Color))) (setq uFlag (vla-EndUndoMark *doc*)) t) ;; repeat ) (princ "\n** Invalid Object Selected **")))))) (princ)) now when I'm trying to load it I have
error: extra right paren on input
I think I know where is a problem as I was trying to do some changes to original code- please see below in red
(defun c:a2f (/ *error* Stringify ENT OBJ PT TMP TOBJ TYP UFLAG) ;; Lee Mac~13.01.10 (vl-load-com) (defun *error* (msg) (and uFlag (vla-EndUndoMark *doc*)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ))(defun Stringify (x / typ) (cond ((eq 'REAL (setq typ (type x))) (rtos x)) ((eq 'INT typ) (itoa x)) ((eq 'STR typ) x) (t (vl-princ-to-string x))))(setq *doc* (cond (*doc*) ((vla-get-ActiveDocument (vlax-get-acad-object)))) *spc* (cond (*spc*) ((if (zerop (vla-get-activespace *doc*)) (if (eq (vla-get-mspace *doc*) :vlax-true) (vla-get-modelspace *doc*) (vla-get-paperspace *doc*)) (vla-get-modelspace *doc*))))) (setq *a2f_Uni 2)) (or *a2f_Pre (setq *a2f_Pre 0)) (or *a2f_Con (setq *a2f_Con 1.)) (or *a2f_Hgt (setq *a2f_Hgt (getvar 'TEXTSIZE))) (setq *a2f_Rot 0.)) (or *a2f_Suf (setq *a2f_Suf "m2")) (mapcar (function set) '(*a2f_Pre *a2f_Con *a2f_Hgt *a2f_Suf) (mapcar (function (lambda (ini foo msg x) (and ini (initget ini)) (cond ((and (setq tmp ((eval foo) (strcat "\n" msg ": "))) (/= "" tmp)) tmp) (x)))) (list 4 6 6 nil) '(GetInt GetReal GetDist GetString) '("Specify Precision" "Specify Conversion Factor" "Specify Text Height" "Specify Suffix") (list *a2f_Pre *a2f_Con *a2f_Hgt *a2f_Suf))) (while (progn (setq ent (car (entsel "\n>> Pick Hatch >>"))) (cond ((eq 'ENAME (type ent)) (if (and (eq "AcDbHatch" (vla-get-ObjectName (setq obj (vlax-ename->vla-object ent)))) (vlax-property-available-p obj 'Area)) (if (setq pt (getpoint "\nPick Point for Field: ")) (progn (setq uFlag (not (vla-StartUndoMark *doc*))) (setq tObj (vla-AddMText *spc* (vlax-3D-point pt) 0.0 (strcat "%%"))) (mapcar (function (lambda (property value) (vlax-put-property tObj property value))) '(Height Rotation Layer Color) (list *a2f_Hgt *a2f_Rot (vlax-get-property obj 'Layer) (vlax-get-property obj 'Color))) (setq uFlag (vla-EndUndoMark *doc*)) t) ;; repeat ) (princ "\n** Invalid Object Selected **")))))) (princ))
when I removed it- is working great
thanks for all your help Why did you change that part? All that means is that it wouldn't remember the last entry for default. I thought this is to set 'variables' and don't ask user for them- sorry I'm not good in lisp - I was just trying to modify it...with my poor knowledge about programming lisp.
I've changed few lines below as well- sorry I did lot of mess but is working
Thanks once again!
Must be modified also.
Regards
Why? ......
页:
[1]