.NET

.NET

Reply
Valued Contributor
mario.rosenbohm
Posts: 56
Registered: ‎12-06-2006
Message 1 of 7 (389 Views)
Accepted Solution

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

389 Views, 6 Replies
10-24-2012 04:39 AM

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

 

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;
}

 

*Expert Elite*
Alfred.NESWADBA
Posts: 9,608
Registered: ‎06-29-2007
Message 2 of 7 (387 Views)

Re: How determine running Application is Civil or "Civil run as AutoCAD&quo

10-24-2012 05:01 AM in reply to: mario.rosenbohm

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
-------------------------------------------------------------------------
Valued Contributor
mario.rosenbohm
Posts: 56
Registered: ‎12-06-2006
Message 3 of 7 (357 Views)

Re: How determine running Application is Civil or "Civil run as AutoCAD&amp

10-26-2012 12:09 AM in reply to: Alfred.NESWADBA

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"

Valued Contributor
mario.rosenbohm
Posts: 56
Registered: ‎12-06-2006
Message 4 of 7 (329 Views)

Re: How determine running Application is Civil or "Civil run as AutoCAD&amp

10-28-2012 10:20 PM in reply to: mario.rosenbohm

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;
        }

 

Contributor
glanard
Posts: 20
Registered: ‎09-29-2006
Message 5 of 7 (248 Views)

Re: How determine running Application is Civil or "Civil run as AutoCAD&amp

12-19-2012 12:32 PM in reply to: mario.rosenbohm

@Mario,

 

First of all, thanks... but, this is not reliable for me :smileysad:.

 

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" :womanhappy:, but If you try manually to use a CIVIL command, you will get something like "unknown command" :womansurprised:.

 

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 :smileywink:

 

@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,

*Expert Elite*
Jeff_M
Posts: 4,521
Registered: ‎07-22-2003
Message 6 of 7 (225 Views)

Re: How determine running Application is Civil or "Civil run as AutoCAD"

12-21-2012 08:30 PM 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
Valued Contributor
mario.rosenbohm
Posts: 56
Registered: ‎12-06-2006
Message 7 of 7 (213 Views)

Re: How determine running Application is Civil or "Civil run as AutoCAD&amp

12-23-2012 05:45 AM in reply to: mario.rosenbohm
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
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.