本帖最后由 Gu_xl 于 2012-3-31 14:07 编辑
回复 daidong013 的帖子
- (defun c:tt(/ os ss pl p1 p2)
- (setq os (getvar 'osmode))
- (setvar 'osmode 0)
- (setq ss (ssget '((0 . "insert"))))
- (if ss
- (progn
- (setq pl (GXL-GETSSBOX ss)
- p1 (car pl)
- p2 (cadr pl)
- ss (GXL-SEL-SS->LIST ss)
- )
- ;;;此处画一个圆,图块投影到园上排序
- (command "_pline" p1 "a" "s" (list (car p1) (cadr p2)) p2 "s" (list (car p2) (cadr p1)) p1 "")
- (setq en (entlast))
- (setq ss (vl-sort ss '(lambda (a b)
- (< (vlax-curve-getParamAtPoint en (vlax-curve-getclosestpointto en (gxl-dxf a 10)))
- (vlax-curve-getParamAtPoint en (vlax-curve-getclosestpointto en (gxl-dxf b 10)))
- )
- )
- )
- )
- (command "_pline")
- (mapcar 'command (mapcar '(lambda (X) (gxl-dxf x 10)) ss))
- (command "")
- (entdel en)
- )
- )
- (setvar 'osmode os)
- (princ)
- )
- ;; gxl-GetssBox 取得选择集的实体外矩形框
- (defun gxl-GetssBox (ss / maxpt maxptlst minpt minptlst obj x ss1)
- (setq ss1 (gxl-Sel-SS->List ss))
- (foreach x ss1
- (setq obj (vlax-ename->vla-object x))
- ;(setq minPt (vlax-make-safearray vlax-vbdouble '(0 . 2)))
- ;(setq maxPt (vlax-make-safearray vlax-vbdouble '(0 . 2)))
- (vla-GetBoundingBox Obj 'minpt 'maxpt) ; 得到包围框
- (setq minPt (vlax-safearray->list minPt))
- (setq maxPt (vlax-safearray->list maxPt))
- (setq minPtlst (append minPtlst (list minPt)))
- (setq maxPtlst (append maxPtlst (list maxPt)))
- ) ;_ 结束foreach
- (setq minPt (list (apply 'min (mapcar 'car minPtlst))
- (apply 'min (mapcar 'cadr minPtlst))
- 0
- ) ;_ 结束list
- ) ;_ 结束setq
- (setq maxPt (list (apply 'max (mapcar 'car maxPtlst))
- (apply 'max (mapcar 'cadr maxPtlst))
- 0
- ) ;_ 结束list
- ) ;_ 结束setq
- ;(command "rectang" minPt maxPt)
- (list minPt maxPt)
- ) ;_ 结束defun
- (defun gxl-Sel-SS->List (ss / i s )
- (if ss
- (repeat (setq i (sslength ss))
- (setq s (cons (ssname ss (setq i (1- i))) s))
- )
- )
- )
- ;;;==================================================================
- ;;;(gxl-dxf ent i )取出图元索引i对应的值
- ;;;==================================================================
- (defun gxl-dxf (ent i)
- (cond ((= (type ent) 'ename)
- (cdr (assoc i (entget ent)))
- )
- ((= (type ent) 'list)
- (cdr (assoc i ent))
- )
- ) ;_ if
- )
|