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

0 Members and 1 Guest are viewing this topic.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
(GetEnv equivalent in C#
« on: November 30, 2007, 12:18:01 AM »
Question :

I'm trying to retrieve the Acad Search Path variable value
equivalent to (GetEnv "ACAD") in Lisp

As far as I can determine this can't be done with the NET API Library

Anyone have any ideas about a (GetEnv ... and (SetEnv ... equivalent in C# ?

Something similar to one of these :-
« Last Edit: October 17, 2009, 02:48:33 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.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: (GetEnv equivalent in C#
« Reply #1 on: November 30, 2007, 03:10:05 AM »
I don't see a way with reflector, or in the Arx docs, as the way you would do it in lisp, it doesn't look like you can with C#.  Lisp would be
Code: [Select]
(vla-get-SupportPath
  (vla-get-Files
    (vla-get-Preferences
      (vlax-get-Acad-Object)
    )
  )
)

You can get an object, from the Application object, for the Preferences, but I don't know what you can get from there.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: (GetEnv equivalent in C#
« Reply #2 on: November 30, 2007, 03:24:29 AM »
Thanks Tim, that was my conclusion too.

there is AN AcedGetEnv(.. in arx that may perhaps could be PEnvoke'd ... but I'm lost there ..
.. or at a pinch, perhaps the ActiveX methods used in VLisp and vba could be addressed via COM.

My brains not working at the moment, so I'll come back to it.
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.

FengK

  • Guest
Re: (GetEnv equivalent in C#
« Reply #3 on: November 30, 2007, 04:06:12 AM »
I'm guessing here. Would info in this post be helpful?
http://www.theswamp.org/index.php?topic=10017.msg135522#msg135522

Can you access "Vl.Application.16" via C#?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: (GetEnv equivalent in C#
« Reply #4 on: November 30, 2007, 04:47:14 AM »
This is trying with Autodesk.AutoCAD.Interop referenced

I'm out of my depth here ... [gurgle, gurgle, gurgle ]

the piccy to prove it :

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 #5 on: November 30, 2007, 05:17:10 AM »
like a dog at a bone ....
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 #6 on: November 30, 2007, 07:05:55 AM »
Kerry,

I was going to post up how to do the COM thing once I returned from walking the mutt, but I see you've already done it.

Here is an implementation of a wrapper for acedGetEnv.

If you look at the docs, it tells you that acedgetenv will look in a particular registry key for the value or failing that, the windows sys env table. You could use the built-in acad .net functions to find the product root key and then do a reg search thru .net, then the system environment variables if you wanted to implement your own.


Cheers,
Glenn.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: (GetEnv equivalent in C#
« Reply #7 on: November 30, 2007, 08:06:16 AM »
Thanks Glenn.

That's the direction I wanted to head in next.

I noticed you called that 'setenvwrapper' ..
do you actually have a setenvwrapper using acedGetEnv acedSetEnv ?   <<<< EDIT






« Last Edit: November 30, 2007, 08:24:20 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 #8 on: November 30, 2007, 08:17:56 AM »
Sorry Kerry, that was a slip of the fingers on this UK keyboard  :-) It was supposed to be getenv...

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: (GetEnv equivalent in C#
« Reply #9 on: November 30, 2007, 08:26:20 AM »
I've heard the spelling over there is weird too !

:-D


ps: I really meant using acedSetEnv


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 #10 on: November 30, 2007, 08:32:07 AM »
Here is an updated code file with both acedGetEnv and acedSetEnv.

Is that what you're after?

Cheers,
Glenn.

Chuck Gabriel

  • Guest
Re: (GetEnv equivalent in C#
« Reply #11 on: November 30, 2007, 08:34:45 AM »
Sorry Kerry, that was a slip of the fingers on this UK keyboard  :-) It was supposed to be getenv...

Is this a permanent relocation, or are you just visiting?

Glenn R

  • Guest
Re: (GetEnv equivalent in C#
« Reply #12 on: November 30, 2007, 08:38:21 AM »
Hey Chuck,

Permanent, or at least until we decide to go someplace else  :-)
Shipped the dog and the cat as well. Max (the beagle), seems to be loving it - all the new smells and cooler weather. The cat doesn't seem to care one way or the other as long as there's food and a heater to sleep by.

Cheers,
Glenn.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: (GetEnv equivalent in C#
« Reply #13 on: November 30, 2007, 08:49:08 AM »
Here is an updated code file with both acedGetEnv and acedSetEnv.

Is that what you're after?

Cheers,
Glenn.

perfectamundo !


I hope Jane was happy to see the animules.
 .. I bet Surrey is a little greener than the landscape you left here.

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 #14 on: November 30, 2007, 08:50:19 AM »
Well done Kerry and Glenn.
Autodesk.AutoCAD.Interop wasn't in my cad but I did find it in Objectarx 2008\inc