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
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?
(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?
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?
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