How do I add my DLL to Autocad shortcuts with VB.NET

How do I add my DLL to Autocad shortcuts with VB.NET

cengizincebi
Contributor Contributor
420 Views
2 Replies
Message 1 of 3

How do I add my DLL to Autocad shortcuts with VB.NET

cengizincebi
Contributor
Contributor

Hello everybody,

 

I created the program (my class have 3 forms) with VB.NET for Autocad/Civil3D.  

I want to use with shortcut keyword in Autocad/Civil3D this forms.

But I dont found solution...... 

 

I want to run;

      F1 press for Form1,

      CTRL+ALT+J press for Form2,

     CTRL+H press for Form3.

 

Can you help me?

 

Thanks... 

0 Likes
Accepted solutions (1)
421 Views
2 Replies
Replies (2)
Message 2 of 3

norman.yuan
Mentor
Mentor

Are you talking AutoCAD .NET Plugin(which is complied as DLL from .NET code)? 

 

If yes, the functionalities built into the DLL are exposed in AutoCAD process either as ExtensionApplication, which runs automatically when the DLL is loaded; or as commands (public methods decorated with [CommandMethod()] attributes. 

 

In your case, it sounds like you should define a few commands, which, when run,  could show corresponding forms (or do whatever, for that matter). Then you use standard AutoCAD menu/toolbar/shortcut(hot)keys customization approach to run your commands. I am sure you have already had some commands created, haven't you?

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 3

cengizincebi
Contributor
Contributor
Accepted solution

Hi Norman, Thanks for support. But my problem was different. Thanks.

 

I solved 😉  with AutocadDevBlog(By Madhukar Moogala). Thanks Madhukar.

Web pages;

-https://adndevblog.typepad.com/autocad/2016/03/adding-icon-next-to-custom-command.html

-https://adndevblog.typepad.com/autocad/2020/06/redefining-help-shortcut-key-with-cui-api.html

 

My Solution (for VB.NET);

-------------------------------------------------------

Public Sub AddTestCUI()
' https://adndevblog.typepad.com/autocad/2016/03/adding-icon-next-to-custom-command.html
' https://adndevblog.typepad.com/autocad/net/

Dim ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
Dim mainCuiFile As String = Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("MENUNAME")
mainCuiFile += ".cuix"

Try
Dim debugFolder As String = Path.GetDirectoryName(mainCuiFile)
Dim CustomizationSection As New CustomizationSection(mainCuiFile)
Dim macroGroups = CustomizationSection.MenuGroup.MacroGroups
Dim MacroGroup As MacroGroup

If macroGroups.Count = 0 Then
MacroGroup = New MacroGroup("MacroGroup", CustomizationSection.MenuGroup)
Else
MacroGroup = macroGroups(0)
Dim cName As String = "Deneme10-KomutGirişi"
Dim commandMacro = "' DENEME10-KOMUTGIRIŞI" + Command() '"^C^C_" + Command()
Dim commandId = "Cengiz_CE_0010_cID" + Command() ' "ID_" + Command()
Dim buttonId = "Cengiz_CE_0010_bID" + Command() ' "btn" + Command()
Dim labelId = "Cengiz_CE_0010_lID" + Command() '"lbl" + Command()

Dim menuMacro = MacroGroup.CreateMenuMacro(cName, commandMacro, "", "", MacroType.Any, "", "", labelId)
menuMacro.macro.Name = "CE_DENEME10-KOMUTGIRIŞI" 'Macro Name
menuMacro.macro.Command = "' DENEME10-KOMUTGIRIŞI" ' Macro comand
menuMacro.ElementID = "Cengiz_CE_0010" ' elementID
menuMacro.macro.type = MacroType.Any

'Assigning "CE_DENEME10-KOMUTGIRIŞI" to "CTRL+ALT+1"
If menuMacro.ElementID.Equals("Cengiz_CE_0010") Then
Dim acCollection As AcceleratorCollection = CustomizationSection.MenuGroup.Accelerators
Dim macCancel = New MenuAccelerator(menuMacro, "CTRL+ALT+1", CustomizationSection.MenuGroup)
End If

Dim macro = menuMacro.macro
macro.CLICommand = Command()
End If

File.Delete(mainCuiFile)
CustomizationSection.SaveAs(mainCuiFile)
Catch ex As Exception
ed.WriteMessage(Environment.NewLine + ex.Message)
End Try
End Sub

 

-------------------------------------------------------

 

Maybe someone will need it

 

Bye.

 

0 Likes