乐筑天下

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

[编程交流] More AutoCAD-like programs

[复制链接]

31

主题

170

帖子

139

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
155
发表于 2022-7-6 11:27:35 | 显示全部楼层 |阅读模式
I'm trying to modify some of my lisps to make them look more like standard autocad commands and I'm wondering if anybody has some examples of how to do it.
 
What I'm trying to do is replace the 5 user text inputs with one menu of options that can be changed by first selecting what you want changed, then entering what you want the new value to be.
 
I'm not sure if this explains it very well, so I'll give an example...
 
I have a lisp that makes creating consecutive 3-d faces faster and easier by hidding neccessary edges and saving the verticies of the previous face so that a couple of them can be used for the following face (eliminates having to click on points twice, once for each face).
 
When I activate this lisp it first asks what type of face (first, middle, or last), then type of array (rectangular or circular), after that it asks if you want to switch back and forth between selecting the 3rd point before the 4th point and selecting the 4th point before the 3rd point (makes surfacing larger areas alot faster by eliminating alot of the zoom and panning), then which layer (current, temp, or name), finally whether or not you want to hide the inside edges.
 
What I would like to do is create a menu of options, kinda like the menu that comes up when you do a PEDIT:
 
Enter an option [Close/Join/Width/Edit ertex/Fit/Spline/Decurve/Ltype gen/Undo]:
 
But have it  come up like this:
 
Enter and option [Face type/Array type/Oscillation/Layer/Hide Edges]:
 
And the user can change the settings he/she wants to, or just hit enter to continue the lisp.
 
I know how to make the prompt and strings, I just don't know how to loop back to the original prompt once a setting is changed.
 
Any help would be greatly appriciated.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 11:31:02 | 显示全部楼层
Perhaps make use of the WHILE function coupled with a few conditionals
回复

使用道具 举报

31

主题

170

帖子

139

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
155
发表于 2022-7-6 11:37:06 | 显示全部楼层
Any chance you've got an example, I learn easiest from examples.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 11:39:25 | 显示全部楼层
Silly example:
 
  1. (defun c:test (/ tot choice egg bac) (setq tot 0)  (while   (progn     (initget "Checkout Eggs Bacon")     (setq choice (getkword "\nWhat you wanna do? [Checkout/Eggs/Bacon]  : "))     (cond (  (or (eq "Checkout" choice)                  (not choice))              (princ (strcat "\nTotal = £" (itoa tot))) nil)           (  (eq "Eggs" choice)              (if (setq egg (getint "\nHow Many Eggs do you want? : "))                (setq tot (+ tot (* 2 egg))))              t)           (t (if (setq bac (getint "\nHow Many rashers of Bacon? : "))                (setq tot (+ tot (* 3 bac))))            t)))) (princ))
回复

使用道具 举报

31

主题

170

帖子

139

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
155
发表于 2022-7-6 11:41:28 | 显示全部楼层
lol, didn't mean you had to write it up, but I appriciated it... so what did you have for breakfast this morning?
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 11:43:57 | 显示全部楼层
lol neither eggs or bacon actually
 
This may be a more intuitive approach to follow:
 
  1. (defun c:test (/ tot choice egg bac ExitFlag) (setq tot 0) (while (not ExitFlag)   (initget "Checkout Eggs Bacon")   (setq choice (getkword "\nWhat you wanna do? [Checkout/Eggs/Bacon]  : "))   (cond (  (or (eq "Checkout" choice)                (not choice))            (princ (strcat "\nTotal = £" (itoa tot)))            (setq ExitFlag t))         (  (eq "Eggs" choice)            (if (setq egg (getint "\nHow Many Eggs do you want? : "))              (setq tot (+ tot (* 2 egg)))))         (t (if (setq bac (getint "\nHow Many rashers of Bacon? : "))              (setq tot (+ tot (* 3 bac))))))) (princ))
回复

使用道具 举报

31

主题

170

帖子

139

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
155
发表于 2022-7-6 11:48:18 | 显示全部楼层
I know in this case it works fine to do it the way you did, but would it make sense to change:
 
  1. (t (if (setq bac (getint "\nHow Many rashers of Bacon? : "))              (setq tot (+ tot (* 3 bac)))))))
 
To:
 
  1. (  (eq "Bacon" choice)            (if (setq bac (getint "\nHow Many rashers of Bacon? : "))              (setq tot (+ tot (* 3 bac)))))))
 
I didn't know if this would be easier to understand if you came back to your program and needed to make a change a couple years down the road.
 
Also what does the "(t " this line do:
 
  1. (t (if (setq bac (getint "\nHow Many rashers of Bacon? : "))
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 11:49:52 | 显示全部楼层
 
Perhaps, the responses are controlled by the initget function, so it makes no difference.
 
 
It ensures the last condition is met.
回复

使用道具 举报

31

主题

170

帖子

139

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
155
发表于 2022-7-6 11:54:23 | 显示全部楼层
gotcha, thanks for you help. Btw, if I ever make it accross the lake to London, I'm buying you a beer.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 11:57:33 | 显示全部楼层
You're welcome, thanks
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-6 02:12 , Processed in 0.653016 second(s), 72 queries .

© 2020-2025 乐筑天下

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