Designed4Life Posted July 7, 2009 Posted July 7, 2009 First let me start by noting thanks for all the help I received w/ my last issue about converting an existing dwg_scal lisp to work as a field. The field works great and everyone in the office is very excited about the change! I do have another issue. I assigned a filename field to several blocks we use for Section Titles and Plan titles. The field works great until the drawing is xref'd into another file. Since I have just started working w/ fields I failed to realize the filename field only works w/ the host dwg. It seems to me the way around this is to create a lispvariable field for the dwg name which gives the name of the drawing. I currently have a lisp routine which uses a getvar for the drawing name which is as follows: (strcat (getvar "dwgname")) Whenever I run this lisp routine in the command line it lists the command, dwg name, & read only. For example: If the dwg name is TITLE01.DWG after I run the lisp routine the following is noted in the command line: DWGNAME = "TITLE01.DWG" (read only) Is there a way to convert my current lisp routine into a field to use as a lispvariable "dwgname" or does anyone have a better lisp routine or field which would accomplish the same task? Quote
Lee Mac Posted July 7, 2009 Posted July 7, 2009 Just a quick one, uses a Diesel expression: (defun c:addnme (/ doc spc pt) (vl-load-com) (setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object)) spc (if (zerop (vla-get-activespace doc)) (if (= (vla-get-mspace doc) :vlax-true) (vla-get-modelspace doc) (vla-get-paperspace doc)) (vla-get-modelspace doc))) (if (setq pt (getpoint "\nSelect Point for Field: ")) (vla-AddMText spc (vlax-3D-point pt) 0 "%<\\AcDiesel $(getvar,dwgname)>%")) (princ)) Quote
lpseifert Posted July 7, 2009 Posted July 7, 2009 Field > Field Name > Filename never mind- I guess I should have read the post thoroughly Quote
Lee Mac Posted July 7, 2009 Posted July 7, 2009 ...I assigned a filename field to several blocks we use for Section Titles and Plan titles. The field works great until the drawing is xref'd into another file. Since I have just started working w/ fields I failed to realize the filename field only works w/ the host dwg.... Field > Field Name > Filename Not sure if he's already tried this... :wink: Quote
Designed4Life Posted July 7, 2009 Author Posted July 7, 2009 Just a quick one, uses a Diesel expression: (defun c:addnme (/ doc spc pt) (vl-load-com) (setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object)) spc (if (zerop (vla-get-activespace doc)) (if (= (vla-get-mspace doc) :vlax-true) (vla-get-modelspace doc) (vla-get-paperspace doc)) (vla-get-modelspace doc))) (if (setq pt (getpoint "\nSelect Point for Field: ")) (vla-AddMText spc (vlax-3D-point pt) 0 "%<\\AcDiesel $(getvar,dwgname)>%")) (princ)) If I copy the diesel expression you provided directly into the field category "diesel expression" I get an invalid field code response. I did however create a new lisp routine and copy the diesel expression into the lisp and it works but it still uses the name of the host dwg when xref'd into another dwg upon regen which is what I am hoping to avoid. In addition, the only way I can get the lisp routine/field to work is to type in addnme on the command line but this does not work with the attribute I created for the drawing name. I would have to delete the attribute and insert the field in its place. I would rathar be able to turn the attribute into a field using the field dialog box options. Am I missing a crucial step? Quote
Lee Mac Posted July 7, 2009 Posted July 7, 2009 If you wanted to create your own field using the Diesel Expression, you would need to use this: $(getvar,dwgname) But this will just retrieve the value of that sys var for the current drawing you are working on of course. Lee Quote
Designed4Life Posted July 7, 2009 Author Posted July 7, 2009 If you wanted to create your own field using the Diesel Expression, you would need to use this: $(getvar,dwgname) But this will just retrieve the value of that sys var for the current drawing you are working on of course. Lee Yes, I tried it and you are right the field uses the name of the host not the name of the xref similar to how the standard filename field works. I am really after a field that maintains the name of the drawing being xref'd into another drawing and does not adopt the name of the host. Thanks for being patient w/ me. Any other ideas? Quote
Lee Mac Posted July 7, 2009 Posted July 7, 2009 Could use the RTEXT expression, in your main drawing where the xref resides. $(xrefs, Quote
Designed4Life Posted July 7, 2009 Author Posted July 7, 2009 Could use the RTEXT expression, in your main drawing where the xref resides. $(xrefs, I understand how to use the RTEXT expression but it is still not what I am after. I do not want to add another step in our day-to-day drawing routine. I am merely trying to modify our existing block TITLE01 to include a drawingname field associated with the attribute in order to automate our existing drawing practices as much as possible. The "out-of-the-box" filename field works great along w/ the previous diesel expression you gave me earlier but when xref'd into another drawing they both adopt the drawing name of the host. I hope my attempt to explain my wish is not misleading. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.