乐筑天下

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

[编程交流] insert block at distance & ang

[复制链接]

3

主题

8

帖子

5

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-6 07:41:56 | 显示全部楼层 |阅读模式
In this portion of a continuing program I'm putting together, a 4' block is inserted at a user point at a defined angle, then it is again inserted but this time 4' away at the same angle so that the two blocks form an 8' line. This is continued until the user stops the program. However, when the second block is inserted, it is rotated correctly but inserted somewhere north of where it is supposed to be. Obviously my polar calc or something is off:
 

[code](defun c:blockinsert ();;;;part 5 of overall program;;(setq p1 (getpoint "\nSELECT POINT: "));user inputs first point(setq p2 (getpoint "\nSELECT NEXT POINT: "));user inputs second point - for use in part 6 of program;(setq ang1 (angle p1 p2));get angle from user points(setq angreal (* 180.0 (/ ang1 pi)));convert from radians to degrees;(setq blockpt "@48
回复

使用道具 举报

35

主题

2471

帖子

2447

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
174
发表于 2022-7-6 08:08:51 | 显示全部楼层
Please pay attention that the POLAR function require the angle to be in radians, not in degrees:
  1. (setq nextpoint (polar p1 [color=red]ang1[/color] 48))
回复

使用道具 举报

35

主题

2471

帖子

2447

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
174
发表于 2022-7-6 08:22:10 | 显示全部楼层
I attempted some changes to your code, even though I don’t understand what you intend to do with the third attribute:
  1. (defun c:blockinsert( / oldCmdEcho point1st angleInsert nextItem )(setq oldCmdEcho (getvar "CMDECHO"))(setvar "CMDECHO" 0)(setq nextItem "Yes")(if (and (setq point1st    (getpoint "\nIndicate start point: "))         (setq angleInsert (getorient point1st "\nIndicate direction: "))) (while (not (or (initget "Yes No")                 (= nextItem "No")))  (command "_INSERT" "p4" point1st 1.0 1.0 (* (/ angleInsert pi) 180.0) "1" "category text" "??")  (setq point1st (polar point1st angleInsert 48))  (setq nextItem (getkword "Insert another one /No?")) ))(setvar "CMDECHO" oldCmdEcho)(princ))
回复

使用道具 举报

3

主题

8

帖子

5

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-6 08:50:26 | 显示全部楼层
That was the main problem (face palm!)
 
Thanks!
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-9 22:07 , Processed in 1.129787 second(s), 60 queries .

© 2020-2025 乐筑天下

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