乐筑天下

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

[编程交流] entmake - why "too few argumen

[复制链接]

57

主题

243

帖子

190

银币

后起之秀

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

铜币
285
发表于 2022-7-6 06:34:55 | 显示全部楼层 |阅读模式
Why "too few arguments"?
 
  1. (defun c:mci (cp)(setq cp (getpoint "\nCenter point:"))(entmake         (list(cons 0 "CIRCLE");;Entity(cons 62 5);;Color(cons 10 cp);;Center point(cons 40 2);;Radius))(princ))
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-6 06:50:52 | 显示全部楼层
  1. (defun c:mci ([color=blue][b]/[/b][/color] cp)
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-6 06:55:50 | 显示全部楼层
You defined function as it requires argument (cp) and c:mci is defined as command function so you can't supply that argument, for as soon as you execute it in standard way like any other command with Command: mci, no argument is passed to function... So change line (defun c:mci (cp) to (defun c:mci ( / cp ) as like you've written later in function parameter cp is variable user supplies while function runs... So cp isn't argument but variable that needs to be localized...
回复

使用道具 举报

35

主题

2471

帖子

2447

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
174
发表于 2022-7-6 07:06:35 | 显示全部楼层
I believe you were looking to localize the variables, not to have an argument (also, not valid for commands, only for functions):
  1. (defun c:mci ( [color=red]/[/color] cp)...
回复

使用道具 举报

57

主题

243

帖子

190

银币

后起之秀

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

铜币
285
发表于 2022-7-6 07:13:25 | 显示全部楼层
Thank you both. I appreciate your explanation.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 07:19:04 | 显示全部楼层
In addition to the above suggestions, you can also marginally improve the efficiency of your code by quoting expressions which need not be evaluated, e.g.:
 
  1. ([color=BLUE]defun[/color] c:mci ( [color=BLUE]/[/color] cp zv )   ([color=BLUE]setq[/color] zv ([color=BLUE]trans[/color] '(0.0 0.0 1.0) 1 0 [color=BLUE]t[/color])) [color=GREEN];; WCS Extrusion vector of UCS plane[/color]   ([color=BLUE]if[/color] ([color=BLUE]setq[/color] cp ([color=BLUE]getpoint[/color] [color=MAROON]"\nCenter: "[/color])) [color=GREEN];; Center point in UCS[/color]       ([color=BLUE]entmake[/color]           ([color=BLUE]list[/color]              '(00 . [color=MAROON]"CIRCLE"[/color]) [color=GREEN];; Entity Type[/color]              '(62 . 5) [color=GREEN];; Colour[/color]               ([color=BLUE]cons[/color] 10 ([color=BLUE]trans[/color] cp 1 zv)) [color=GREEN];; Center point in OCS[/color]              '(40 . 2.0) [color=GREEN];; Radius[/color]               ([color=BLUE]cons[/color] 210 zv) [color=GREEN];; Extrusion Vector in WCS[/color]           )       )   )   ([color=BLUE]princ[/color]))
I have also ensured the program will perform correctly in all UCS construction planes.
回复

使用道具 举报

57

主题

243

帖子

190

银币

后起之秀

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

铜币
285
发表于 2022-7-6 07:32:50 | 显示全部楼层
 
 
Lee, as always, efficient and master.
I appreciate that.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 07:42:17 | 显示全部楼层
You're very welcome teknomatika.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-10 18:45 , Processed in 0.859303 second(s), 79 queries .

© 2020-2025 乐筑天下

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