使用此
- (setq obj (vlax-ename->vla-object (car (entsel))))
- (vla-GetBoundingBox obj 'minpoint 'maxpoint)
- (setq minpt (vlax-safearray->list minpoint))
- (setq maxpt (vlax-safearray->list maxpoint))
这样可以找到块的角。然后冲破障碍。使用co-ords可以创建多段线的选择集,然后找到其中的文本。
现在,用文本作为属性(如tag1 tag2等)制作一个pline块,并将属性值填充到文本值中。
唷!
中间需要很多代码。
一个开始。
- (setq sspl (ssget "CP" (list minpt maxpt)))
- ; Text in polygons
- ; By Alan H may 2013
- (vl-load-com)
- (defun getcoords (ent)
- (vlax-safearray->list
- (vlax-variant-value
- (vlax-get-property
- (vlax-ename->vla-object ent)
- "Coordinates"
- )
- )
- )
- )
- (defun co-ords2xy ()
- ; 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 co-ords)(nth (+ I 1) co-ords) ))
- (setq coordsxy (cons xy coordsxy))
- (setq I (+ I 2))
- ) ; end repeat
- ) ; end defun
- (setq fname (strcat "c:/alan/" (getstring "\nEnter file name ")))
- (setq fout (open fname "w"))
- (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 numb3 (length co-ords))
- (setq z numb3)
- (setq ansco-ords "")
- (repeat numb3
- (setq ansco-ords (strcat ansco-ords (rtos (nth (setq z (- z 1)) co-ords) 2 3 ) " " ))
- )
- (setq ans (strcat "Pline " ansco-ords))
- (write-line ans fout)
- (setq ansco-ords "")
- (setq ss (ssget "WP" coordsxy (list (cons 0 "Text,Mtext")))) ; selection set of text within polygon
- (if (= ss nil)
- (princ "\nnothing inside")
- (progn
- (setq coordsxy nil) ; reset for next time
- (setq numb2 (sslength ss))
- (setq y numb2)
- (repeat numb2
- (setq anstext (vlax-get-property (vlax-ename->vla-object (ssname ss (setq y (- y 1)))) "Textstring"))
- (princ anstext) ; change to write text to file
- (write-line (strcat "text " anstext) fout)
- (princ "\n")
- ) ; end repeat2
- (setq ss nil) ; reset for next poly
- )
- )
- ) ; end repeat1
- (close fout)
- (princ)
|