×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Making LISP place "DWGMANE" into an attribute value?

Making LISP place "DWGMANE" into an attribute value?

Making LISP place "DWGMANE" into an attribute value?

(OP)
Hi everyone!  I am returning to AutoCAD 2002, after working 13 yrs with MicroStation.  Funny what one forgets about LISP when away for so long.

I am trying to write a routine that places sys vari "DWGNAME" into a block attribute value "DWG_NUMBER".  DBOR2D.DWG is the name of the title block.

I am familiar with the old LISP from Release 10 and I am trying to relearn LISP with AutoCAD 2002.  I have the extraction from the dwg file figured out...

(setq dn (substr (getvar "DWGNAME") 1 (-(strlen (getvar "DWGNAME")) 4)))

..but I am fighting with the proper code of inserting the dn variable into the "DWG_NUMBER" attribute.

Sorry for being long winded beginning this thread.  I am not looking for actual code, but more confirmation it can be done with LISP and directions to references on how to do it.

Thanks in advance,
George

RE: Making LISP place "DWGMANE" into an attribute value?

Hi...

(defun dwg-atributo (/ dn p-ins atributo)
  (setq    dn (substr (getvar "dwgname")
           1
           (- (strlen (getvar "dwgname")) 4)
       )
  ) ;_setq
  (if (not (tblsearch "block" dn))
    (progn
      (setq p-ins (cadr (grread 1)))
      (vl-cmdf "_.-attdef" "" "DWG_NUMBER" "" dn p-ins 2.5 0)
      (setq atributo (entlast))
      (vl-cmdf "_.-block" dn p-ins atributo "")
      (prompt "\nIndique punto de inserción: ")
      (vl-cmdf "_.-insert" dn pause "" "" "")
    ) ;_progn
  ) ;_if
) ;_defun

(defun c:dwginsert ()
  (setvar "cmdecho" 0)
  (vl-cmdf "_.undo" "_begin")
  (dwg-atributo)
  (vl-cmdf "_.undo" "_end")
  (setvar "cmdecho" 1)
  (prin1)
) ;_defun

(prompt "\n*** nuevo comando DWGINSERT definido. ***")
(prin1)

RE: Making LISP place "DWGMANE" into an attribute value?

(OP)
SpeedCAD, thanks for the help!  I guess I didn't specify my concern correctly.

The attribute "dwg_number" exists in a block, "dref2d".  I just want to populate that existing attribute with the system var "DWGNAME".

George

RE: Making LISP place "DWGMANE" into an attribute value?

How about using RTEXT
Command:rtext

Initializing...

Current settings: Style=SSF 2002-A  Height=1 1/8"  Rotation=0
Enter an option [Style/Height/Rotation/File/Diesel] <Diesel>: D

A empty dialog box will pop up.
Insert the following code into the dialog box.

$(getvar, "dwgname")

Charles S. Parnell
Southern Store Fixtures

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources