motee-z 发表于 2022-7-5 19:39:36

将多段线与另一条对齐

你好,朋友们
我想帮助对齐另一条多段线的顶点并标记这些顶点
如附图所示
谢谢
alignpoly。图纸

CAD89 发表于 2022-7-5 20:38:52

你好,motee-z,给你:
(defun c:proftodist (/ sourcepl targetpl vlpl polydata verli hdist cnt pointlst)
(vl-load-com)
(setq        sourcepl (car (entsel "\nSelect source polyline: ")) ; Get source polyline
targetpl (car (entsel "\nSelect target polyline: ")) ; Get target polyline
vlpl       (vlax-ename->vla-object targetpl)
                                ; Convert target polyline data to vla-object
polydata (entget sourcepl)        ; Get source polyline data
verli       (list)                        ; Define an empty list for vertices
)
(foreach v polydata                        ; Append vertices from source polyline
   (if        (= 10 (car v))
   (setq verli (append verli (list (cdr v))))
   )
)
(setq        verli (vl-sort verli
             (function (lambda (x1 x2) (< (car x1) (car x2))))
      )                                ; Sort vertices in ascending order on x axis
hdist (list)                        ; Create an empty list for horizontal distances
cnt   0
)                                        ; Set up a counter
(while (/= cnt (1- (length verli)))        ; Append cumulated horizontal distances
   (if        (= cnt 0)
   (setq
hdist (append hdist
              (list (- (car (nth (1+ cnt) verli)) (car (nth cnt verli))))
      )
   )
   (setq hdist (append hdist
                  (list
                  (+ (- (car (nth (1+ cnt) verli)) (car (nth cnt verli)))
                     (last hdist)
                  )
                  )
          )
   )
   )
   (setq cnt (1+ cnt))
)
(setq pointlst (list))                ; Create an emplty list for the resulting vertices
(foreach d hdist
   (setq pointlst (append pointlst (list (vlax-curve-GetpointatDist vlpl d))))
)
(foreach p pointlst                        ; Create the points along the target polyline
   (entmake
   (list
'(0 . "POINT")
'(100 . "AcDbEntity")
'(62 . 256)
(cons 8 "markchainage")
'(100 . "AcDbPoint")
(cons 10 p)
   )
   )
)
(princ)
)
 
如果这是你要找的,请告诉我!
 
关于CAD89

motee-z 发表于 2022-7-5 20:58:07

谢谢您的回复
干得好
但是,除了点之外,还可以创建具有顶点的多段线
谢谢
页: [1]
查看完整版本: 将多段线与另一条对齐