.NET

Reply
*Terry W. Dotson
Message 1 of 3 (107 Views)

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

107 Views, 2 Replies
03-15-2006 10:40 AM
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
*Tony Tanzillo
Message 2 of 3 (107 Views)

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

03-15-2006 11:42 AM in reply to: *Terry W. Dotson
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
*Terry W. Dotson
Message 3 of 3 (107 Views)

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

03-15-2006 12:23 PM in reply to: *Terry W. Dotson
Tony Tanzillo wrote:

> See the Database.FromAcadDatabase() method.

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

Thanks, Terry

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community