I have a block which consists of a circle with a single letter inside, and 2 attributes. I need to get the data for the circle, but I stepped through the entity using entnext, and I see the attributes come up, but no info on the circle before I get back to the block itself. . .
I read somewhere stepping through should give you info on ALL subentities. I would just use nentsel, but the routine starts by asking me to select 2 blocks, and if I have to go select the blocks again I might as well just do the whole operation manually.
Any help on how to automatically get the data for the circle subentity from the block would be appreciated.
Also, before I go to this issue, when I ran the following code, I was getting bad argument errors. I'm sure I am using WAY too many variables, I first tried running it without (RQX1 TQY1 LQX1 BQY1 RQX2 TQY2 LQX2 BQY2) and I got an error, so I thought maybe I would have to get the X and Y coordinate seperately then just stick that variable in the list XYZ to make it work. Not sure what's going on with it, still new to this and looking for a solution. .
Code:; Define the function (the program). (defun c:WIRE ( / ENT1 ENT2 INFO1 INFO2 SUB1 SUB2 RAD1 RAD2 RQX1 TQY1 LQX1 BQY1 RQX2 TQY2 LQX2 BQY2 RQ1 TQ1 LQ1 BQ1 RQ2 TQ2 LQ2 BQ2 OLDCE *error*) ; Save the current value of cmdecho then redefine it. (setq OLDCE (getvar "cmdecho")) (setvar "cmdecho" 1) (defun *error* (errmes) (princ (strcat "\nExecution of WIRE halted by the following error: " ERRMES)) (setvar "cmdecho" OLDCE) (setq *error* OLDERR) (prin1) ) ; GET a ENTITY from the user and store it in ENT1. (setq ENT1 (car (entsel "\nSelect the first block. "))) ; GET a ENTITY from the user and store it in ENT2. (setq ENT2 (car (entsel "\nSelect the last block. "))) ; EXTRACT the Insertion point from the entity ENT1 and store it in INFO1. (setq INFO1 (cdr (assoc 10 (entget ENT1)))) ; EXTRACT the Insertion point from the entity ENT2 and store it in INFO2. (setq INFO2 (cdr (assoc 10 (entget ENT2)))) ; GET the SUBENTITY of ENT1 and store it in SUB1. (At a loss for what code I need to do this). (setq SUB1 (nentsel (ENT1))) ; GET the SUBENTITY of ENT2 and store it in SUB2. (At a loss for what code I need to do this). (setq SUB2 (nentsel (ENT2))) ; GET the Radius of the first SUBENTITY and store it in RAD1. (setq RAD1 (cdr (assoc 40 (entget SUB1)))) ; GET the Radius of the last SUBENTITY and store it in RAD2. (setq RAD2 (cdr (assoc 40 (entget SUB2)))) ; CALCULATE the X coordinate for RQ1 and store it in RQX1. (setq RQX1 (+ (nth 0 INFO1) RAD1)) ; CALCULATE the Y coordinate for TQ1 and store it in TQY1. (setq TQY1 (+ (nth 1 INFO1) RAD1)) ; CALCULATE the X coordinate for LQ1 and store it in LQX1. (setq LQX1 (- (nth 0 INFO1) RAD1)) ; CALCULATE the Y coordinate for BQ1 and store it in BQY1. (setq BQY1 (- (nth 1 INFO1) RAD1)) ; CALCULATE the X coordinate for RQ2 and store it in RQX2. (setq RQX2 (+ (nth 0 INFO2) RAD2)) ; CALCULATE the Y coordinate for TQ2 and store it in TQY2. (setq TQY2 (+ (nth 1 INFO2) RAD2)) ; CALCULATE the X coordinate for LQ2 and store it in LQX2. (setq LQX2 (- (nth 0 INFO2) RAD2)) ; CALCULATE the Y coordinate for BQ2 and store it in BQY2. (setq BQY2 (- (nth 1 INFO2) RAD2)) ; GET the RIGHT QUADRANT of the first entity and store it in RQ1. (setq RQ1 (list (RQX1) (nth 1 INFO1) 0.0)) ; GET the TOP QUADRANT of the first entity and store it in TQ1. (setq TQ1 (list (nth 0 INFO1) (TQY1) 0.0)) ; GET the LEFT QUADRANT of the first entity and store it in LQ1. (setq LQ1 (list (LQX1) (NTH 1 INFO1) 0.0)) ; GET the BOTTOM QUADRANT of the first entity and store it in BQ1. (setq BQ1 (list (nth 0 INFO1) (BQY1) 0.0)) ; GET the RIGHT QUADRANT of the last entity and store it in RQ2. (setq RQ2 (list (RQX2) (nth 1 INFO2) 0.0)) ; GET the TOP QUADRANT of the last entity and store it in TQ2. (setq TQ2 (list (nth 0 INFO2) (TQY2) 0.0)) ; GET the LEFT QUADRANT of the last entity and store it in LQ2. (setq LQ2 (list (LQX2) (NTH 1 INFO2) 0.0)) ; GET the BOTTOM QUADRANT of the last entity and store it in BQ2. (setq BQ2 (list (nth 0 INFO2) (BQY2) 0.0)) ; Reset "cmdecho" to previous value. (setvar "cmdecho" OLDCE) ; Exit quietly (no return value.) (prin1) )


Reply With Quote
