备注看起来像mline的原始中心线,不确定mline的“co ords”给出了什么,也需要检查顶部、底部和零。
- ; converts mline to pline note uses mline vertices does not take
- ; into account top or bottom offset
- ; By Alan H Aug 2017
- (defun c:test ( / co-ords ent co-ordsxy xy oldsnap)
- (setq oldsnap (getvar "osmode"))
- (setq ss (ssget (list (cons 0 "Mline")))) ; pick only mlines
- (if (/= ss nil)
- (progn
- (repeat (setq x (sslength ss))
- (setq ent (ssname ss (setq x (- x 1)))) ; get mlines
- (setq co-ords
- (vlax-safearray->list
- (vlax-variant-value
- (vlax-get-property
- (vlax-ename->vla-object ent) ; get co-ordinates of mline
- "Coordinates"
- )
- )
- )
- )
- ; 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) 3)) ; mlines have a z value hence / 3
- (setq I 0)
- (repeat numb
- (setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) ))
- (setq co-ordsxy (cons xy co-ordsxy)) ; make a list of co-ordinates
- (setq I (+ I 3))
- )
- (setvar "osmode" 0)
- (command "_pline")
- (while (= (getvar "cmdactive") 1 )
- (repeat (setq y (length co-ordsxy))
- (command (nth (setq y (- y 1)) co-ordsxy)) ; read list of points
- )
- (command "")
- )
- (setq co-ordsxy nil) ; reset to do again
- (command "erase" ent "")
- )
- )
- )
- (setvar "osmode" oldsnap) ; reset snap mode
- )
|