Mountain_XD Posted May 28 Posted May 28 Please help me draw center line by Lisp. Thank you so much! Draw_Center_Line.dwg Quote
Nikon Posted May 28 Posted May 28 15 minutes ago, Mountain_XD said: Please help me draw center line by Lisp For polylines CPL.lsp Quote
Mountain_XD Posted May 28 Author Posted May 28 Thank you Nikon. your lisp is good, but i want to draw center lines only once. Quote
BIGAL Posted May 29 Posted May 29 (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. 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 May 29 by BIGAL Quote
ronjonp Posted June 6 Posted June 6 (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) ) Edited June 7 by ronjonp Quote
Recommended Posts
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.