实体顺序问题,这个图中第一个是 dmx ,你试试下面的代码,就加了个 Reverse
- (defun c:tt (/ XD::List:DivedBy ss mat0 vmat lmat rmat)
- (defun XD::List:DivedBy (lst / ll nl)
- (while lst
- (if (/= (strcase (car (xdrx_getpropertyvalue (car lst) "Layer")))
- "DMX"
- )
- (setq ll (cons (car lst) ll))
- (setq nl (cons (reverse (cons (car lst) ll)) nl)
- ll nil
- )
- )
- (setq lst (cdr lst))
- )
- (reverse nl)
- )
- (if (setq ss (ssget '((0 . "Text,*polyline,line") ;_实体类型
- (8 . "shuju,zhix,dmx,lc,sjx,标高") ;_图层
- )
- ) ;_过滤出断面上的字 线
- )
- (progn
- (setq mat0 (xdrx_matrix_identity 3) ;_基本矩阵
- vmat (xdrx_matrix_settranslation mat0 '(0. 1.5 0.)) ;_向上偏移矩阵
- lmat (xdrx_matrix_settranslation mat0 '(-6.0 0. 0.)) ;_向右偏移矩阵
- rmat (xdrx_matrix_settranslation mat0 '(6. 0. 0.)) ;_向左偏移矩阵
- )
- (mapcar
- '(lambda (x)
- (mapcar '(lambda (a)
- (xdrx_entity_transform a vmat) ;_矩阵变换,就是移动
- )
- (list (nth 1 x) (nth 2 x) (nth 7 x) (nth 8 x)) ;_向上偏移的实体
- )
- (cond
- ((= (length x) 34) ;_两侧有放坡的是 34
- (xdrx_entity_transform (nth 15 x) lmat) ;_左侧
- (xdrx_entity_transform (nth 21 x) rmat) ;_右侧
- )
- ((= (length x) 33) ;_单侧放坡是 33
- (xdrx_entity_transform (nth 14 x) lmat)
- (xdrx_entity_transform (nth 20 x) rmat)
- )
- ((= (length x) 32) ;_两侧都不放坡是 32
- (xdrx_entity_transform (nth 13 x) lmat)
- (xdrx_entity_transform (nth 19 x) rmat)
- )
- (t)
- )
- )
- (XD::List:DivedBy
- (reverse (vl-sort
- (xdrx_pickset->ents ss) ;_选择集转为实体列表
- '(lambda (e1 e2)
- (< (cdr (assoc 5 (entget e1))) ;_ API 有 Bug ,用 Entget
- (cdr (assoc 5 (entget e2)))
- )
- )
- ) ;_按句柄排序,即实体生成顺序,
- );_这个图第一个实体是 dmx
- )
- )
- )
- )
- (princ)
- )
|