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

creating a dll file to be used by lisp and vba

1 REPLY 1
Reply
Message 1 of 2
Chumplybum
293 Views, 1 Reply

creating a dll file to be used by lisp and vba

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
1 REPLY 1
Message 2 of 2
jason.brenton
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.

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