Message 1 of 3
Not applicable
02-08-2011
08:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I'm having struggling with 2 items
1. When running the following code it doesn't return the value into "SCRATCH_FNAM"
2. How can I read back this variable? a example would be wonderfull because I'm a newbie in Vb.net
If I remove the following line it seems to work
resBuf.Add(New TypedValue(Lisp_AE.RTSTR, "scratch_fnam"))
but I need to have the projectlocation from AutoCAD electrical. They provide the following API
(setq fnam (c:wd_mdb_get_proj_scratch_dbnam nil)) ; "nil"=get current proj mdb file name
to get the value Scratch_fnam I tried:
dim Rbin as resultbuffer = Invoke(resbuf)
but how further????
Vb.Net code:
Imports System
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports System.Runtime.InteropServices
Imports Autodesk.AutoCAD.ApplicationServices.Application
Imports Autodesk.AutoCAD.Geometry
Public Class Lisp_AE
Public Const RTREAL As Int32 = 5001
Public Const RTSHORT As Int32 = 5003
Public Const RTSTR As Int32 = 5005
Public Const RTLONG As Int32 = 5010
Public Const RTENAME As Int32 = 5006
' Import the acedInvoke function definition
Private Declare Function acedInvoke Lib "acad.exe" (ByVal args As IntPtr, ByRef result As IntPtr) As Integer
'''//////////////////////////////////////////////////////////////////
' Function: InvokeLispFunc
' Description: This function calls the acedInvoke function.
' Parameters: args - Data structure containing the Lisp function name and arguments to be passed into the function
' stat - An int to store function execution status code
' Return Value: returns from lisp if successful, otherwise, return null
'''//////////////////////////////////////////////////////////////////
Public Shared Function InvokeLispFunc(ByVal args As ResultBuffer, ByRef stat As Integer) As ResultBuffer
Dim rb As IntPtr = IntPtr.Zero
stat = acedInvoke(args.UnmanagedObject, rb)
If (stat = CType(PromptStatus.OK, Integer)) Then
Return CType(Autodesk.AutoCAD.Runtime.DisposableWrapper.Create(GetType(ResultBuffer), rb, True), ResultBuffer)
End If
Return Nothing
End Function
End Class
Public Class SampleMainClass
Public Shared Function ProjPath() As Boolean
Dim stat As Integer = 0
Dim bOK As Boolean = True
Dim resBuf As ResultBuffer = New ResultBuffer
resBuf.Add(New TypedValue(Lisp_AE.RTSTR, "scratch_fnam"))
resBuf.Add(New TypedValue(Lisp_AE.RTSTR, "c:wd_mdb_get_proj_scratch_dbnam"))
resBuf.Add(New TypedValue(Lisp_AE.RTSTR, "nil"))
Dim ret As ResultBuffer = Lisp_AE.InvokeLispFunc(resBuf, stat)
If (ret Is Nothing) Then
Return False
End If
Dim rbChain() As TypedValue = ret.AsArray
If (rbChain.Length = 0) Then
bOK = False
End If
Return bOK
End Function
End Class
Thanks in advance for your help.
Solved! Go to Solution.