.NET

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

creating a dll file to be used by lisp and vba

121 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
Posts: 38
Registered: ‎10-02-2007
Message 2 of 2 (121 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.

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
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

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

Ask the Community