• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Valued Contributor
    Posts: 54
    Registered: ‎12-06-2006
    Accepted Solution

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

    242 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

     

    Please use plain text.
    *Expert Elite*
    Posts: 6,456
    Registered: ‎06-29-2007

    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
    -------------------------------------------------------------------------
    Please use plain text.
    Valued Contributor
    Posts: 54
    Registered: ‎12-06-2006

    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"

    Please use plain text.
    Valued Contributor
    Posts: 54
    Registered: ‎12-06-2006

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

     

    Please use plain text.
    Contributor
    Posts: 20
    Registered: ‎09-29-2006

    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,

    Please use plain text.
    *Expert Elite*
    Posts: 3,049
    Registered: ‎07-22-2003

    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
    Please use plain text.
    Valued Contributor
    Posts: 54
    Registered: ‎12-06-2006

    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
    Please use plain text.