Jump to content

Can we change DWGNAME and DWGPREFIX?


hikerVancouver

Recommended Posts

When I open a dxf file using a script file, DWGPREFIX is a directory where script was executed from, and DWGNAME is a default "drawing.dwg" in opened file.

 

Is it possible to change these variables without saving the file?

 

I am using R14.

 

Thank You.

Link to comment
Share on other sites

Welcome to CADTutor!

 

Unfortunately, the DWGNAME, and DWGPREFIX System Variables are Read-Only.

 

Without seeing your code, it will be hard to suggest alternative / corrective action(s).

Link to comment
Share on other sites

My code is really basic. I just say:

 

_open\n"full path to a file"\n

 

in a src file which is passed to autocad with /b option when starting it.

 

My goal is to open dxf file in autocad, and if user changes it and type "dxfout" on a command prompt, h(s)e doesn't have to remember original file path/name and retype it or search for it.

 

Saving file after opening it is not an option in this case.

 

Thank for quick reply.

Link to comment
Share on other sites

My code is really basic. I just say:

 

_open\n"full path to a file"\n

 

in a src file which is passed to autocad with /b option when starting it.

 

My goal is to open dxf file in autocad, and if user changes it and type "dxfout" on a command prompt, h(s)e doesn't have to remember original file path/name and retype it or search for it.

 

Saving file after opening it is not an option in this case.

 

Thank for quick reply.

 

Why not instead try using the /t switch?

 

Sample application icon target:

 

[size=2]"C:\AutoCAD 20[color=red]xx[/color]\acad.exe" /nologo /p "C:\profiles\[color=red]MyProfile[/color]" [color=blue]/t [/color]"C:\[color=black]MyTemplates[/color]\[color=red]MyTemplate[/color]"[/size]

 

Edit - AutoCAD Startup Switches

Edited by BlackBox
Added link
Link to comment
Share on other sites

I have never created templates.

 

Would you be able to show an example of a file which I could use/modify for this purpose? Files will never come from exact same directory.

 

My guess is that in a template I would have to specify name or?

 

Thank You once again for looking into this.

Link to comment
Share on other sites

I have figured out DWGPREFIX part. Because I start a script from within another application by calling WIN API CreateProcess(), I specified "startIn" to be a directory where dxf file was read from.

 

Is it possible to "overload" autocad commands?

 

What I am having in mind is to create a lisp routine so if user types "dxfout", in the place of DWGNAME, dxfout would use USERS1 variable which I could set as dxf file is being open.

 

If this is possible, what file should I be looking into modifying? Does anybody have any examples of this?

Link to comment
Share on other sites

Lisp routines will not work past an open command where a script file will. To automate lisp and scripts - it is a little difficult but here is the process.

 

Run a lisp to write a script of the file you want to open

use the script to open the file

use the same script to run another lisp routine (once the file is open)

 

Once the file is open you should be able to get the DWGPREFIX and DWGNAME variables and sort from there.

Link to comment
Share on other sites

One minor correction...

 

AutoLisp routines will not work past an open command where a script file will. To automate lisp and scripts - it is a little difficult but here is the process.

 

Run a lisp to write a script of the file you want to open

use the script to open the file

use the same script to run another lisp routine (once the file is open)

 

Once the file is open you should be able to get the DWGPREFIX and DWGNAME variables and sort from there.

 

I'll offer ObjectDBX as one example of Visual LISP being able to carry out tasks (not commands) after opening a drawing. Another way is to open a drawing by invoking the Add Method upon the Documents Collection... this option would permit the use of Selection Sets, and Commands.

 

In any event, drawing templates (.DWT) are incredibly valuable to any production team. Aptly named - the 'template' - what all of your drawings are based upon (i.e., System Variables, potentially including layer sets, named views, etc.). It is common to have a template for each client, and / or for separate disciplines.

 

Instead of redefining (not overloading) the dxfout command, could you not simply write a custom routine to provide a command line, menu item, toolbar macro, and / or ribbon option for your users? Simply hard-code the desired seed file(s) into the routine's options (if applicable).

 

*IF* you must use the dxfout command, perhaps a Command Reactor would be useful? (

 

I say the KISS principle should prevail; setup your templates, and write a custom routine... simple.

Link to comment
Share on other sites

One minor correction...

 

 

 

I'll offer ObjectDBX as one example of Visual LISP being able to carry out tasks (not commands) after opening a drawing. Another way is to open a drawing by invoking the Add Method upon the Documents Collection... this option would permit the use of Selection Sets, and Commands.

 

In any event, drawing templates (.DWT) are incredibly valuable to any production team. Aptly named - the 'template' - what all of your drawings are based upon (i.e., System Variables, potentially including layer sets, named views, etc.). It is common to have a template for each client, and / or for separate disciplines.

 

Instead of redefining (not overloading) the dxfout command, could you not simply write a custom routine to provide a command line, menu item, toolbar macro, and / or ribbon option for your users? Simply hard-code the desired seed file(s) into the routine's options (if applicable).

 

*IF* you must use the dxfout command, perhaps a Command Reactor would be useful? (

 

I say the KISS principle should prevail; setup your templates, and write a custom routine... simple.

*cough*he's running r14*cough*
Link to comment
Share on other sites

*cough*he's running r14*cough*

 

I completely overlooked that. :oops:

 

R14 was before my time... I take it that means scrap all the ActiveX COM fodder? Does it (R14) not support the use of DWT / AutoLSP / Macros?

Link to comment
Share on other sites

I completely overlooked that. :oops:

 

R14 was before my time... I take it that means scrap all the ActiveX COM fodder? Does it (R14) not support the use of DWT / AutoLSP / Macros?

VLISP wasn't officially released until 2000, but it's supposed to have been an addon package for r14.

 

As far as I remember, r14 allowed for templates.

Link to comment
Share on other sites

VLISP wasn't officially released until 2000, but it's supposed to have been an addon package for r14.

 

As far as I remember, r14 allowed for templates.

 

At least my entire post wasn't irrelevant. LoL

 

Hazzah!

 

3491276517_ac58b9b60f.jpg

Link to comment
Share on other sites

R14 will offer Lisp and scripts and Template files but not Visual lisp

 

Thanks for your comments though as I have always done the Lisp/ Scripts way of opening drawings and never really looked at a Visual Lisp way. Probably because when I did this it was in R14!!

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...