Author Topic: (GetEnv equivalent in C#  (Read 25347 times)

0 Members and 1 Guest are viewing this topic.

Glenn R

  • Guest
Re: (GetEnv equivalent in C#
« Reply #15 on: November 30, 2007, 08:52:45 AM »
I hope Jane was happy to see the animules.
 .. I bet Surrey is a little greener than the landscape you left here.

Yes, she was, but it didn't take her long to remember what a pain the mutt can be.
Yeah, it's green here and blasted brown if not bare earth there.

Cheers,
Glenn.

Glenn R

  • Guest
Re: (GetEnv equivalent in C#
« Reply #16 on: November 30, 2007, 08:54:42 AM »
Well done Kerry and Glenn.
Autodesk.AutoCAD.Interop wasn't in my cad but I did find it in Objectarx 2008\inc

It should be on the COM tab in the add reference dialog Bryce. Kerry should be able to post a nice piccy of the entries you need to reference seeing as he's snagit happy at the moment ;)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: (GetEnv equivalent in C#
« Reply #17 on: November 30, 2007, 10:17:18 AM »
Well done Kerry and Glenn.
Autodesk.AutoCAD.Interop wasn't in my cad but I did find it in Objectarx 2008\inc

It should be on the COM tab in the add reference dialog Bryce. Kerry should be able to post a nice piccy of the entries you need to reference seeing as he's snagit happy at the moment ;)

OK

just Reference the  AutoCAD 2008 Type Library
and add the using statement
using Autodesk.AutoCAD.Interop;

added:
just realised, these threads must look weird if the viewer isn't logged in ( a member) ... cause the piccys really do tell a story :-)

« Last Edit: November 30, 2007, 10:26:42 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Bryco

  • Water Moccasin
  • Posts: 1883
Re: (GetEnv equivalent in C#
« Reply #18 on: November 30, 2007, 01:29:07 PM »
Thanks mate. Picture is worth a 1000 beers.

Glenn R

  • Guest
Re: (GetEnv equivalent in C#
« Reply #19 on: November 30, 2007, 02:22:32 PM »
And Kerry is the king of piccies  :-D

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: (GetEnv equivalent in C#
« Reply #20 on: November 30, 2007, 07:04:09 PM »
And Kerry is the king of piccies  :-D


[you] can be as well !
http://www.theswamp.org/index.php?topic=20184.msg245455#msg245455


I'm just too lazy to write properly .. succinct is difficult.


**
[you] of course being [you the reader].
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Glenn R

  • Guest
Re: (GetEnv equivalent in C#
« Reply #21 on: November 30, 2007, 07:10:09 PM »
Duly noted my friend.

Cheers,
Glenn.

Chumplybum

  • Newt
  • Posts: 97
Re: (GetEnv equivalent in C#
« Reply #22 on: December 02, 2007, 07:10:29 PM »
what about:  Autodesk.AutoCAD.ApplicationServices.UserConfigurationManager ????


Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: (GetEnv equivalent in C#
« Reply #23 on: December 02, 2007, 11:55:42 PM »

Haven't tried that Chumplybum .. have you ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: (GetEnv equivalent in C#
« Reply #24 on: December 03, 2007, 12:33:03 AM »
sorry, I was board  :laugh:

Code: [Select]
AcMgdWrprs.Utilities.GetEnv("ACAD")

for 2007



Chumplybum

  • Newt
  • Posts: 97
Re: (GetEnv equivalent in C#
« Reply #25 on: December 03, 2007, 01:11:07 AM »
this is the same as (getenv "ACAD")...


Dim UserConfigurationManager As Autodesk.AutoCAD.ApplicationServices.UserConfigurationManager = Autodesk.AutoCAD.ApplicationServices.Application.UserConfigurationManager
Dim ProfileBase As Autodesk.AutoCAD.ApplicationServices.IConfigurationSection = UserConfigurationManager.OpenCurrentProfile

Dim GeneralRegKey As Autodesk.AutoCAD.ApplicationServices.IConfigurationSection = ProfileBase.OpenSubsection("General")

System.Windows.Forms.MessageBox.Show(GeneralRegKey.ReadProperty("ACAD", "").ToString)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: (GetEnv equivalent in C#
« Reply #26 on: December 03, 2007, 02:03:49 AM »

cool !

I'll have a play tonight ... Thanks.


kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: (GetEnv equivalent in C#
« Reply #27 on: December 03, 2007, 02:32:32 AM »
Yes,Mark, that seems fine.
I made a method that's a little more generic
Haven't tested for invalid data in this version ...

Code: [Select]
        public static object GetProfileEntry(string sSubSection, string sProperty)
        {
            UserConfigurationManager ucManager = Application.UserConfigurationManager;
            IConfigurationSection currentProfile = ucManager.OpenCurrentProfile();
            IConfigurationSection subSection = currentProfile.OpenSubsection(sSubSection);
            return subSection.ReadProperty(sProperty, "");
        }

A piccy for Joe ..
« Last Edit: December 03, 2007, 02:41:02 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: (GetEnv equivalent in C#
« Reply #28 on: December 03, 2007, 06:13:02 AM »
I s'pose there's really no need for a method when we can do it in-line without intermediate variable assignments ..

Code: [Select]
           
 string sSupportPath = AcadApp.UserConfigurationManager.OpenCurrentProfile().
                                 OpenSubsection("General").ReadProperty("ACAD", "").ToString();
« Last Edit: December 03, 2007, 07:34:35 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Glenn R

  • Guest
Re: (GetEnv equivalent in C#
« Reply #29 on: December 03, 2007, 06:52:51 AM »

I s'pose there's really no need for a method when we can do it in-line without intermediate variable assignments ..

Code: [Select]
            string sSupportPath = AcadApp.UserConfigurationManager.OpenCurrentProfile().
                                 OpenSubsection("General").ReadProperty("ACAD", "").ToString();code]

True, but the function looks better; is easier to read and if one property in that 'property chain' fails, it's a lot harder to debug...just some thoughts.

Cheers,
Glenn.