Jump to content

.NET Development in Dept With Different Versions of AutoCAD


Bill Tillman

Recommended Posts

I knew this was going to happen....again. We have almost everyone in this department updated to AutoCAD 2015 Mechanical with the exception of a few other users like myself who use either 2014 vanilla or 2013 vanilla. So my project in VB.NET now has a new module which looks for a running version of AutoCAD and uses it with a SendCommand to make some other tasks happen.

 

Today we deployed it and the first problem was that the 2015 users cannot run the app due to the 2013 reference that's built in at compile time. I don't suppose there is any way around this because unlike a VBA program I wrote long ago which loaded a reference for Excel depending on the version the users were running I don't think you could get a stand-alone exe to grab a reference on the fly.

 

BTW - I just found out that the 2014 users are able to use it but the 2015 Mechanical users are SOL for the moment until I figure out a work around for this....possibly another exe which will determine the users' name or their version of AutoCAD and launch the correct exe for their version.....except for the boss who has two different versions of AutoCAD installed and he runs one or the other or sometimes both of them at the same time...depending on his workload and his mood. And they want me to develop code for this dept which adheres to such very rigorous standards.... LOL!

Link to comment
Share on other sites

I knew this was going to happen....again. We have almost everyone in this department updated to AutoCAD 2015 Mechanical with the exception of a few other users like myself who use either 2014 vanilla or 2013 vanilla. So my project in VB.NET now has a new module which looks for a running version of AutoCAD and uses it with a SendCommand to make some other tasks happen.

 

Today we deployed it and the first problem was that the 2015 users cannot run the app due to the 2013 reference that's built in at compile time. I don't suppose there is any way around this because unlike a VBA program I wrote long ago which loaded a reference for Excel depending on the version the users were running I don't think you could get a stand-alone exe to grab a reference on the fly.

 

I'm not sure what '2013 reference' you mean?

 

 

 

... I don't think you could get a stand-alone exe to grab a reference on the fly.

 

You could code your app to use a Field, Property, or Method to conditionally return the appropriate reference, or simply use dynamics, no?

 

 

 

BTW - I just found out that the 2014 users are able to use it but the 2015 Mechanical users are SOL for the moment until I figure out a work around for this....possibly another exe which will determine the users' name or their version of AutoCAD and launch the correct exe for their version.....except for the boss who has two different versions of AutoCAD installed and he runs one or the other or sometimes both of them at the same time...depending on his workload and his mood. And they want me to develop code for this dept which adheres to such very rigorous standards.... LOL!

 

If you didn't want to rely on ROAMABLEROOTPREFIX, or Registry, etc., you might consider:

 

Process process = <get your process here>;

process .Modules[0].FileName;

 

 

 

Cheers

Link to comment
Share on other sites

Bill, have you looked into late binding? That should pick up the version of AutoCAD that's running, then identify it and run the appropriate software.

 

BB, how do you get your apps to run on different versions of AutoCAD, you surely don't write an app for each version?

 

Best

Link to comment
Share on other sites

Bill, have you looked into late binding? That should pick up the version of AutoCAD that's running, then identify it and run the appropriate software.

 

BB, how do you get your apps to run on different versions of AutoCAD, you surely don't write an app for each version?

 

Best

 

Yes, do tell.

Link to comment
Share on other sites

Bill, have you looked into late binding? That should pick up the version of AutoCAD that's running, then identify it and run the appropriate software.

 

BB, how do you get your apps to run on different versions of AutoCAD, you surely don't write an app for each version?

 

FWiW -

 

Early/late binding can be replaced with dynamics, which inherently removes x86/x64 dependency. :thumbsup:

 

I only build different apps when COM/Platform-dependent for the version, or where AutoCAD API requires it.

 

 

 

As a quick example, this for 2010-2011 (.NET 3.5) using Autodesk.AutoCAD.Interop (COM/Platform-dependent; resulting in x86, x64 builds):

 

               //...
               AcadDocument acDoc = doc.AcadDocument as AcadDocument;
               acDoc.GetType().InvokeMember("StartUndoMark",
                   BindingFlags.InvokeMethod, null, acDoc, null);

               //... Do something useful

               acDoc.GetType().InvokeMember("EndUndoMark",
                   BindingFlags.InvokeMethod, null, acDoc, null);
               //...

 

 

 

... Can be replaced with this for AutoCAD 2012-2015 (and newer?)(.NET 4) to do same, with pure .NET (no COM Assembly references, and can be built to 'Any CPU'):

 

               //...
               dynamic acDoc = doc.GetAcadDocument();
               acDoc.StartUndoMark();

               //... Do something useful

               acDoc.EndUndoMark();
               //...

 

 

 

So to recap; less typing, less Assembly references to keep track of, and less builds (depending on the app you're coding, as always, of course)... Hooray [dynamics]! :beer:

 

Cheers

Edited by BlackBox
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...