.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VBA to VB.NET - Receiving a drawing database as a parameter

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
344 Views, 2 Replies

VBA to VB.NET - Receiving a drawing database as a parameter

I'm trying to use VBA to call a VB.NET sub, and pass a drawing database
as a parameter. I've included a string passed MyTestSub1 to verify that
the communication is there, and the alert dialog shows.

However when trying to pass a drawing database I get an error indicating
it "does not support expected interface".

Can "db As Autodesk.AutoCAD.DatabaseServices.Database" be used as an
incoming parameter?

Thanks in advance,

Terry

==================================================================

.NET Code
---------

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.ApplicationServices

Public Class MyTestClass

Public Sub MyTestSub1(ByVal mystr As String)
Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(mystr)
End Sub

Public Sub MyTestSub2(ByVal db As
Autodesk.AutoCAD.DatabaseServices.Database)
db.RetainOriginalThumbnailBitmap = True
End Sub

End Class

VBA Code
--------
Dim MyRef As Object
Set MyRef = Application.GetInterfaceObject("MyProject.MyTestClass")
MyRef.MyTestSub1 "Hello from VBA"
MyRef.MyTestSub2 ThisDrawing.Database
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

You are passing an AcadDatabase COM object, and
expecting to receive a Database managed wrapper
for AcDbDatabase. I don't think so.

If you're making an assumption like that, then I
would suggest making an investment in learning
a bit more about the .NET managed wrapper API,
before attempting any significant development
with it, beyond simple band-aids. Contrary to
what may have been implied by 'managed', the
possiblity of crashing AutoCAD is quite good even
with the safety net provided by managed code.

See the Database.FromAcadDatabase() method.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Terry W. Dotson" wrote in message news:5111860@discussion.autodesk.com...
I'm trying to use VBA to call a VB.NET sub, and pass a drawing database
as a parameter. I've included a string passed MyTestSub1 to verify that
the communication is there, and the alert dialog shows.

However when trying to pass a drawing database I get an error indicating
it "does not support expected interface".

Can "db As Autodesk.AutoCAD.DatabaseServices.Database" be used as an
incoming parameter?

Thanks in advance,

Terry

==================================================================

.NET Code
---------

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.ApplicationServices

Public Class MyTestClass

Public Sub MyTestSub1(ByVal mystr As String)
Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(mystr)
End Sub

Public Sub MyTestSub2(ByVal db As
Autodesk.AutoCAD.DatabaseServices.Database)
db.RetainOriginalThumbnailBitmap = True
End Sub

End Class

VBA Code
--------
Dim MyRef As Object
Set MyRef = Application.GetInterfaceObject("MyProject.MyTestClass")
MyRef.MyTestSub1 "Hello from VBA"
MyRef.MyTestSub2 ThisDrawing.Database
Message 3 of 3
Anonymous
in reply to: Anonymous

Tony Tanzillo wrote:

> See the Database.FromAcadDatabase() method.

That appears to be the solution. As usual your very helpful.

Thanks, Terry

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost