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#
Solved! Go to Solution.
Solved by _gile. Go to Solution.
Solved by Alfred.NESWADBA. Go to Solution.
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 -
Thanks for the reply, but, I dont think the support file search path is a system variable that can be edited that way.
Hi,
for editing:
Public Shared Sub SetSystemVariable(name As String, value As Object)
Member von Autodesk.AutoCAD.ApplicationServices.Core.Application
- alfred -
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 -
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.
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!
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!
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 -
Can't find what you're looking for? Ask the community or share your knowledge.