乐筑天下

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

[编程交流] Trying to create 2 lines, but

[复制链接]

66

主题

1552

帖子

1514

银币

后起之秀

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

铜币
325
发表于 2022-7-5 17:38:27 | 显示全部楼层
 
When user hits "Esc" the code exits with error, in that example an error-handler function is defined to reset the osmode variable:
  1.         (defun *error* ; define the error-handler function        (alert (strcat "\nError occured, now you are inside the *error* function \nand reseting the osmode variable!"))        (if osm (setvar 'osmode osm)) ; when your code crashes, it will check and reset the osmode value        (princ)); defun *error*
Try the code I posted there.
回复

使用道具 举报

16

主题

99

帖子

83

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
80
发表于 2022-7-5 17:41:49 | 显示全部楼层
Hi ng...
 
Grrr is trying to nudge you in the right direction.
 
Your code might look like this:
 
  1. (defun c:fuste8        (/          *error*  pin            altura   dsup     dinf         nlados          esp           e2            ss1             p1esq    p2esq         p1dir          p2dir           p1esq1   p2esq1   p1dir1   p2dir1         jorr          lest           ldir            dirint   esqint   teste         dinttopo dintbase aitopo   aibase   osm        ) ;_ end of / (defun *error* (msg)   (if        (and msg     (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))) ;_ end of and     (princ (strcat "\nError: " msg))   ) ;_ end of if   (if        osm     (setvar 'osmode osm)   ) ;_ end of if   (princ) ) ;_ end of defun (setq osm (getvar 'osmode)) (setvar 'osmode 0) (setq pin (getpoint "\nPonto de introducao: ")) (setq        altura (getint "\nAltura: ")dsup   (getint "\nDiametro superior: ")dinf   (getint "\nDiametro inferior: ") ;nlados (getint "\nNumero de lados: ")esp    (getint "\nEspessura: ")jorr   (/ (* (atan (- (/ dinf 2) (/ dsup 2)) altura) 180) PI) ) ;_ end of setq ;;DADOS COMPLEMENTARES (setq        dinttopo (- dsup esp)dintbase (- dinf esp) ) ;_ end of setq (setq   aitopo (* dinttopo (/ (sin (/ PI ) (cos (/ PI )))   aibase (* dintbase (/ (sin (/ PI ) (cos (/ PI ))) ) ;_ end of setq ;;Linhas extremas (setq        p1esq (cons (- (car pin) (/ dsup 2))            (cons (cadr pin) (cons 0.0 '()))      ) ;_ end of cons ) ;_ end of setq (setq        p2esq (cons (- (car pin) (/ dinf 2))            (cons (- (cadr pin) altura) (cons 0.0 '()))      ) ;_ end of cons ) ;_ end of setq (setq        p1dir (cons (+ (car pin) (/ dsup 2))            (cons (cadr pin) (cons 0.0 '()))      ) ;_ end of cons ) ;_ end of setq (setq        p2dir (cons (+ (car pin) (/ dinf 2))            (cons (- (cadr pin) altura) (cons 0.0 '()))      ) ;_ end of cons ) ;_ end of setq (command "line" p2esq p1esq "");(setq lest (entlast));(command "offset" esp lest p1dir "");(setq esqint (entlast)) (command "line" p2dir p1dir "");(setq ldir (entlast));(command "offset" esp ldir p1esq "");(setq dirint (entlast)) ;;Linha intermedia de 8 (setq        p1esq1 (cons (- (car pin) (/ aitopo 2))             (cons (cadr pin) (cons 0.0 '()))       ) ;_ end of cons ) ;_ end of setq (setq        p2esq1 (cons (- (car pin) (/ aibase 2))             (cons (- (cadr pin) altura) (cons 0.0 '()))       ) ;_ end of cons ) ;_ end of setq (setq        p1dir1 (cons (+ (car pin) (/ aitopo 2))             (cons (cadr pin) (cons 0.0 '()))       ) ;_ end of cons ) ;_ end of setq (setq        p2dir1 (cons (+ (car pin) (/ aibase 2))             (cons (- (cadr pin) altura) (cons 0.0 '()))       ) ;_ end of cons ) ;_ end of setq ;;THESE LINES OVERLAP THE PREVIOUS ONES! (command "line" p1esq1 p2esq1 "") (command "line" p1dir1 p2dir1 "")  (setvar 'osmode osm) (prin1 p2esq1) (prin1 "   ") (prin1 p2esq) (prin1 "   ") (prin1 p1esq1) (prin1 "   ") (prin1 p1esq)) ;_ end of defun
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

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

铜币
325
发表于 2022-7-5 17:42:53 | 显示全部楼层
Maybe the error-handling tutorial from LM would help more:
http://www.lee-mac.com/errorhandling.html
I don't know why I haven't posted it earlier. (as english is not my native language and I might be bad at explaining things).
回复

使用道具 举报

16

主题

99

帖子

83

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
80
发表于 2022-7-5 17:45:22 | 显示全部楼层
 
Yeah, that's where it helped me wrap my head around error trapping...
回复

使用道具 举报

16

主题

99

帖子

83

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
80
发表于 2022-7-5 17:48:28 | 显示全部楼层
Hey ng...
 
As I don't know the language, what is this lisp routine supposed to do?
回复

使用道具 举报

3

主题

10

帖子

7

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 17:53:20 | 显示全部楼层
@ PDuMont
 
It's Portuguese, it defines simple lines with a few parameters introduced.
 
Altough its simple, those are drawings used in the metal-mechanic industry for poles and high altitude towers. That is basically a front view of a pole, with a upper and bottom diameter and a height. I've recently joined a company on the sector and as I love programming I'm trying to help with drawings.
 
 
@Grrr
 
Sorry I didn't pay attention the your post on the link, i'll take a look at it now. Thanks very much
回复

使用道具 举报

171

主题

447

帖子

276

银币

中流砥柱

Rank: 25

铜币
860
发表于 2022-7-5 17:54:37 | 显示全部楼层
 
If you put "non"before the point that problem does not arise.
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 17:57:58 | 显示全部楼层
Whilst error trapping is the way to go we just use old fashioned type 47
 
This defun is part of our library autoload.
  1. (defun c:47 () (setvar "osmode" 47))
 
A better way is to have a library error trap routine and auto load it so only need 1 line in your code (myerror) with around 200+ routines I really should do this, for osmode, filedia and a couple more.
回复

使用道具 举报

24

主题

1265

帖子

1028

银币

后起之秀

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

铜币
362
发表于 2022-7-5 18:02:43 | 显示全部楼层
 
Or do it like this:
http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/osnap-off-in-a-lisp-routine/m-p/794975#M20633
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

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

铜币
325
发表于 2022-7-5 18:05:48 | 显示全部楼层
 
Thanks for posting this!
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-14 02:11 , Processed in 1.957829 second(s), 71 queries .

© 2020-2025 乐筑天下

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