.NET

Reply
Contributor
Chumplybum
Posts: 25
Registered: ‎12-15-2003
Message 1 of 2 (140 Views)

creating a dll file to be used by lisp and vba

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

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
Next

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

cheers

mark
Active Contributor
jason.brenton
Posts: 38
Registered: ‎10-02-2007
Message 2 of 2 (140 Views)

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
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!