Jump to content

Recommended Posts

Posted
15 minutes ago, Mountain_XD said:

Please help me draw center line by Lisp

For polylines

CPL.lsp

Posted

Thank you Nikon. your lisp is good, but i want to draw center lines only once.

Posted

Maybe ... 

 

 

Posted (edited)

Just an idea you drag over the pairs of lines, you find the correct pairs wont go into that now, then look for shortest and offset it to middle and change layer. So in image draw red pline then yellow pline color just for clarity.

 

image.png.963f63430e6438065cbb49a2d195a581.png

 

Not sure how your drawing the slab plan may be easier if using a lisp to add the make centerline as part of that code. Yes have draw slabs code.

 

 

Edited by BIGAL
  • 2 weeks later...
Posted

Thank you SLW210 . Your link is Well.

Posted (edited)

@Mountain_XD Here's some code for your first example without the closed boundary.

(defun c:foo (/ _m _srt a b el s)
  ;; RJP » 2025-06-06
  ;; Draws centerlines between parallel lines
  (defun _m (p1 p2) (mapcar '/ (mapcar '+ p1 p2) '(2. 2. 2.)))
  (defun _srt (p l) (car (vl-sort l '(lambda (r j) (< (distance p r) (distance p j))))))
  (cond	((setq s (ssget '((0 . "LINE"))))
	 (setq s (mapcar '(lambda (x)
			    (list (cdr (assoc 10 (setq el (entget x))))
				  (cdr (assoc 11 el))
				  (_m (cdr (assoc 10 el)) (cdr (assoc 11 el)))
			    )
			  )
			 (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
		 )
	 )
	 (while	(cadr s)
	   (setq a (car s))
	   (setq s (cdr s))
	   (setq s
		  (vl-sort s '(lambda (r j) (< (distance (last a) (last r)) (distance (last a) (last j)))))
	   )
	   (setq b (car s))
	   (entmakex (list '(0 . "LINE")
			   (cons 10 (_m (car a) (_srt (car a) (list (car b) (cadr b)))))
			   (cons 11 (_m (cadr a) (_srt (cadr a) (list (car b) (cadr b)))))
			   '(8 . "Import_Beams")
		     )
	   )
	   (grdraw (last a) (last b) 3)
	   (setq s (cdr s))
	 )
	)
  )
  (princ)
)

2025-06-06_16-48-46.gif.bf66d823c41c637deeca2f184fc71219.gif

 

Edited by ronjonp

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...