标注的尺寸避让lisp_晓东CAD家园-论坛-A/VLISP-[LISP程序]:如何用Lisp模拟尺寸标注?-想用Lisp模拟尺寸标注,但是引用‘command’无法实现可选参数输入,请教高招!!谢谢...

该博客介绍了如何使用Lisp语言在CAD中模拟尺寸标注的过程。通过Lisp函数c:d,用户可以选择不同的方式指定延伸线起点,并进行旋转角度设置,以创建符合要求的尺寸标注。同时,代码还涉及到了命令行输入、实体选择、坐标转换和角度计算等操作。
摘要由CSDN通过智能技术生成

[FONT=courier new]

(defun c:d (/ p0 p1 p2 ang ent p10a p11a entst)

(setvar "cmdecho" 0)

(ai_undo_push)

(setvar "osmode" 47)

(mlay "dim" "3")

(initget 128)

(setq p0 (getpoint "\nSpecify first extension line origin or [Align/< Select line to align>] :")

entst (entlast)

)

(if (null p0)

(setq p0 "S")

)

(if (= (type p0) 'str)

(progn

(cond

((= (strcase p0) "S")

(setq ent (nentselp "\nSelect line :"))

(while (null ent)

(setq ent (nentselp "\nSelect line :"))

)

(while (/= (cdr (assoc 0 (entget (car ent)))) "LINE")

(setq ent (nentselp "Object selected is not line .\nSelect line :"))

)

(if (= (nth 3 ent) nil)

(progn

(setq p1 (trans (cdr (assoc 10 (entget (car ent)))) 0 1)

p2 (trans (cdr (assoc 11 (entget (car ent)))) 0 1)

ang (* 180 (/ (angle p1 p2) pi))

)

)

(progn

(matrix_b ent)

(setq p1 (trans p10a 0 1)

p2 (trans p11a 0 1)

ang (* 180 (/ (angle p1 p2) pi))

)

)

)

)

((= (strcase p0) "A")

(setq p1 (getpoint "\nSpecify first extension line origin :")

p2 (getpoint p1 "\nSpecify second extension line origin :")

ang (* 180 (/ (angle p1 p2) pi))

)

)

)

(princ "\nSpecify dimension line location :")

(command "_.dim1" "rotated" ang p1 p2 pause "")

)

(progn

(setq p1 (getpoint p0 "\nSpecify second extension line origin :"))

(princ "\nSpecify dimension line location :")

(command "dimlinear" p0 p1 pause)

)

)

(if (not (equal entst (entlast)))

(progn

(replace_ch "dim" 256 "bylayer" (entlast))

(entmod (subst

(cons 51 0)

(assoc 51 (entget (entlast)))

(entget (entlast))

)

)

(setq dimtxt (cdr (assoc 42 (entget (entlast)))))

(princ (strcat "\nDimension text = " (rtos dimtxt)))

)

)

(ai_undo_pop)

(setvar "cmdecho" 1)

(princ)

)

[/FONT]

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值