Open dwg's from command line into tabs in AutoCAD

Open dwg's from command line into tabs in AutoCAD

superturbo
Contributor Contributor
999 Views
19 Replies
Message 1 of 20

Open dwg's from command line into tabs in AutoCAD

superturbo
Contributor
Contributor

I am trying to compose a batch file for opening a drawing in the desired AutoCAD application (for instance AutoCAD Vanilla, AutoCAD Mechanical or DWG TrueView 202x). The drawing file name and application would be parameters to the batch file. The idea is that if an instance of the selected application is open, the drawing is opened in a new tab there, otherwise the application is to be launched.

 

Normally, we launch these applications with, for instance:
“C:\Program Files\....\acad.exe” /p “profile.arg” /product ACADM”

 

But this line will launch a new instance every time it is run.

From what I have found online, it seems that using the DWG Launcher is the way to go, in order to open the drawing in a new tab. However, DWG launcher will launch the last used Autodesk application and configuration. Since we use several different Autodesk applications, I need to launch the desired application specifically, and preferably with certain additional parameters in order to use our profile. No matter which Autodesk application is the last used.

 

How can this be accomplished?

 

0 Likes
Accepted solutions (1)
1,000 Views
19 Replies
Replies (19)
Message 2 of 20

cadffm
Consultant
Consultant

Hi,

 

>"However, DWG launcher will launch the last used Autodesk application and configuration. "

The last CLOSED application, right.

 

>"I am trying to compose a batch file">

>" No matter which Autodesk application is the last used."

You can't with a simple script/batch file, possible with API programming only.

Are you talking about a .bat/.cmd file, or what way exactly?

 

oh wait - I did this in the past too (decades)

I'll write to you again later, probably with the solution for you.

 
 

 

 

Sebastian

0 Likes
Message 3 of 20

superturbo
Contributor
Contributor

Thank you, that would be lovely!

I thought I couldn't be the only one doing this...

 

As for your question, I need to at least begin with a .bat file - but it could, of course, call another script if required.

0 Likes
Message 4 of 20

cadffm
Consultant
Consultant
Accepted solution

Hi,

 

The way I use for another situation: I change the registry values before I start my automation.

 

This is the important place for the "dblclick on DWG in windows file explorer" action.

cadffm_0-1747403522664.png

 

 

 

I didn't test it for your aclauncher script and I know that there are 4 or more places in your registry, what changes too -

but it will be a good point to start for you.

 

 

HTH

Sebastian

0 Likes
Message 5 of 20

cadffm
Consultant
Consultant

see also the definition of these keys

For example: AutoCAD LT (2022)

cadffm_0-1747404163314.png

 

Sebastian

0 Likes
Message 6 of 20

superturbo
Contributor
Contributor

Sweet! Thank you!

 

Now I need to figure out how to pass more parameters to the Launcher. At this point, it opens the drawing in the selected application. However, if the application is not currently running, it launches it but does not use the desired (which also is the last used) profile and workspace.

0 Likes
Message 7 of 20

cadffm
Consultant
Consultant

Hi,

 

" However, if the application is not currently running, it launches it but does not use the desired (which also is the last used) profile and workspace"

 

This has nothing to do with the "commandlineline" goal, it should be a general issue with your install (or win profile)!?

Pls confirm / or not.

 

 

1. Your .DWG (and btw. .DXF and .DWT) is linked to aclauncher.exe.

 

Close all adesk programs

2. Open your adesk program by doubleclick a .dwg In win file explorer.

What program is it?

    Switch to another profile and switch to another workspace.

  Close the program.

 

3.    Open another adesk program and close it

    Doubleclick a .dwg from explorer.

What program opens Now?

 

4. Open the first opend program, make sure you start the program without parameters for profile and workspace!

    What profile and workspace is active?

 

?

Acad should remember the last profile (and the last workspace is part of this setting)

 

 

Sebastian

0 Likes
Message 8 of 20

superturbo
Contributor
Contributor


Now I am a little confused. Doing the 4 steps that you described worked like a charm. Then I continued:


5. I started AutoCAD Mechanical with the <<acadmpp>> profile. Closed it. Double clicking a .dwg launched ACADM with <<acadmpp>> profile, correctly.


6. I closed it, and started ACADM with my profile and closed it. Now, double clicking the .dwg still launches ACADM with the <<acadmpp>> profile.


7+. After several more launches back and forth of ACADM with my profile and also TrueView at some point, eventually, double clicking the .dwg started launching ACADM with my profile again.


I am unable to reproduce this behavior reliably, but every now and then, after having launched ACADM with the <<acadmpp>> profile, it seems to get stuck with that profile for a heap more launches.


> Acad should remember the last profile (and the last workspace is part of this setting)

It does, most of the time, but not always. Hmm...

0 Likes
Message 9 of 20

cadffm
Consultant
Consultant

I don't have an explaination at this point.

It should not have the now and then moments.

 

Afk 

 

Sebastian

0 Likes
Message 10 of 20

superturbo
Contributor
Contributor

I might have an explanation of sorts to this.

