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

How to dynamically alter options

6 REPLIES 6
Reply
Message 1 of 7
davidgarner
261 Views, 6 Replies

How to dynamically alter options

Specifically the Options > Files > Project Files Search Path

I could do this before in LISP with:

(setq acadApp (vlax-get-acad-object )
prefs (vlax-get-property acadApp 'Preferences)
files (vlax-get-property prefs 'Files )
)


What objects and/or namespaces do I need to explore in .Net to learn how to do this?
6 REPLIES 6
Message 2 of 7
davidgarner
in reply to: davidgarner

OK, Here's the solution I've come up with. I'd love to hear comments on it's feasibility and any possible "gotchas".

Since I can't find an alterable (i.e., not read only) preferences object. I am going to programatically alter the

HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R16.2\ACAD-4004:409\Profiles\CHONGACAD\Project Settings\<project name> registry entry.
Message 3 of 7
NathTay
in reply to: davidgarner

Not sure what the .NET API equivalent is but the lisp is using the ActiveX API which you can access with AcadApplication.Preferences.Files.

Regards - Nathan
Message 4 of 7

I am also trying to figure this one out.
Here is what I have done, but Autocad pauses for 12 sec while ruinning this. The search path does get changed, I just think 12 sec is excessive therefor I am sure I have done this totally wrong.

public partial class MyClass
{
[CommandMethod ("SearchTest")]

public void STest()
{
AcadApplicationClass oApp = new AcadApplicationClass();
oApp.Preferences.Files.SetProjectFilePath("Search Test","C:\\");
}
}

Any Help?
Message 5 of 7
Anonymous
in reply to: davidgarner

Your's code start new instance of AutoCAD! 🙂
Try instead to get current instance of AutoCAD:
[code]
Autodesk.AutoCAD.Interop.AcadApplication oApp =
(Autodesk.AutoCAD.Interop.AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;
[/code]
Message 6 of 7

Thank you.
I knew I was doing something horribly wrong.
Message 7 of 7
Anonymous
in reply to: davidgarner

A little more info:-

Yes, all the Preferences for AutoCAD are accessible in .NET through AcadApplication.Preferences where AcadApplication is your instance of the AutoCAD Application Class.

For Preferences which can accept multiple File Path entries such as the Support File Search Path, you can feed the paths in as a single string, with each Path separated from the next by a semi-colon (no spaces). Also, do not finish with a semi-colon.

E.g.

AcadApp as AcadApplication

'New up an instance of Acad or connect to a running instance here...

AcadApp.Preferences.Files.SupportPath = "C:\Documents and Settings\YourUserName.CENTRICLTD\Application Data\Autodesk\AutoCAD 2006\R16.2\enu\Support;C:\Program Files\AutoCAD 2006\Support;C:\Program Files\AutoCAD 2006\Help;C:\Program Files\AutoCAD 2006\Fonts;C:\Program Files\AutoCAD 2006\Express;C:\Program Files\AutoCAD 2006\Support\Color"

If you look under the Preferences Class in the Object browser in the AutoCAD VBA Editor, you will see a numberr of classses which contain the various settings that you can fiddle with.

Regards,

Glenn

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