TheSwamp
Code Red => .NET => Topic started by: Peter Jamtgaard on June 02, 2010, 08:30:47 AM
-
I did a search on the site and couldn't find a reference to acedGetEnv and acedSetEnv
Comments?
Peter
mports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Runtime
Imports System.Runtime.InteropServices 'for DllImport()
Imports System.Security
Imports System.Text.StringBuilder
Imports System.Reflection.Assembly
Public Class vbvlClass
' Use P/Invoke for acedGetEnv
' Use P/Invoke for acedGetEnv
<System.Security.SuppressUnmanagedCodeSecurity(), DllImport("acad.exe", _
CharSet:=CharSet.Auto, CallingConvention:=CallingConvention.Cdecl, EntryPoint:="acedGetEnv")> _
Private Shared Function acedGetEnv(ByVal strEnvironmentName As String, ByVal stbReturnValue As System.Text.StringBuilder) As Integer
End Function
' Use P/Invoke for acedSetEnv
<System.Security.SuppressUnmanagedCodeSecurity(), DllImport("acad.exe", _
CharSet:=CharSet.Auto, CallingConvention:=CallingConvention.Cdecl, EntryPoint:="acedSetEnv")> _
Private Shared Function acedSetEnv(ByVal strEnvironmentName As String, ByVal stbNewValue As System.Text.StringBuilder) As Integer
End Function
'______________________________________________________________________________________________________________________
'
' Get and Set environment variables using th P/Evoke
'______________________________________________________________________________________________________________________
<LispFunction("GetEnvironment")> _
Public Shared Function GetEnvironment(ByVal rbfEnvironmentName As ResultBuffer) As ResultBuffer
Dim rbfReturn As New ResultBuffer
Dim arrEnvironmentName As TypedValue() = rbfEnvironmentName.AsArray
Dim strEnvironmentName As String = arrEnvironmentName(0).Value.ToString
Dim stbReturn As New System.Text.StringBuilder(1024)
Try
acedGetEnv(strEnvironmentName, stbReturn)
rbfReturn.Add(New TypedValue(&H138D, stbReturn.ToString))
Catch Ex As Exception
rbfReturn.Add(New TypedValue(&H138D, "Error " & Ex.Message))
End Try
Return rbfReturn
End Function
'______________________________________________________________________________________________________________________
'
' Overload GetEnvironment function to accept and return strings
'______________________________________________________________________________________________________________________
Public Shared Function GetEnvironment(ByVal strEnvironmentName As String) As String
Dim stbReturn As New System.Text.StringBuilder(2048)
Try
acedGetEnv(strEnvironmentName, stbReturn)
Return stbReturn.ToString
Catch Ex As Exception
Return "Error " & Ex.Message
End Try
End Function
'______________________________________________________________________________________________________________________
'
' SetEnvironment function to accept and return result buffers
'______________________________________________________________________________________________________________________
<LispFunction("SetEnvironment")> _
Public Shared Function SetEnvironment(ByVal rbfEnvironmentName As ResultBuffer) As ResultBuffer
Dim rbfReturn As New ResultBuffer
Try
Dim arrEnvironmentName As TypedValue() = rbfEnvironmentName.AsArray
Dim strEnvironmentName As String = arrEnvironmentName(0).Value.ToString
Dim strNewValue As String = arrEnvironmentName(1).Value.ToString
Dim stbNewValue As New System.Text.StringBuilder(1024)
stbNewValue.Append(strNewValue)
acedSetEnv(strEnvironmentName, stbNewValue)
rbfReturn.Add(New TypedValue(&H138D, stbNewValue.ToString))
Catch Ex As Exception
rbfReturn.Add(New TypedValue(&H138D, "Error " & Ex.Message))
End Try
Return rbfReturn
End Function
'______________________________________________________________________________________________________________________
'
' Overload SetEnvironment function to accept and return strings
'______________________________________________________________________________________________________________________
Public Shared Function SetEnvironment(ByVal strEnvironmentName As String, ByVal strNewValue As String) As String
Try
Dim stbNewValue As New System.Text.StringBuilder(2048)
stbNewValue.Append(strNewValue)
acedSetEnv(strEnvironmentName, stbNewValue)
Return "OK"
Catch Ex As Exception
Return "Error " & Ex.Message
End Try
End Function
End Class
-
I did a search on the site and couldn't find a reference to acedGetEnv and acedSetEnv
Comments?
Peter
Yep
http://www.theswamp.org/index.php?topic=20237.msg362446#msg362446
http://www.theswamp.org/index.php?topic=22942.msg275966#msg275966
and from Augi
http://forums.augi.com/showthread.php?t=109055&highlight=acedSetEnv
-
Where is that dialog search form?
The one I used shown below is from the Search on the toolbar, and selecting the advanced button.
Peter
-
try this ..
-
... and for anyone following ..
You don't need to use the advanced search.
The normal search will search the current forum section, so if you are somewhere in the .NET forum search will find the reference if it exists.
... at least that's been my experience.
-
I am a bit perplexed ... it appears that you are defining new functions to set read environment variables (presumably from lisp) when you could simply use getenv and setenv. If you are using it for some other purpose then by all means carry on ...
-
Daniel
(and other swamp creatures)
I just add the LISPFunction to test the code.
I thought it would be useful for .net to set the values for the environment and lisp variables.
What am I doing?
Right now I am more interested in exploring the different entry points of the acad.exe and other arx autocad dll's
I found some old delphi code that shows some of the variabe types for the various entry points in acad.exe.
I have been trying to see if I can get any of them to work.
Have any of you got the acedEvalDiesel entry point to work?
I have it running, but am having trouble getting the values out.
Also I want to say that a good portion of the code I have posted is from other sources, and I do not take credit for inventing them, just maybe translating them and getting them to work in vb.net.
I do re-write the code to make the code VERY similar to the other examples to help myself and any others to learn from them.
I by no means want to take the credit from the original developers.
On the AUGI, Autodesk, ADN, VBForums, ....
I always figure that forums are here to share code, and help others to learn to program.
I very much appreciate all of your suggestions and code samples.
I also want you to know that when I find something useful or cool,
I share it on these groups almost immediately.
Sometimes I may copy similar programs from one forum to another.
If this group has other rules of forum etiquette please let me knnow.
Thanks again.
Peter
-
Peter,
That's what this place is all, about learning from each other and building upon code others have posted. Feel free to use anything I've posted anyway you like. There are instances where the author has put significant effort into their posts, out of respect, its proper to acknowledge their efforts with a comment in the code I.e.
// Based on the fine work of Tony the Tiger
...
-
or in my case.
//This is a fix-up of the crap Dan posted
:lol:
-
I had
Can't argue with that !!
ready to post
... before you added the last :-D