乐筑天下

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

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

[复制链接]

3

主题

10

帖子

7

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 17:03:52 | 显示全部楼层 |阅读模式
Short version:
 
I have a code that uses 4 commands to create 4 different lines. However, even if the points i give him are different, he sometimes places the lines over themselves.
 
I have used a prin1 to confirm the points i give him are really different, and they are, but for some reason the code places the lines over themselves randomly!
 
Long version: the code
 
  1. (defun c:fuste8 (/ 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)(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));;DADOS COMPLEMENTARES(setq dinttopo (- dsup esp)dintbase (- dinf esp))(setqaitopo (* dinttopo (/ (sin (/ PI ) (cos (/ PI )))aibase (* dintbase (/ (sin (/ PI ) (cos (/ PI ))));;Linhas extremas(setq p1esq (cons (- (car pin) (/ dsup 2)) (cons (cadr pin) (cons 0.0 '()))))(setq p2esq (cons (- (car pin) (/ dinf 2)) (cons (- (cadr pin) altura) (cons 0.0 '()))))(setq p1dir (cons (+ (car pin) (/ dsup 2)) (cons (cadr pin) (cons 0.0 '()))))(setq p2dir (cons (+ (car pin) (/ dinf 2)) (cons (- (cadr pin) altura) (cons 0.0 '()))))(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 '()))))(setq p2esq1 (cons (- (car pin) (/ aibase 2)) (cons (- (cadr pin) altura) (cons 0.0 '()))))(setq p1dir1 (cons (+ (car pin) (/ aitopo 2)) (cons (cadr pin) (cons 0.0 '()))))(setq p2dir1 (cons (+ (car pin) (/ aibase 2)) (cons (- (cadr pin) altura) (cons 0.0 '()))));;THESE LINES OVERLAP THE PREVIOUS ONES!(command "line" p1esq1 p2esq1 "") (command "line" p1dir1 p2dir1 "") (prin1 p2esq1)(prin1 "   ")(prin1 p2esq)(prin1 "   ")(prin1 p1esq1)(prin1 "   ")(prin1 p1esq)
回复

使用道具 举报

24

主题

1265

帖子

1028

银币

后起之秀

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

铜币
362
发表于 2022-7-5 17:07:12 | 显示全部楼层
Sounds like object snap is enabled while the routine is running.
回复

使用道具 举报

3

主题

10

帖子

7

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 17:10:26 | 显示全部楼层
you are absolutely right.. is it possible to disable osnap and re-enable it at the end of the routine?
回复

使用道具 举报

16

主题

99

帖子

83

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
80
发表于 2022-7-5 17:14:51 | 显示全部楼层
(setq osnapmode (getvar 'osmode)) ;this saves your current osnap settings
(setvar 'osmode 0) ;this turns off osnaps
 
; **your routine here
 
(setvar 'osmode osnapmode) ;this resets to your saved osnap settings
回复

使用道具 举报

3

主题

10

帖子

7

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 17:17:38 | 显示全部楼层
Thank you very much everyone
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 17:20:19 | 显示全部楼层
A bit more on osmode sometimes in a lisp you want certain snaps and do not want operator to use wrong ones so you just set your snaps to what you want then type osmode the number shown matches that combination. eg our normal working is osmode 47.
回复

使用道具 举报

171

主题

447

帖子

276

银币

中流砥柱

Rank: 25

铜币
860
发表于 2022-7-5 17:23:22 | 显示全部楼层
  1. (command "line" [color="red"]"non"[/color]p1esq1 "[color="red"]non[/color]"p2esq1 "") (command "line" [color="red"]"non[/color]"p1dir1 "[color="red"]non[/color]"p2dir1 "")
Put 'non"before the point
回复

使用道具 举报

3

主题

10

帖子

7

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 17:28:42 | 显示全部楼层
Yes, using osmode (value) seems pretty nice. But i've ran into other problem, if for some reason i cancel the code mid-execution, osnap will stay at 0. Is it possible to replace osmode back to the saved value if the user presses "esc"?
 
I might use "non", but i'm curious if a action on escape is possible with lisp
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

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

铜币
325
发表于 2022-7-5 17:29:48 | 显示全部楼层
 
Read post #7 in this thread: http://www.cadtutor.net/forum/showthread.php?98546-Lisp-circle
回复

使用道具 举报

3

主题

10

帖子

7

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 17:33:19 | 显示全部楼层
@Grrr
I've read the post, what's new about it?
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

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

© 2020-2025 乐筑天下

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