tuantrinhdp Posted May 16, 2022 Posted May 16, 2022 Hello everyone. I have object, i want to auto copy and move it to at vertex polyline. Please help me create lisp. Thanks for your help. TEST.dwg Quote
mhupp Posted May 16, 2022 Posted May 16, 2022 (edited) First make the red circle and hatch into a block with the insertion point in the center. This will ask you to Select a Block. Next Select entities: this can be one or multiple polylines you wish to place the selected block around. ;;----------------------------------------------------------------------;; ;; COPY B TO EACH VERTICY OF POLYLINE (defun C:FOO (/ blk SS e ent coords) (setvar 'cmdecho 0) (setq blkname (cdr (assoc 2 (entget (car (entsel "\nSelect Block")))))) (prompt "\nSelect Polyline") (if (setq SS (ssget ":L" '((0 . "*POLYLINE")))) (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) (setq coords (vl-remove-if 'not (mapcar (function (lambda (p) (if (= 10 (car p)) (cdr p)))) (entget ent)))) (foreach pt coords (vl-cmdf "_insert" blkname "_non" pt "" "" "") ) ) ) (setvar 'cmdecho 1) (princ) ) Edited May 16, 2022 by mhupp Code Updated 1 Quote
tuantrinhdp Posted May 16, 2022 Author Posted May 16, 2022 49 minutes ago, mhupp said: First make the red circle and hatch into a block with the insertion point in the center. This will ask you to Select a Block. Next Select entities: this can be one or multiple polylines you wish to place the selected block around. ;;----------------------------------------------------------------------;; ;; COPY BLOCK TO EACH VERTICY OF POLYLINE (defun C:FOO (/ blkname SS ent coords pt) (setvar 'cmdecho 0) (setq blkname (cdr (assoc 2 (entget (car (entsel "\nSelect Block")))))) (if (setq SS (ssget ":L" '((0 . "*POLYLINE")))) (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) (setq coords (vl-remove-if 'not (mapcar (lambda (p) (if (= 10 (car p)) (cdr p))) (entget ent)))) (foreach pt coords (vl-cmdf "_insert" blkname "_non" pt "" "" "") ) ) ) (setvar 'cmdecho 1) (princ) ) Thank you, but have error: bad function: #<SUBR @00000204b652d2c8 -lambda-> Quote
mhupp Posted May 16, 2022 Posted May 16, 2022 BricsCAD doesn't need the (function in front of lambda to run so i took it out. updated code. 1 Quote
Kajanthan Posted May 21, 2022 Posted May 21, 2022 Try This (defun Circle (cen rad) (entmakex (list (cons 0 "CIRCLE") (cons 10 cen) (cons 40 rad) (cons 8 "Dot") ) ) ) (defun c:dot ( / e g f) (command "_.Layer" "_Make" "Dot" "_Color" "1" "" "LType" "Continuous" "" "") (setq e (entsel "\nPlease choose an object: ")) (setq e (entget (car e))) (foreach f e (if (= (car f) 10) (progn (setq g (list (cadr f) (caddr f))) (setq g (trans g 0 1)) (Circle g 0.5) (command "_-hatch" "_S" "_L" "" "_LA" "Dot" "_P" "_S" "") ) ) ) ) 1 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.