.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How determine running Application is Civil or "Civil run as AutoCAD"?

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
mario.rosenbohm
885 Views, 6 Replies

How determine running Application is Civil or "Civil run as AutoCAD"?

Hi,

 

i can determine the installed Version with:

 

Autodesk.AutoCAD.Runtime.SystemObjects.DynamicLinker.ProductKey="Software\Autodesk\AutoCAD\R18.1\ACAD-9000:407"

 

but this key is also by running Civil as AutoCAD.

 

How i can determine between "Civil" and "Civil runing as AutoCAD" ?

 

regards Mario

 

6 REPLIES 6
Message 2 of 7

Hi,

 

try to connect to any AECC-based lib, if you get an error it's the wrong profile for useing any Civil-API

Quick&dirty to check the availability of Civil-API:

Dim tCivilAPI_active as Boolean = false
Try
Dim tActiveX_ProgID as String = "AeccXUiLand.AeccApplication.9.0" 'use your version-nr Dim tObj As Object = pAcadAppCOM.GetInterfaceObject(tActiveX_ProgID) tCivilAPI_active = (tObj IsNot Nothing) 'TODO release the COM-object here Catch ex As Exception tCivilAPI_active = false 'just to make sure End Try

 

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 7

Hi alfred,

;-( ... dont work for me.

pAcadAppCOM.GetInterfaceObject("AeccXUiLand.AeccApplication.8.0") (Civil3d 2011) is never null (c# for Nothing).

 

even with the official start parameters Civil3D as AutoCAD "/ P AutoCAD"

Message 4 of 7

Hello,

i have found a solution that works fine.
If someone has a diferent version he can post so times.

regards Mario

        public static Boolean isCivilRunning()
        {
            Boolean result = false;
            try
            {
                foreach (System.Reflection.Assembly item in AppDomain.CurrentDomain.GetAssemblies())
                {
                    if (item.FullName.StartsWith("AeccUiWindows"))
                    {
                        result = true;
                        break;
                    }
                }
            }
            catch
            {
                // return false;
            }
            return result;
        }

 

Message 5 of 7
glanard
in reply to: mario.rosenbohm

@Mario,

 

First of all, thanks... but, this is not reliable for me Smiley Sad.

 

I don't know CIVIL but I suppose it is exactly like MECHANICAL.

 

What you can try is :

- Start AutoCAD, in <<VANILLA>> profile.

- Change the profile to your <<CIVIL>> one.

- Your code will say: "Civil is running" Woman Happy, but If you try manually to use a CIVIL command, you will get something like "unknown command" Woman Surprised.

 

You know, when you develop an application that has to be deployed on thousands of computers and used daily by many users all over the world, you must be prepared to evrything 😉

 

@Alfred

As I said previously, even with a "Try... Catch", you can sometimes get a fatal error on the GetInterfaceObject.

That's why we are looking to be sure, BEFORE, to be in the correct release.

 

Regards,

Message 6 of 7
Jeff_M
in reply to: glanard

We use a loader dll to check the "IsPureAcadProfile" profile in use when Civil3D starts. If it is 1 then we inform the user that our dll will not be loaded. If it is 0 then we load our dll.

Jeff_M, also a frequent Swamper
EESignature
Message 7 of 7

Hello glanard, your can set a brakepoint in your Code at loadet autocad-Profil and add a 'monitored expression' in your debug-view from visual-studio or other. The 'monitored expression' is "AppDomain.CurrentDomain.GetAssemblies()". This List include all load dlls. Than du it the same with "mechanical-profil", your'll see it be more dlls. Take one of this 'more dlls' that is typical of mechanical and replace the 'AeccUiWindows' width his 'FullName'. that should go. regards Mario

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost