lisp 如何取矩形的长和宽数据

lisp 如何取矩形的长和宽数据,第1张

(defun C:TE ( / LL)

(SETVAR "CMDECHO" 0)

(command "undo" "Be")

(setq ll (vla-get-Length (vlax-ename->vla-object (CAR (ENTSEL)))));;;;;;;;;;;;;;;;得到所选图元的长度

(vl-cmdf "line" (getpoint "\n指定位置画一条等长的线的基点:" ) (strcat "@" (rtos (/ ll 20)) ",0") "")

(command "undo" "e")

(COMMAND "REGEN")

(princ)

)

(PROMPT "即取出矩形的长边和高的数据来在指定位置画一条等长的线")

(PRIN1)

;;;;;;此程序简陋,没有检查对象是否是矩形的函数,没有取出长边和高的数据

(defun c:aaa()

(setq cmd (getvar "cmdecho"))

(setvar "cmdecho" 0)

;;;;以下pa\ww\hh值须由用户输入

(setq pa (getpoint "\n左下角点:"))

(setq ww (getdist "\n宽度:"))

(setq hh (getdist "\n高度:"))

;;;;以下pb、pc、pd值须由程序依据pa、ww、hh计算得出

(setq pb (polar pa 0 ww))

(setq pc (polar pb (/ pi 2) hh))

(setq pd (polar pc pi ww))

(setq osm (getvar "osmode"))

(setvar "osmode" 0)

;;;;以下依据pa、pb、pc、pd画出矩形

(command "_pline" pa pb pc pd "c")

(setvar "osmode" osm)

(setvar "cmdecho" cmd)

(princ)

)

;试用以下程序

(defun c:ccc()

(setq cm (getvar "cmdecho")

os (getvar "osmode")

)

(setvar "cmdecho" 0)

(command "_undo" "be")

(if (setq pt0 (getpoint "\左下角:"))

(if (setq pt1 (getcorner pt0 "\n右上角:"))

(progn

(setvar "osmode" 0)

(command "_rectang" pt0 pt1)

(while (setq pdbz (getint "\n要改变长宽吗<输入任意整数则改变,回车则结束>:"))

(setq dxy (mapcar '- pt1 pt0)

ent (entlast)

)

(if (= (setq cd (getreal (strcat "\n当前长度为:" (rtos (car dxy) 2 3) ", 请输入改动值:"))) nil)

(setq cd (car dxy))

)

(if (= (setq kd (getreal (strcat "\n当前宽度为:" (rtos (cadr dxy) 2 3) ", 请输入改动值:"))) nil)

(setq kd (cadr dxy))

)

(if (not (equal dxy (list cd kd)))

(command "_erase" ent ""

"_rectang" pt0 (mapcar '+ pt0 (list cd kd))

)

)

)

)

)

)

(command "_undo" "e")

(setvar "osmode" os)

(setvar "cmdecho" cm)

(princ)

)

试一试下面这段程序。

(defun c:rec_dia (/ a b c)

(setq a (getpoint "\n点选矩形内部的一点: "))

(command "boundary" a "")

(setq a (ssget "L")

a (ssname a 0)

a (entget a)

b (assoc 10 a)

)

(while b

(setq c (cons (cdr b) c)

a (cdr (member b a))

b (assoc 10 a)

)

)

(command "line" (nth 0 c) (nth 2 c) ""

"line" (nth 1 c) (nth 3 c) ""

)

)

以上就是关于lisp 如何取矩形的长和宽数据全部的内容,包括:lisp 如何取矩形的长和宽数据、lisp画矩形,写了这个代码,但是加载运行之后输入点和长宽高却无事发生,没有出现矩形,这是为什么、visual lisp写一个小程序 就在cad中画一个矩形 可以自由改动长宽高 先谢谢 了等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zz/9870836.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-02
下一篇 2023-05-02

发表评论

登录后才能评论

评论列表(0条)

保存