Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autolisp pause when insert attributes

Status
Not open for further replies.

pheng

Electrical
Oct 4, 2005
2
I have created a program that will automatically insert a standardized drawing title, and then insert a north arrow with a specified direction. It works ok except that when lisp inserts "atitleft" and the user is prompted for the attribute title (txt), it will not allow for spaces between words. I've tried using pause instead of first using getstring-txt but that didn't work. Any ideas as how to allow for spaces when intering the title name?

(defun C:titlexft ()
(setq la (getvar "clayer"))
(command "blipmode" "on")
(command "layer" "s" "titletxt" "")
(setq lt (/ (getvar "ltscale") 30))
(setq scf (/ (getvar "dimscale") 96))
(setq pnt1 (getpoint "\nPick insertion point for bottom-left of text "))
(setq txt (getstring "\nDrawing Title: "))
(setq scl (getstring "\nDrawing Scale <20'>: "))
(setq tem (getstring "\nDrawing Template <SCALE: 1=>: "))
(command "insert" "atitleft" "s" lt pnt1 "" txt scl tem)
(setq pnt2x (- (CAR PNT1) (* 61 SCF)))
(setq pnt2y (+ (CADR PNT1) (* 18 SCF)))
(setq pnt2 (list pnt2x pnt2y))
(setq ang1 (getorient PNT2 "DIRECTION OF NORTH ARROW: "))
(setq ang2 (* (/ ANG1 PI) 180))
(setq pnt3 (polar pnt2 (+ ANG1 PI) (* 27 SCF)))
(command "insert" "anarrow" pnt2 scf "" ang2)
(command "insert" "anlogo" pnt3 scf "" "")
(command "layer" "s" la "")
(command "blipmode" "off")
)
 
Replies continue below

Recommended for you

In order to allow blanks with the getstring function the first optional argument should be non-nil. Thus:

(setq txt (getstring T "\nDrawing Title: "))

will allow you to enter a string with spaces in it.

I'm confused though on the following command:

command "insert" "atitleft" "s" lt pnt1 "" txt scl tem)

After the double quotes (which is saying you're accepting the current number for the rotation). The insert command is done. I assume your trying to put in values for attributes. But as near as I can tell that won't work. I'm using Acad 2002 so maybe something changed but I doubt it.
 
Thanks, that worked. As for the three values, I'm using A2000 & A2004 and it does seem to work as it is- in both versions. Yes the insert command is done, but the attributes were attached to the block that was inserted. From what I've seen Autolisp seems to require that any additional values be added to the same command sequence.
 
Great. I tried the insert command in 2006 and it worked. I don't know if I just had my attributes goofed up earlier today when I tried it in 2002 or what, but you're right, it should work.

Anyway, glad I could help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor