乐筑天下

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

[编程交流] Block Insert, Center and Auto

[复制链接]

1

主题

5

帖子

4

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 07:17:39 | 显示全部楼层 |阅读模式
I'm having trouble finishing this LISP. Can anyone help me out. The command line is telling me the command I'm entering 'roomtag' is unknown. It's probably something little but I can't seem to figure it out. Please help out if you can. Thanks!
 
  1. ;;;Place Room Tag in Middle of Room and Auto Fill 'x' and 'y' Attribute Values(defun c:RoomTag (/ pt1 pt3 rx ry pt5)(initget 1)(setq pt1 (getpoint "\nFirst Corner: "))(initget 1)(setq pt3 (getcorner "\nOpposite Corner: "))(setq rx (abs (- (car pt3)(car pt1))))(setq ry (abs (- (cadr pt3)(cadr pt1))))(setq pt5 ((+ rx pt1) (- ry pt3)))(command "_INSERT" "Tag_Room-Dim" pt5 "" "" pause pause rx ry "")(princ)
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-6 07:27:54 | 显示全部楼层
One issue ....
  1. (setq pt5 ([b]list [/b](+ rx pt1) (- ry pt3)))
 
I think you should add one more parenthesis at the end of the routine .
回复

使用道具 举报

1

主题

5

帖子

4

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 07:29:29 | 显示全部楼层
  1. [i][size=2];;;Place Room Tag in Middle of Room and Auto Fill 'x' and 'y' Attribute Values[/size][/i][i][size=2](defun c:RoomTag (/ pt1 pt3 rx ry pt5)[/size][/i][i][size=2](initget 1)[/size][/i][i][size=2](setq pt1 (getpoint "\nFirst Corner: "))[/size][/i][i][size=2](initget 1)[/size][/i][i][size=2](setq pt3 (getcorner pt1 "\nOpposite Corner: "))[/size][/i][i][size=2](setq rx ((- (car pt3)(car pt1))))[/size][/i][i][size=2](setq ry ((- (cadr pt3)(cadr pt1))))[/size][/i][i][size=2](setq pt5 (list (+ rx pt1) (+ ry pt1)))[/size][/i][i][size=2](command "_INSERT" "Tag_Room-Dim" pt5 "" "" pause pause "abs rx "x" abs ry" " ")[/size][/i][i][size=2](princ)[/size][/i][i][size=2])[/size][/i]
 
Thanks Tharwat, That got it off the ground. But now after I click the other corner of the room it gives me a 'bad function: 186.25'.
 
I think I need to clarify. I am trying to pick two opposite corners to a room and have the lisp automatically put in a block with attributes I've created and fill the 'room dimensions' value of the block with (x'-x'' x y'-y''). The little 'x' between the two dimensions values is plain text. So I also need to find out how to get the values it is giving me for the distances and convert them to architectural equivalents... 186.25 = 15'-6 1/4". And secondly I would like it to round to the nearest whole number. Thanks for any other help.
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-6 07:38:57 | 显示全部楼层
You have extra parenthesis in the two lines , one for the variable rx and one for ry .
 
You receive bad function because the numbers must be strings ( i am saying that without testing it ) .
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

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

铜币
211
发表于 2022-7-6 07:44:19 | 显示全部楼层
Note: With the command method, you need to consider the way "Tag_Room-Dim" is created (for scale) , ATTREQ & ATTDIA current Value
 
  1. (defun c:RoomTag (/ pt1 pt3 rx ry pt5)[b][color="blue"] (setq        atrq (getvar 'attreq)atd  (getvar 'attdia) ) (setvar 'Attreq 1) (setvar 'attdia 0)[/color][/b] (initget 1) (setq pt1 (getpoint "\nFirst Corner: ")) (initget 1) (setq pt3 (getcorner pt1 "\nOpposite Corner: ")) (setq rx (- (car pt3) (car pt1))) (setq ry (- (cadr pt3) (cadr pt1))) ;(setq pt5 (list (+ rx pt1) (+ ry pt1))) (command "_INSERT"   "Tag_Room-Dim" [b][color="blue"]  "_scale"   "1"[/color][/b]   [b][color="blue"](polar pt1 (angle pt1 pt3) (* (distance pt1 pt3) 0.5))[/color][/b]   ""   [color="blue"][b](strcat (rtos rx 4 0) "x" (rtos ry 4 0))[/b][/color] )[b][color="blue"]  (setvar 'Attreq atrq) (setvar 'attdia atd)[/color][/b] (princ))
回复

使用道具 举报

4

主题

2143

帖子

2197

银币

限制会员

铜币
-24
发表于 2022-7-6 07:50:00 | 显示全部楼层
jfklimek,
 
Please read the CODE POSTING GUIDELINES and edit your posts to include CODE TAGS!
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-6 07:52:39 | 显示全部楼层
Error trap to re-set the user settings would be very helpful and safer
回复

使用道具 举报

1

主题

5

帖子

4

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 07:56:57 | 显示全部楼层
 
roger that SLW210. I tried to go back and change the code I put previously in but it says I don't have privelages to make those changes. This will be adhered to from now on. I apologize.
回复

使用道具 举报

1

主题

5

帖子

4

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 08:06:17 | 显示全部楼层
pBe, Thanks! So I'll make this short since the passed three replies were erased because it took to long for me to reply! ahhh.
 
The code works, but I have to rearrange the three attributes in the block in order for the 'strcat' value to auto place. (It only auto places in the first attribute option). If it's not in the first attribute option, the following code skips any user input for the attributes entirely and places the 'strcat in the first value.
 
  1. (command "_INSERT"   "Tag_Room-Dim"   "_scale" "1"   (polar pt1 (angle pt1 pt3) (* (distance pt1 pt3) 0.5))   ""   pause   pause   (strcat (rtos rx 4 0) "x" (rtos ry 4 0)))
 
Ideally I'd like to have the attributes arrange so that it prompts me for the first two attribute values then auto fills the last one with 'strcat'. Is this possible?
 
The following code works with a rearrange block as spoken of above!
  1. (defun c:RoomTag\ (/ pt1 pt3 rx ry pt5) (setq        atrq (getvar 'attreq)atd  (getvar 'attdia) ) (setvar 'Attreq 1) (setvar 'attdia 0) (initget 1) (setq pt1 (getpoint "\nFirst Corner: ")) (initget 1) (setq pt3 (getcorner pt1 "\nOpposite Corner: ")) (setq rx (- (car pt3) (car pt1))) (setq ry (- (cadr pt3) (cadr pt1))) (command "_INSERT"   "Tag_Room-Dim"   "_scale" "1"   (polar pt1 (angle pt1 pt3) (* (distance pt1 pt3) 0.5))   ""   (strcat (rtos rx 4 0) "x" (rtos ry 4 0))) (setvar 'Attreq atrq) (setvar 'attdia atd) (princ))
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-6 08:11:08 | 显示全部楼层
Have the code auto fill all attributes.  After picking the two corners then ask for the two attributes it will accept a  if you want blank entry.
 
This way insert pt scale rot att1 att2 att3 no worry then about pausing.
 
  1. (setq pt3 (getcorner pt1 "\nOpposite Corner: "))(setq att1 (getstring "\nEnter att1"))(setq att2 (getstring "\nEnter att2"))
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-10 10:28 , Processed in 0.542657 second(s), 72 queries .

© 2020-2025 乐筑天下

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