land Posted August 22, 2023 Share Posted August 22, 2023 i need to insert a block on many polylines at one time . Quote Link to comment Share on other sites More sharing options...
fuccaro Posted August 22, 2023 Share Posted August 22, 2023 Just *any* point of the polylines? 1 Quote Link to comment Share on other sites More sharing options...
fuccaro Posted August 22, 2023 Share Posted August 22, 2023 (defun c:pp() (setq ssp (ssget '((0 . "LWPOLYLINE")))) (repeat (setq i (sslength ssp)) (setq p1 (ssname ssp (setq i (1- i))) a (assoc 10 (entget p1))) (entmake (list (cons 0 "INSERT") a (cons 2 "sample_block"))) ) ) Define a block named "sample_block", launch this lisp and select the polylines (all at once) 1 1 Quote Link to comment Share on other sites More sharing options...
mhupp Posted August 23, 2023 Share Posted August 23, 2023 If you want only closed polylines modify @fuccaro lisp. (setq ssp (ssget '((0 . "LWPOLYLINE")(70 . 1)))) 1 Quote Link to comment Share on other sites More sharing options...
land Posted August 23, 2023 Author Share Posted August 23, 2023 (edited) Worked well my friend thank you. But is it possible to modify it so that the block is defined within AutoCAD itself, so that when a command is given, it asks for the name of the block, and then it is executed?,and to be align on polylines at mid of this. @fuccaro 21 hours ago, fuccaro said: (defun c:pp() (setq ssp (ssget '((0 . "LWPOLYLINE")))) (repeat (setq i (sslength ssp)) (setq p1 (ssname ssp (setq i (1- i))) a (assoc 10 (entget p1))) (entmake (list (cons 0 "INSERT") a (cons 2 "sample_block"))) ) ) Edited August 23, 2023 by land Quote Link to comment Share on other sites More sharing options...
fuccaro Posted August 24, 2023 Share Posted August 24, 2023 (defun c:pp() (setq BlockName (getstring "Enter a block name: " )) (setq ssp (ssget '((0 . "LWPOLYLINE")))) (repeat (setq i (sslength ssp)) (setq p (entget (ssname ssp (setq i (1- i)))) a (assoc 10 p) b (assoc 10 (cdr (member a p))) c (mapcar '(lambda (x y) (* 0.5 (+ x y))) (setq a (cdr a)) (setq b (cdr b))) ) (entmake (list (cons 0 "INSERT") (cons 10 c) (cons 2 BlockName)(cons 50 (angle a b)))) ) ) Not sure what "align on polylines" means. I use the first two points of polylines to place the block. This could be wrong if the polyline starts with an arc... There is no error trap in this Lisp, so when prompted, enter a valid block name. 1 Quote Link to comment Share on other sites More sharing options...
land Posted August 24, 2023 Author Share Posted August 24, 2023 Worked well thank you. 2 hours ago, fuccaro said: (defun c:pp() (setq BlockName (getstring "Enter a block name: " )) (setq ssp (ssget '((0 . "LWPOLYLINE")))) (repeat (setq i (sslength ssp)) (setq p (entget (ssname ssp (setq i (1- i)))) a (assoc 10 p) b (assoc 10 (cdr (member a p))) c (mapcar '(lambda (x y) (* 0.5 (+ x y))) (setq a (cdr a)) (setq b (cdr b))) ) (entmake (list (cons 0 "INSERT") (cons 10 c) (cons 2 BlockName)(cons 50 (angle a b)))) ) ) Not sure what "align on polylines" means. I use the first two points of polylines to place the block. This could be wrong if the polyline starts with an arc... There is no error trap in this Lisp, so when prompted, enter a valid block name. Quote Link to comment Share on other sites More sharing options...
fuccaro Posted August 25, 2023 Share Posted August 25, 2023 Glad to help Quote Link to comment Share on other sites More sharing options...
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.