courtesy of http://www.developerfusion.co.uk/utilities/convertcsharptovb.aspx
Imports System
Imports System.Runtime.InteropServices
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports AcadApp = Autodesk.AutoCAD.ApplicationServices.Application
Public Class Commands
Sub New()
End Sub
Const RTSTR As Short = 5005
Const RTNORM As Short = 5100
Const RTNONE As Short = 5000
Const RTREAL As Short = 5001
Const RT3DPOINT As Short = 5009
Const RTLONG As Short = 5010
Const RTSHORT As Short = 5003
Const RTENAME As Short = 5006
_
_
Shared Function acedCmd(ByVal resbuf As IntPtr) As Integer
End Function
Public Shared Function Command(ByRef ParamArray args As Object()) As Integer
If AcadApp.DocumentManager.IsApplicationContext Then
Return 0
End If
Dim res As Integer = 0
Dim cnt As Integer = 0
' Using
Dim buffer As ResultBuffer = New ResultBuffer
Try
For Each o As Object In args
Dim code As Integer = 0
If TypeOf o Is String Then
code = RTSTR
Else
If TypeOf o Is Int32 Then
code = RTLONG
Else
If TypeOf o Is Int16 Then
code = RTSHORT
Else
If TypeOf o Is Double Then
code = RTREAL
Else
If TypeOf o Is Point3d Then
code = RT3DPOINT
Else
If TypeOf o Is ObjectId Then
code = RTENAME
End If
End If
End If
End If
End If
End If
If Not (code = 0) Then
buffer.Add(New TypedValue(code, o))
System.Threading.Interlocked.Increment(cnt)
End If
Next
If cnt > 0 Then
Dim cmdecho As Object = AcadApp.GetSystemVariable("CMDECHO")
AcadApp.SetSystemVariable("CMDECHO", 0)
res = acedCmd(buffer.UnmanagedObject)
AcadApp.SetSystemVariable("CMDECHO", cmdecho)
End If
Finally
CType(buffer, IDisposable).Dispose()
End Try
Return res
End Function
Public Shared Function ZoomExtents() As Integer
Return Command("._ZOOM", "_E")
End Function
End Class
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com
wrote in message news:5110049@discussion.autodesk.com...
Hello,
can anyone please tell how to use the command 'acedInvoke' from VB .NET. I found a lot of examples for #Sharp, but I am not able to translate it to VB .NET.
By the way, is this the only method to call a command from a modal dialog?
Regards, Jan