abhisjek 发表于 2022-7-5 20:25:41

Lisp查找矩形的L和B

嗨,今天的问候。
(任何人都可以)
我需要lisp来读取矩形的边,以便使我的对象平行于选定矩形的长边。
 
谢谢和问候,
@bhi。

ReMark 发表于 2022-7-5 20:47:35

你看过ALIGN命令了吗?

BIGAL 发表于 2022-7-5 21:25:24

另一个是UCS OB,如果说插入旋转为零,则文本的旋转为零,然后UCS W
 
如果你真的需要得到顶点,你需要看距离1-2和2-3来计算更长的距离,但即使这样,你也可能得到顶部而不是底部。
 
(defun plcords (/ ent obj plobs )
(vla-load-com)
(defun getcoords (ent)
(vlax-safearray->list
   (vlax-variant-value
   (vlax-get-property
   (vlax-ename->vla-object ent)
   "Coordinates"
   )
   )
)
)

(defun co-ords2xy ( / I)
; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z
(setq numb (/ (length co-ords) 2))
(setq I 0)
(repeat numb
(setq xy (list (nth (+ I 1) co-ords)(nth I co-ords) ))
(setq coordsxy (cons xy coordsxy))
(setq I (+ I 2))
) ; end repeat
)

(setq plobjs (ssget (list (cons 0 "lwpolyline"))))
(setq numb1 (sslength plobjs))
(setq x numb1)

(repeat numb1
(setq obj (ssname plobjs (setq x (- x 1))))
(setq co-ords (getcoords obj))
)
(co-ords2xy)

(setq inc (length coordsxy))
(repeat (/ inc2)
(setq x (rtos (nth (setq inc (- inc 1)) co-ords) 2 3 ))
(setq y (rtos (nth (setq inc (- inc 1)) co-ords) 2 3 ))
(setq xy (strcat x "," y ))
(princ xy)
(princ "\n ")
)
)
(plcords)

abhisjek 发表于 2022-7-5 21:28:29

谢谢你,先生,
页: [1]
查看完整版本: Lisp查找矩形的L和B