你好
我试着做一个lisp,它贯穿所有的行,并按颜色排序,所以最重的颜色最终位于顶部。
如果有行要移动,但选择为空(例如图形中不存在绿线),则脚本会停止并等待选择,但我希望它这样做
如果没有线路,请继续前进。
这是为了清理从Revit导出的dwg,因此有时需要对所有颜色进行排序,有时是3或4,具体取决于导出的图形。
- (defun ssfilter-by-color (color / lay layers)
- ;; Get all the layer names whi?ch are set to the color
- (setq lay (tblnext "LAYER" t) ;Get the 1st layer
- layers "" ;Initialize the layer names filter string
- )
- (while lay ;Step through all layers
- ;; Check if current layer is set to color
- (if (= (cdr (assoc 62 lay)) color)
- (setq layers (strcat "," (cdr (assoc 2 lay)) layers)) ;Add to filter string
- )
- (setq lay (tblnext "LAYER")) ;Get the next layer
- )
- (if (= layers "")
- (list (cons 62 color))
- (list '(-4 . "<OR")
- '(-4 . "<AND")
- (cons 8 (substr layers 2))
- '(62 . 256)
- '(-4 . "AND>")
- (cons 62 color)
- '(-4 . "OR>")
- )
- )
- )
- (sssetfirst nil (ssget "_x" (ssfilter-by-color 7))) ;;nr=indexcolor
- (command "_draworder" "_B")
- (sssetfirst nil (ssget "_x" (ssfilter-by-color 3)))
- (command "_draworder" "_B")
- (sssetfirst nil (ssget "_x" (ssfilter-by-color 1)))
- (command "_draworder" "_B")
- (sssetfirst nil (ssget "_x" (ssfilter-by-color 4)))
- (command "_draworder" "_B")
- (princ)
|