乐筑天下

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

[编程交流] Getdist - What is wrong?

[复制链接]

57

主题

243

帖子

190

银币

后起之秀

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

铜币
285
发表于 2022-7-6 08:07:26 | 显示全部楼层 |阅读模式
What is wrong with this code?
 
  1. (setq pnt1 (getpoint "\nPoint 1"))(setq pnt2 (getpoint "\nPoint 2"))(setq disth (getdist '(pnt1 pnt2)))(setq ncol (getint "\nNº Columns"))(setq disth (/ disth ncol))
回复

使用道具 举报

35

主题

2471

帖子

2447

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
174
发表于 2022-7-6 08:22:32 | 显示全部楼层
The GETDIST function allows you to get a distance dynamically on screen:
 
  1. (if (setq pnt1 (getpoint "\nPoint 1"))(setq disth (getdist pnt1 "\nPoint 2")))
 
To calcute distance between two point use DISTANCE:
 
  1. (if (and (setq pnt1 (getpoint "\nPoint 1"))        (setq pnt2 (getpoint "\nPoint 2")))(setq disth (distance pnt1 pnt2)))
 
Regards,
Mircea
回复

使用道具 举报

57

主题

243

帖子

190

银币

后起之秀

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

铜币
285
发表于 2022-7-6 08:42:49 | 显示全部楼层
Tanks Mircea,
However in the AutoCad Help these examples are presented:
 
  1. (setq dist (getdist)) (setq dist (getdist '(1.0 3.5))) (setq dist (getdist "How far ")) (setq dist (getdist '(1.0 3.5) "How far? "))
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 08:45:45 | 显示全部楼层
getdist will prompt the user to pick one or two points and return the distance between them, it requires a string argument (prompt message) and optional base point for the distance - you are supplying it with a quoted list of two symbols.
 
Essentially, there are two ways you can approach this:
 
1) getpoint - getpoint - distance:
 
  1. (setq p1 (getpoint "\nPoint 1: "))(setq p2 (getpoint "\nPoint 2: "))(setq di (distance p1 p2))
2) getpoint - getdist:
 
  1. (setq p1 (getpoint "\nPoint 1: "))(setq di (getdist p1 "\nDistance: "))
Note that both of the above solutions do not account for null user input and will require some error trapping in this respect.
回复

使用道具 举报

57

主题

243

帖子

190

银币

后起之秀

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

铜币
285
发表于 2022-7-6 09:00:36 | 显示全部楼层
Tanks, Lee.
In fact what I want is to use distance value as the value set by the input of points 1 and 2. I understand.
回复

使用道具 举报

35

主题

2471

帖子

2447

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
174
发表于 2022-7-6 09:08:51 | 显示全部楼层
 
To match the help example you may write it like this:
  1. (setq coordX (getreal "\nCoordinate X of point 1: ")     coordY (getreal "\nCoordinate Y of point 1: "))(setq disth (getdist (list coordX coordY) "\nInput second point:"))
For sure this isn't practical at all, is just to help you understand.
 
Regards,
Mircea
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-9 09:35 , Processed in 0.584983 second(s), 64 queries .

© 2020-2025 乐筑天下

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