You are here:

AutoCAD/Block with Attributes within AutoLisp

Advertisement


Question
Hallo,
I am Spiros from Greece.
I would like to know if there is a way to use the insertion of a Block with Attributes within an Autolisp Routine (an ATTDIA 1), without causin the routine to End !
This is the code I use :

(setvar "ATTDIA" 1)

(command "insert" Blockname "s" insertscale "r" 0)
(while (= (logand (getvar "CMDACTIVE") 2) 1)
(setvar "cmdecho" 1)
(command pause)
)

..... and it all works til the Block is inserted and the Attributes Dialog is filled, but then the Lisp ends !

I know that the value of 2 is not correct but I had to try something.
The fact is that I am trying to continou the LispRoutine after the insertion, for example with a follow up "alert" but it comes on BEFORE the insertion.
This is the code:

(setvar "ATTDIA" 1)
(command "insert" Blockname "s" insertscale "r" 0)
(while (= (logand (getvar "CMDACTIVE") 2) 1)
(setvar "cmdecho" 1)
(command pause)
)
(alert "pop")

I have also tried:

(command "insert" Blockname "s" insertscale "r" 0 pause) ;;;(or pause 2x)

Could you help me please ?

Thank you very mouch.  

Answer
The alert "pop" was interesting.  :)  Anyway, the last line made the most sense.  Nowhere else did you pause for user input on the insertion point.  This problem is probably the same reason  that I use the command line version of the INSERT command instead of the dialog version.  Since I have been using the command line version of insert in my routines, I have never missed having a dialog box come up with a list of prompts and a bunch of windows to fill with attribute values.  You don't have to do any mouse-clicking at the command line.

Try something like this:

(setq oad (getvar "attdia"))
(setvar "attdia" 0)
(setvar atval1 (getstring "\nPut first prompt here:  "))
(setvar atval2 (getstring "\nPut second prompt here:  "))
(command "_.insert" blockname pause "" "" "" atval1 atval2)
(setvar "attdia" oad)

This way you get prompted at the command line for the attribute values instead of in a dialog box.  Then you can continue your routine. If you want a space in the user input attribute value, then include a t after getstring:  
(setvar atvalX (getstring T "\nPut a prompt here:  "))


Keep in touch
Bill DeShawn
http://my.sterling.net/~bdeshawn  

AutoCAD

All Answers


Answers by Expert:


Ask Experts

Volunteer


Bill DeShawn

Expertise

I can address all 2-D questions and some 3-D questions. I do programming in AutoLISP if it doesn`t involve solid modeling. I can also address menu customization issues and can help you find answers to questions I can`t answer by taking your question directly to Autodesk via their newsgroups.

Experience

I used to do electronic and mechanical design for a flat panel monitor manufacturer, and now I do architectural drafting for an architect. I did and do AutoLISP and menu customization and take pride in making my lisp routines to do the work exactly the way the client likes them done.

Publications
I had a routine published in CADENCE magazine (no longer in publication and taken over by CADALYST). Some of my routines are published on my website at http://my.sterling.net/~bdeshawn

©2012 About.com, a part of The New York Times Company. All rights reserved.