25 Posts
0 Kudos
Registered: ‎12-15-2003
Post 1 of 2

creating a dll file to be used by lisp and vba

142 Views, 1 Replies
10-03-2005 05:08 PM

i'm getting confused between a function written in vb6 and in vb.net.

i have the following code in vb6:
Public Function GroupExists(ByVal sName As String) As Boolean

Dim mgMenuGroup As AutoCAD.AcadMenuGroup

For Each mgMenuGroup In AutoCAD.Application.MenuGroups
If mgMenuGroup.Name = sName Then
GroupExists = True
Exit Function
End If
Next mgMenuGroup

GroupExists = False

End Function

and this code in vb.net (which i assume is the equivalent):
Public Function GroupExists(sGroupName As String) As Boolean

Dim AcadApp As Autodesk.AutoCAD.Interop.AcadApplication = Marshal.GetActiveObject("AutoCAD.Application.16.1")
Dim mgMenuGroup As Autodesk.AutoCAD.Interop.AcadMenuGroup

For Each mgMenuGroup In AcadApp.MenuGroups
If mgMenuGroup.Name = sGroupName Then
GroupExists = True
Exit Function
End If

GroupExists = False

End Function

now for my questions... is it correct that i have to set a variable to an instance of autocad (ie acadapp)??? if so does this mean everytime i need to do something with autocad (reading layers, menus etc) i have to add an instance to autocad in each of my classes, or can i add a global instance to autocad when either my lisp or vba application access my dll file??? the reason why i'm a little confused is that in vb6, there was no need to set an instance to autocad and now it seems that there is...

any help would be great


Active Contributor
38 Posts
0 Kudos
Registered: ‎10-02-2007
Post 2 of 2

Re: creating a dll file to be used by lisp and vba

10-19-2007 09:53 AM in reply to: Chumplybum
Actually, its much more than that.
For any added buttons, general watchdogging, menu control of other sorts, you use variation on applicationa and acadapp objects.

within a single drawing, and somewhat to the outside, you communicate to the workingdatabase of the app, (centered on current file) you access all and any block and hidden items within and also has methods to reach other files to grab any of the same information.

Not sure if it is general practice, but i use the implemented interface of the app to add custom buttons, placed where i like.
in non .net environments things are very different tho, such as vba that comes with autocad, you have access to the current app by default, and fairly easily just make a button that gets added like any lisp button. cui and all that.
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!