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

DllImport for acedGetEnv....

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
StormyC
2846 Views, 9 Replies

DllImport for acedGetEnv....

Got what I think is an odd situation.  Im trying to access the support paths using the dll import that can be found in a number of sites.  Problem is, the entry point doesnt seem to exist - im sure it worked before.. any help would be appreciated.

 

AutoCAD2014, Win7 64, VSExpress2010, C#

 

acerror.png

9 REPLIES 9
Message 2 of 10
Alfred.NESWADBA
in reply to: StormyC

Hi,

 

acedGetEnv is placed in ACCORE.DLL and not in ACAD.EXE (I guess since 2013).

 

BTW: why don't you use the more direct option to get sysvar's:

   Public Shared Function GetSystemVariable(name As String) As Object
      Member von Autodesk.AutoCAD.ApplicationServices.Core.Application

 

- alfred -

 

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 10
StormyC
in reply to: Alfred.NESWADBA

Thanks for the reply, but, I dont think the support file search path is a system variable that can be edited that way.

Message 4 of 10
Alfred.NESWADBA
in reply to: StormyC

Hi,

 

for editing:

   Public Shared Sub SetSystemVariable(name As String, value As Object)
      Member von Autodesk.AutoCAD.ApplicationServices.Core.Application

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 5 of 10
StormyC
in reply to: Alfred.NESWADBA

The system variable is readonly....

Message 6 of 10
Alfred.NESWADBA
in reply to: StormyC

Hi,

 

>> The system variable is readonly....

Which sysvar?

 

And back to start:

>> Problem is, the entry point doesnt seem to exist - im sure it worked before

Have you seen my first sentence in my first post?

      acedGetEnv is placed in ACCORE.DLL and not in ACAD.EXE (I guess since 2013).

 

At least:

Does >>>that thread<<< abotu adding a path to the list of support paths help?

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 7 of 10
_gile
in reply to: Alfred.NESWADBA

Hi,

 

As Alfred said, since AutoCAD 2013, the acad.exe file have been splited into acad.exe and accore.dll.

Try replacing acad.exe with accore.dll in the DllImport arguments.

 

Anyway, to get and/or set support paths, you can use COM to access to AutoCAD preferences.

 

This needs to reference the COM librairies or use the Dynamic type. The inconvenients of the first route are the advantages of the second one and vice versa.

Referencing COM libraries means using static typing with type checking at compile time which is a great help during edition time (intellisense), but COM librairies are verion and processor architecture dependant which may be an inconvenient.

 

Using COM libraries

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Interop;
using Autodesk.AutoCAD.Runtime;

namespace AcadPreferencesStaticTyping
{
    public class CommandMethods
    {
        [CommandMethod("Test")]
        public void Test()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            AcadPreferences prefs = (AcadPreferences)Application.Preferences;
            string[] supportPaths = prefs.Files.SupportPath.Split(';');
            foreach (string str in supportPaths)
            {
                ed.WriteMessage("\n{0}", str);
            }
        }
    }
}

 

Using Dynamic type

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;

namespace AcadPreferencesDynamicTyping
{
    public class CommandMethods
    {
        [CommandMethod("Test")]
        public void Test()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            dynamic prefs = Application.Preferences;
            string[] supportPaths = prefs.Files.SupportPath.Split(';');
            foreach (string str in supportPaths)
            {
                ed.WriteMessage("\n{0}", str);
            }
        }
    }
}

 

As the codes are very similar, it's quite easy to reference the COM libraries while writing an debugging and, when all works as expected, remove these references and replace the COM types with the 'dynamic' keyword.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 8 of 10
StormyC
in reply to: Alfred.NESWADBA

Which Sysvar:  ACADPREFIX

 

Yes, saw your first sentance but for some reason i didnt think it was the same thing as importing from the .exe

 

Forgive me, Ive just tried it by importing from ACCORE.DLL and that works, for reading & writing.

 

Your other link is to use the interop library, which I wanted to avoid.

 

Many Many thanks for your help!!

 

How did you find that acedGetEnv had moved?

 

Again Thanks!

Message 9 of 10
StormyC
in reply to: _gile

Gilles, many thanks for that reply - I had read about dynamic types but forgotten about them.

 

I may just rewrite it to use those.

 

Thanks both!

Message 10 of 10
Alfred.NESWADBA
in reply to: StormyC

Hi,


>> Forgive me,

You are welcome, no need to appologize, the most important thing is you got it solved and you can continue to work 😉

 

>> How did you find that acedGetEnv had moved?

For Invokes and similar things I use Dependency Walker >>>click<<<.

 

- alfred -

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

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