Dayananda Posted March 11, 2020 Posted March 11, 2020 In my block there is a only one circle included addition to other entities . After inserting the block I need to find out the center co-ordinates of that circle. (setq en1(entlast)) Quote
Emmanuel Delay Posted March 11, 2020 Posted March 11, 2020 (edited) Try this Command FIB (for Find In Block), select block ... It will print the insert point of the circle within the block, and outside the block (see if this works) (vl-load-com) ;; iterates through the items inside a block. Returns the searched item (for example "CIRCLE") (DEFUN find_in_block (blkname tag / od_ent res) (SETQ od_ent (TBLOBJNAME "BLOCK" blkname )) (WHILE (SETQ od_ent (ENTNEXT od_ent)) (if (= tag (cdr (assoc 0 (entget od_ent)))) (setq res od_ent) ) ) res ) (defun geteffectivename ( ent / ) (vla-get-Effectivename (vlax-ename->vla-object ent)) ) (defun c:fib ( / ent blkname subent ip_ins ang_ins ip ang sc dist) (setq ent (car (entsel "\nSelect block: "))) ;;(setq blkname (cdr (assoc 2 (entget ent)))) (setq blkname (geteffectivename ent)) (setq subent (find_in_block blkname "CIRCLE")) ;; get the Insert Point (princ "\nInsert point of the circle inside the block: ") (princ (setq ip_ins (cdr (assoc 10 (entget subent))))) (setq ang_ins (angle (list 0.0 0.0 0.0) ip_ins)) ;; now let's add that to where the block was inserted, including rotation and scale (setq ip (cdr (assoc 10 (entget ent)))) (setq ang (cdr (assoc 50 (entget ent)))) (setq sc (cdr (assoc 41 (entget ent)))) ;; I will assume uniform scale (princ "\nInsert point of the circle outside the block: ") (princ (polar ip (+ ang ang_ins) (* sc (distance (list 0.0 0.0 0.0) ip_ins) ) ) ) (princ) ) Edited March 11, 2020 by Emmanuel Delay 1 Quote
Dayananda Posted March 12, 2020 Author Posted March 12, 2020 18 hours ago, Emmanuel Delay said: Try this Command FIB (for Find In Block), select block ... It will print the insert point of the circle within the block, and outside the block (see if this works) Thanks It is working. (vl-load-com) ;; iterates through the items inside a block. Returns the searched item (for example "CIRCLE") (DEFUN find_in_block (blkname tag / od_ent res) (SETQ od_ent (TBLOBJNAME "BLOCK" blkname )) (WHILE (SETQ od_ent (ENTNEXT od_ent)) (if (= tag (cdr (assoc 0 (entget od_ent)))) (setq res od_ent) ) ) res ) (defun geteffectivename ( ent / ) (vla-get-Effectivename (vlax-ename->vla-object ent)) ) (defun c:fib ( / ent blkname subent ip_ins ang_ins ip ang sc dist) (setq ent (car (entsel "\nSelect block: "))) ;;(setq blkname (cdr (assoc 2 (entget ent)))) (setq blkname (geteffectivename ent)) (setq subent (find_in_block blkname "CIRCLE")) ;; get the Insert Point (princ "\nInsert point of the circle inside the block: ") (princ (setq ip_ins (cdr (assoc 10 (entget subent))))) (setq ang_ins (angle (list 0.0 0.0 0.0) ip_ins)) ;; now let's add that to where the block was inserted, including rotation and scale (setq ip (cdr (assoc 10 (entget ent)))) (setq ang (cdr (assoc 50 (entget ent)))) (setq sc (cdr (assoc 41 (entget ent)))) ;; I will assume uniform scale (princ "\nInsert point of the circle outside the block: ") (princ (polar ip (+ ang ang_ins) (* sc (distance (list 0.0 0.0 0.0) ip_ins) ) ) ) (princ) ) 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.