How to define alias for autocad command using vb.net?

How to define alias for autocad command using vb.net?

williamdepadua
Enthusiast Enthusiast
1,928 Views
7 Replies
Message 1 of 8

How to define alias for autocad command using vb.net?

williamdepadua
Enthusiast
Enthusiast

Hi! I want to set shortcuts to my .Net commands. For sample:

 

My routine 

 

<Autodesk.AutoCad.Runtime.CommandMethod("bomdia")>

Public Sub BomDia()

 

MsgBox("BomDia") 

 

End Sub

 

Name command: bomdia

Alies command: bd

 

I know that it is possible to edit the acad.pgp file using FileSystem, but I wonder if there is any native or correct way to be done

 

Thank you

0 Likes
Accepted solutions (2)
1,929 Views
7 Replies
Replies (7)
Message 2 of 8

seabrahenrique
Advocate
Advocate

Hello!

 

I really don't know if is there another way to add an alias instead the acad.pgp edition (in my knowledge, okay?)

 

But a simple suggestion is to create another command method call the same function, you know?

 

For example:

 

<Autodesk.AutoCad.Runtime.CommandMethod("bomdia")>

Public Sub BomDia()

 

MsgBox("BomDia") 

 

End Sub

 

<Autodesk.AutoCad.Runtime.CommandMethod("bd")>

Public Sub

 

Call BomDia

 

End sub

 

Got it?

0 Likes
Message 3 of 8

williamdepadua
Enthusiast
Enthusiast

Thanks for your reply, but I would like to allow the user to set their shortcuts through a custom interface. Without having to resort to acad.pgp

0 Likes
Message 4 of 8

seabrahenrique
Advocate
Advocate
Accepted solution

Right.

 

If u want to make a interface to your user customize that shortcuts, inevitably you gonna make some "place" to save that preferences, agree? (like a txt file, the acad.pgp itself,  windows register.. etc).

 

(If not, the user will have to redo his shortcuts every time he starts AutoCAD)

 

Thinking that, another suggestion is to make a lisp file and attach to your application, and in that lisp file you can add some personalize shortcuts commands to call your .NET commands, you know? And then, you programming (with a filestream class) a interface to user changing this shortcuts and save in your lisp file....

 

But again: Maybe is there a more simple way to add shortcuts like a way that you want... but i really don't know and did not find here in a quick search... So, it's only a suggestion, and may another colleague here has a better one.

Message 5 of 8

williamdepadua
Enthusiast
Enthusiast
Liked! Thank you!
I'm just confused about this lisp file, when I have to save cofigurations, I use My.Settings which I believe is embedded in DLL.
I do not know how to work with lisp.
How do I do it?
0 Likes
Message 6 of 8

seabrahenrique
Advocate
Advocate
Accepted solution

Do you have a .cuix file in your application? (I guess so, because is a very useful file)

 

So you simply can put your lisps here:

 

seabrahenrique_0-1672325486796.png

 

Here a tutorial to cuix files if you don't know yet.

Message 7 of 8

williamdepadua
Enthusiast
Enthusiast

Amazing!
I did the manual test and it worked perfectly
But I'm not able to load the lisp programmatically, I have a particular cuix and I want to carry the lisps for it.

My code:

Public Sub LoadLispToCuix(FileNameCuix As String, FileNameLisp As String)


Dim menuName As String = Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("MENUNAME")
Dim maincs As Autodesk.AutoCAD.Customization.CustomizationSection = New Autodesk.AutoCAD.Customization.CustomizationSection(menuName + ".cuix")
Dim Cs As Customization.CustomizationSection

If maincs.PartialCuiFiles.Contains("PROCESS.cuix") = True Then

Cs = New Autodesk.AutoCAD.Customization.CustomizationSection("PROCESS.cuix")

Else
Try
LoadMyCui(FileNameCuix)
Cs = New Autodesk.AutoCAD.Customization.CustomizationSection("PROCESS.cuix")
Catch ex As Exception
MsgBox("Não foi possível carregar o arquivo de costumização no caminho: " & vbCrLf & FileNameCuix)
Exit Sub
End Try
End If


Cs.MenuGroup.LspFile(FileNameLsp) 'Not work


Cs.Save()

End Sub

0 Likes
Message 8 of 8

williamdepadua
Enthusiast
Enthusiast

I've been researching and it seems that someone has already come across this problema.

https://forums.autodesk.com/t5/net/add-to-the-cui-quot-lisp-files-quot-section-using-net/m-p/5029990...

That worked!