Jump to content

Align polyline on another one


motee-z

Recommended Posts

Hello motee-z, here you go:

(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)
)

 

Let me know if this is what you are looking for!

 

With regards CAD89

Link to comment
Share on other sites

thanks cad89 for your reply

thats good job

but can be creat polyline with vertices in addition to points

thanks

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...