I'm trying to do a few things through a windows application using VB.Net:
1) open autocad and a specific drawing
2) run an existing VBA function w/ input parameters from .NET form
3) return outputs from VBA macro to .NET application
Is this possible? I'm a newbie to VB.NET but proficient in VBA. I've successfully opened the drawing I need using unmanaged code with my .NET form:
Imports System.Data.OleDb
Imports System.Math
Imports System.Runtime
Imports System.Runtime.InteropServices
Imports System.Runtime.InteropServices.Marshal
Imports System.Windows.Forms
Imports Autodesk.AutoCAD
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub MySub()
Connect2ACAD() 'procedure that checks for running autocad and opens new if not open.
Dim oApp As AcadApplication
Dim oDoc As AcadDocument
oApp = GetActiveObject("AutoCAD.Application.16")
oApp.Visible = True
oDoc = oApp.Documents.Open(filenam)
End Sub
End Class
The inputs and outputs of the function I have in VBA are all double datatype where the output is the area of a region created.
I know there's a RunMacro command, but this can't be used with input parameters or outputs. Any help whatsoever would be greatly appreciated - including better methods to start from scratch. Thanks,
J.P.