Is there a .NET property that can be used to identify the AutoCAD vertical?

Is there a .NET property that can be used to identify the AutoCAD vertical?

rhesusminus
Mentor Mentor
1,010 Views
5 Replies
Message 1 of 6

Is there a .NET property that can be used to identify the AutoCAD vertical?

rhesusminus
Mentor
Mentor

Hi.

 

I'm about to create some -NET add-ins for AutoCAD Electrical, using the AutoCAD Electrical "API", which is all LISP.

 

I want to do a check before running any code, to see if AutoCAD Electrical is the version my code is running in.

I've found some LISP-examples for this, but I'd really prefer to use something .NET-ish instead.

 

So, any ideas?


Trond Hasse Lie
EPLAN Expert and ex-AutoCAD Electrical user.
Ctrl Alt El
Please select "Accept Solution" if this post answers your question. 'Likes' won't hurt either. 😉
0 Likes
Accepted solutions (1)
1,011 Views
5 Replies
Replies (5)
Message 2 of 6

_gile
Consultant
Consultant

Hi,

 

You can get the registry product key using:

HostApplicationServices.Current.MachineRegistryProductRootKey

or:

HostApplicationServices.Current.UserRegistryProductRootKey

And you can have some informations about AutoCAD ProductIds here.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 6

rhesusminus
Mentor
Mentor

Thanks Gilles.

 

However... Running AutoCAD 2016 from the icon created when installing AutoCAD Electrical 2016, this still reports as AutoCAD Electrical.There's 1 registry key for both 😞

 

Is there any way to check if a file is loaded maybe? If "acade.mnl" is loaded, we're running AutoCAD Electrical...

 

 

 


Trond Hasse Lie
EPLAN Expert and ex-AutoCAD Electrical user.
Ctrl Alt El
Please select "Accept Solution" if this post answers your question. 'Likes' won't hurt either. 😉
0 Likes
Message 4 of 6

moogalm
Autodesk Support
Autodesk Support

Hi,

 

I didnt get the problem you are facing, using API userproductregistrykey for Acad electrical you 'll get F007:409 in the string.

F007 is for Acade and F001 is for Acad vanilla.

 

 

I don't think there is an API to check if mnl file is loaded.

0 Likes
Message 5 of 6

rhesusminus
Mentor
Mentor
When you install AutoCAD Electrical, you will slso get an icon in the start menu, with the option to start AutoCAD Electrical as plain, vanilla AutoCAD.

When I check the registry keys, there is only one there, for AutoCAD Electrical.

So, I will need some other way to find out if it is AutoCAD Electrical that is running.

Trond Hasse Lie
EPLAN Expert and ex-AutoCAD Electrical user.
Ctrl Alt El
Please select "Accept Solution" if this post answers your question. 'Likes' won't hurt either. 😉
0 Likes
Message 6 of 6

rhesusminus
Mentor
Mentor
Accepted solution

This seems to work for AutoCAD Electrical recognition:

 

 <CommandMethod("CTRLALTEL", "AREWERUNNINGAUTOCADELECTRICAL", "AREWERUNNINGAUTOCADELECTRICAL", CommandFlags.Modal)> _
        Public Sub AreWeRunningAutoCADElecrical()

            If IsThisAutoCADElectrical() Then

                System.Windows.Forms.MessageBox.Show("Yes :)")

            Else

                System.Windows.Forms.MessageBox.Show("No :(")

            End If

        End Sub

        Private Function IsThisAutoCADElectrical() As Boolean

            Try
                Dim Request As New ResultBuffer
                Request.Add(New TypedValue(5005, "ace_getactiveproject"))

                Dim Result As ResultBuffer = Autodesk.AutoCAD.ApplicationServices.Application.Invoke(Request)

                If Not Result Is Nothing Then

                    Return True

                Else

                    Return False

                End If

            Catch Ex As System.Exception

                Return False

            End Try

        End Function

Trond Hasse Lie
EPLAN Expert and ex-AutoCAD Electrical user.
Ctrl Alt El
Please select "Accept Solution" if this post answers your question. 'Likes' won't hurt either. 😉
0 Likes