mac26 Posted March 2, 2022 Posted March 2, 2022 Below is the code snippet that has me scratching my head. When the routine executes the "-insert" command all goes will until it is supposed to evaluate the three attributes, at that point it crashes. This is what is shown at the command line: (2.90716e+06 794227.0)-insert Enter block name or [?] <Map_Survey_Point>: Map_Survey_Point. If I do this:(command "-insert" "Map_Survey_Point" x_y "" "" "" it will ask for the three attributes and if I put in the variables it will insert the block with the variable names not the values. I have done this many times before in different applications and it has always worked. Here are the results of the lst setq: _$ lst (89 2.90716e+06 794227.0 45.04 BLDGCOR) _$ desc BLDGCOR _$ elev 45.04 _$ pntnum 89 any help would be appreciated. thanks (setq lst (read (strcat "(" d ")")) pntnum (nth 0 lst) x (nth 1 lst) y (nth 2 lst) elev (nth 3 lst) desc (nth 4 lst) x_y (list x y) ) (command "-insert" "Map_Survey_Point" x_y "" "" "" desc elev pntnum) Quote
mhupp Posted March 2, 2022 Posted March 2, 2022 might be how your building your list from d (setq pntnum (nth 0 d) x (nth 1 d) y (nth 2 d) elev (nth 3 d) desc (nth 4 d) ) (command "-insert" "Map_Survey_Point" (list x y) "" "" "" desc elev pntnum) Quote
Steven P Posted March 2, 2022 Posted March 2, 2022 If I was checking this I would look at your (command "-insert" "Map_Survey_Point" x_y "" "" "" desc elev pntnum) line Perhaps print to screen everything it is saying - you have probably done this? and then you can see what it is doing a bit more clearly something like (princ "\n x_y: ") (princ x_y) (princ "\n desc: ") (princ desc) (princ "\n elev: ") (princ elev) (princ "\n pntnum: ") (princ pntnum) (princ "\n") Also might be worth a check that the block is loaded into the drawing file too - probably is of course, but as an error check (if (tblsearch "block" "Map_Survey_Point") (progn (princ "Yes - So Do Something") ) ;end progn (princ "Block doesn't exist in this drawing") ) ; end if I put this together just to check (defun c:testthis ( / ) (setq MyBlock "Map_Survey_Point") (setq lst (list 89 2.90716e+06 794227.0 45.04 BLDGCOR)) (setq pntnum (nth 0 lst) x (nth 1 lst) y (nth 2 lst) elev (nth 3 lst) desc (nth 4 lst) x_y (list x y) ) (princ "\n x_y: ") (princ x_y) (princ "\n desc: ") (princ desc) (princ "\n elev: ") (princ elev) (princ "\n pntnum: ") (princ pntnum) (if (tblsearch "block" MyBlock) (progn (command "-insert" MyBlock x_y "" "" "" desc elev pntnum) ) ;end progn (princ "Block doesn't exist in this drawing") ) ; end if ) The only thing it isn't checking is how you make lst.. and if it doesn't work then that is your problem 1 Quote
Steven P Posted March 2, 2022 Posted March 2, 2022 (Oh, not sure about your block I tried this with a fairly basic block, not dynamic or anything and (command "-insert" ....) only wants block name, insert point, X scale, Y scale and rotation, doesn't want desc, elev and pntnum - AutoCAD 2022, BricsCAD and others might be different) Quote
mhupp Posted March 2, 2022 Posted March 2, 2022 If you insert a block with attributes it should prompt what to input for each attribute. Prompt <Value>: Test 1 Quote
BIGAL Posted March 2, 2022 Posted March 2, 2022 Do you have 3 or more attributes in your block ? Without dwg no idea. Quote
Steven P Posted March 3, 2022 Posted March 3, 2022 11 hours ago, mhupp said: If you insert a block with attributes it should prompt what to input for each attribute. Prompt <Value>: Test Thanks MHUPP, I just used a very simple block from a drawing I had loaded Quote
ronjonp Posted March 3, 2022 Posted March 3, 2022 Another way to do this is set ATTREQ to 0 then fill in the attributes after insertion: (defun _putatt (e tag val) (vl-catch-all-apply 'setpropertyvalue (list e tag val)) ) (_putatt (entlast) "XYZ" "123") 1 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.