#Attribute Insert
6 messages in this thread
Hello All,
A few messages back, I asked for some help on attribute's. I might
not have been clear enough in explaining the problem.
Here goes!! When a wblock containing multiple attributes is inserted
into an existing drawing, I would like a lisp routine to answer the
attribute questions.
I use a very simple lisp program, which includes the (setq filename
(open "somefile.dat" "r")) and (read-line filename) routine now to answer
these questions. Works great! "If it's not broke, don't fix it" may be the
real answer. However, I would prefer a looping routine to replace the
(read-line filename).
I have tried the "IF-THEN-ELSE" and "WHILE" and "REPEAT" commands but
apparently dont understand how to use them. Maybe the real question is "Can
a lisp routine answer attribute prompts?"
Anyway, can someone at least tell me if its possible to use a
function that includes a looping (read-line) to answer attribure prompts?
Will be most appreciative!!!!!!!!!!!!!!!!!!!!
Thanks,,,gragg
Jerry-I don't claim to be a lisp expert, but I blew the dust of an old
routine that I use quite frequently. It sounds like it accomplishes the
same things you're try to do, just a different application.
The routine takes user input and reads a file until there is a match, it
then assigns the valve to a variable which it uses as an attribute value in
a block insertion. Note the attdia is on for editing before final block
insertion. I think the core of the program could be used for what you're
trying to do.
I've uploaded the routine to you on Email, if you have any questions feel
free.
Dennis
Gragg – I think your question seems to be more one of how to do conditional
looping in AutoLISP.
In your case, the problem is that you must know *how many* times to repeat
the loop, and if this number of iterations is determined by the number of
attribute prompts that appear after inserting the block, then it will get
rather tricky.
What I would suggest is that you turn attribute prompting off (via a call to
(setvar "attreq" 0)), and then go back and replace the values of the variable
attributes using AutoLISP's (entmod) and (entnext) functions. If you need
help with these, then just hollar.
-TonyT.
Tony – Why would you suggest that he turn of attreq to do his filling in
of attributes. I'm not questioning your integrity or ability or anything
like that. I just want to learn.
Mike J.
Mike – Feel free to question my suggestions, integrity, or ability anytime you
wish…. I can hack it…<g>
If you re-read my comment to him, I suggested that he insert the block first,
and then modify the new attributes using (ENTMOD), meaning that he doesn't
need to respond to any attribute prompts, and since it is difficult for any
program to *predict* how many attributes values will be prompted for, that is
why Autodesk invented ATTREQ to begin with, and that's why I suggested that he
use that approach.
If I'm not clear on this, then please tell me and I'll try to explain further.
-TonyT.
Tony – Thanks. I see. I was thinking that you would always know the
numberof atts. There's that "always" word. That should have clued me that
I was in error. With your method you would not necessarily have to modify
the code if the number of attributes in the block changed. Good idea.
Mike J.