.NET

Reply
Active Contributor
davidgarner
Posts: 26
Registered: ‎04-14-2005
Message 1 of 7 (106 Views)

How to dynamically alter options

106 Views, 6 Replies
04-05-2006 05:58 PM
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?
Active Contributor
davidgarner
Posts: 26
Registered: ‎04-14-2005
Message 2 of 7 (106 Views)

Re: How to dynamically alter options

04-06-2006 05:38 PM 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.
Distinguished Contributor
NathTay
Posts: 1,691
Registered: ‎12-15-2003
Message 3 of 7 (106 Views)

Re: How to dynamically alter options

04-06-2006 07:24 PM 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
Active Contributor
Techno Destructo
Posts: 47
Registered: ‎04-05-2006
Message 4 of 7 (106 Views)

Re: How to dynamically alter options

07-25-2006 01:59 AM in reply to: davidgarner
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?
Distinguished Contributor
Alexander Rivilis
Posts: 303
Registered: ‎09-26-2004
Message 5 of 7 (106 Views)

Re: How to dynamically alter options

07-25-2006 03:08 AM in reply to: davidgarner
Your's code start new instance of AutoCAD! :smileyhappy:
Try instead to get current instance of AutoCAD:
[code]
Autodesk.AutoCAD.Interop.AcadApplication oApp =
(Autodesk.AutoCAD.Interop.AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;
[/code]
Active Contributor
Techno Destructo
Posts: 47
Registered: ‎04-05-2006
Message 6 of 7 (106 Views)

Re: How to dynamically alter options

07-28-2006 02:52 AM in reply to: davidgarner
Thank you.
I knew I was doing something horribly wrong.
Active Member
glenn
Posts: 9
Registered: ‎08-10-2005
Message 7 of 7 (106 Views)

Re: How to dynamically alter options

07-30-2006 02:57 PM 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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community