乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 39|回复: 8

[编程交流] ** Error: Too many actual para

[复制链接]

6

主题

36

帖子

34

银币

初来乍到

Rank: 1

铜币
34
发表于 2022-7-6 10:38:16 | 显示全部楼层 |阅读模式
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
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 10:52:21 | 显示全部楼层
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?
回复

使用道具 举报

6

主题

36

帖子

34

银币

初来乍到

Rank: 1

铜币
34
发表于 2022-7-6 10:56:18 | 显示全部楼层
Hi Lee Mac,
 
Yes- it's one of your great lisps
Below I made the code highlighted in vlide in red:
 
  1. (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 (= [b][color=Red](vla-get-mspace *doc* :vlax-true)[/color][/b])                                (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 [And don't you dare pick anything else]  >>")))     (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!
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 11:02:43 | 显示全部楼层
Ah - that's a typo on my part - I should've spotted that
 
Please try this instead:
 
  1. (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 [And don't you dare pick anything else]  >>")))     (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))
回复

使用道具 举报

6

主题

36

帖子

34

银币

初来乍到

Rank: 1

铜币
34
发表于 2022-7-6 11:11:07 | 显示全部楼层
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
 
  1. (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)[b][color=Red])[/color][/b] (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.)[b][color=Red])[/color][/b] (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 [And don't you dare pick anything else]  >>")))     (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
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 11:18:12 | 显示全部楼层
Why did you change that part? All that means is that it wouldn't remember the last entry for default.
回复

使用道具 举报

6

主题

36

帖子

34

银币

初来乍到

Rank: 1

铜币
34
发表于 2022-7-6 11:30:18 | 显示全部楼层
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!
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-6 11:34:24 | 显示全部楼层
 
Must be modified also.
 
Regards
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 11:42:59 | 显示全部楼层
 
Why? ......
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-6 17:14 , Processed in 0.552496 second(s), 70 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表