It would appear that when ACAD is launched with the <<vanilla>> or <<acadmpp>> profiles, they seem to create their own keys in the registry among the apps under DWG Launcher. If either is present, DWG Launcher does not always honor its standard value, but picks this instead.

 

I now have my script remove these keys if they are present (if it is not the desired profile), and as far as I can tell, the desired profile gets launched every time.

Message 11 of 20

cadffm
Consultant
Consultant

I am not sure what you trying to say (sorr.

 

The "standard" should be always the last used product with the last used profile.

 

The last used profile is NEVER an .arg file,

because if you start/import an .arg file onced,

acad will never use this .arg again.

/Profile parameter will use the existing profile (with this profile name).

If there is no profile with this name, only then, 

acad import it from .arg file.

Sebastian

0 Likes
Message 12 of 20

cadffm
Consultant
Consultant

"I now have my script remove these keys if they are present"

 

Pls share this part of your script, thx.

Sounds interesting and new to me,

I will take a look.

 

Sebastian

0 Likes
Message 13 of 20

superturbo
Contributor
Contributor

My apologies for the unclarity.
The “Standard” value gets changed to the last used program as expected – yet, when a .dwg is double clicked, this is not honored if there is a key for acadmpp among the previously used products. In such a case, the acadmpp gets launched.
It does not make sense, but it is what I have observed, again and again.

 

My script, essentially, pushes a desired key to the AcLauncher “Standard” value and then runs AcLauncher. I have created new keys for the desired programs+profiles. Running the script, with acadm and dwg filename as parameters, will push my acadm key to the acLauncher “Standard” value and run acLauncher with the filename as parameter.
To resolve the above issue with acadmpp, the script also removes this key if it exists before running AcLauncher.

 

So far so good.

 

However, my remaining issue is that if AutoCAD Vanilla is the last started program and is currently running... And I run my script to open a .dwg in, say, ACADM. The “Standard” value is set correctly to my own acadm key, but still, AcLauncher opens the .dwg in a new tab in the running Vanilla instance. Similarly to when an acadmpp key exists, the “Standard” value is ignored. Removing the generic AutoCAD key does not make any difference. If I close Vanilla and run the script again, the .dwg is correctly opened in ACADM.

 

Somehow, it seems like AcLuncher has a very strong preference for Vanilla and acadmpp...
What I see in HKCU\Software\Autodesk\DWGCommon\shellex\apps does not explain this behavior. Are there other areas in the registry that control AcLauncher?

0 Likes
Message 14 of 20

cadffm
Consultant
Consultant

Hi,

 

>"and is currently running... And I run my script to open a .dwg in, say, ACADM. The “Standard” value is set correctly to my own acadm key, but still, AcLauncher opens the .dwg in a new tab in the running Vanilla instance."

 

Isn't it the standard behavior of AcLauncher?

I am in holiday, so I can't run tests.

That's how it works.

Use running instance, or start a bew instance of the last used version.

Sebastian

0 Likes
Message 15 of 20

cadffm
Consultant
Consultant

>"this is not honored if there is a key for acadmpp"

Interesting! 

Your sample-.DWG file is an MPP file, or does it acting the same way with a plain AutoCAD file?

 

There are different .DWG "type" registered.

For each product, for each version.

Perhaps it has to do with that?

 

I can't test.

Sebastian

0 Likes
Message 16 of 20

superturbo
Contributor
Contributor

> Your sample-.DWG file is an MPP file, or does it acting the same way with a plain AutoCAD file?

Thank you. This is an interesting thought.

I have tried dwg's saved by the various AutoCAD applications, and the behavior is the same.

0 Likes
Message 17 of 20

superturbo
Contributor
Contributor

> Isn't it the standard behavior of AcLauncher?

I am not sure what the standard behavior is. I was hoping that each time AcLauncher is called, it would simply honor its "Standard" value. But obviously it doesn't.

 

Please enjoy your holiday!

0 Likes
Message 18 of 20

cadffm
Consultant
Consultant

(Last) save is not important.

Try a testfile 

AutoCAD

NEW

Acad.dwt or AcadIso.dwt

save

 

This should save a plain auticad file, without mpp tags.

Sebastian

0 Likes
Message 19 of 20

superturbo
Contributor
Contributor

My apologies - this is what I have done. Saved dwg's with the different AutoCAD applications, and sent them to my script. Which application the dwg had been created in does not seem to make any difference in AcLauncher behavior.

0 Likes
Message 20 of 20

superturbo
Contributor
Contributor

>>"and is currently running... And I run my script to open a .dwg in, say, ACADM. The “Standard” value is set correctly to my own acadm key, but still, AcLauncher opens the .dwg in a new tab in the running Vanilla instance."

 

>Isn't it the standard behavior of AcLauncher?

 

AcLauncher's behavior does not entirely make sense. Most of the time, it honors its Standard value in the registry and opens the .dwg in the desired app/flavor - even if another flavor is the last launched or closed. This includes Vanilla of a different edition/year than the other flavors. However, if Vanilla of the same year as the other flavor is the last launched program, AcLauncher seems to ignore its Standard value and opens the .dwg in that Vanilla instance.

I can't seem to find a way to resolve this...

 

0 Likes