XButton CATIA macro
Introduction
Have you ever thought about how to use those two side buttons on your mouse? For home use, you can always download some software like X-Mouse Button Control and get a lot of options. But sometimes you can’t install this software because of administrator rights or because it’s not safe to download a portable version. So if you are in this situation you are like me. Therefore I tried to find a solution for this problem. Hence I want to write a simple Xbutton CATIA macro application.
Write code for XButton CATIA macro
The code is very simple but I was searching for an idea for a long time. You will need to use a timer so it can register your mouse click.
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick If MouseButtons = System.Windows.Forms.MouseButtons.XButton1 Then End if End Sub
This is a kind of container for your macros, so you can put any macro inside of that. You must import System.Windows.Forms.MouseButtons for this solution to work.
I wrote hide/show macro for Xbutton1 CATIA macro so here is the code.
Dim productDocument1 As Document productDocument1 = MyCATIA.ActiveDocument Dim selection1 As Selection Dim showstate As CatVisPropertyShow selection1 = productDocument1.Selection Dim visPropertySet1 visPropertySet1 = selection1.VisProperties visPropertySet1.GetShow(showstate) Select Case showstate Case CatVisPropertyShow.catVisPropertyNoShowAttr visPropertySet1.SetShow(0) Case CatVisPropertyShow.catVisPropertyShowAttr visPropertySet1.SetShow(1) End Select selection1.Clear()
Certainly, this is a very simple macro. There are two cases, one of the element is in hide and other if the element is in show mode.
The second macro from the Xbutton CATIA macro application is open in a new window. You can select one or more parts and hit Xbutton2 and it will open one or more parts in a new window.
Dim selection As Selection Selection = MyCATIA.activedocument.selection For i = 1 To selection.Count MyCATIA.StartCommand(“Open in New Window”) Next End If
If you want to use this macro you must be in a product or assembly environment. You can work more on these macros due to make them better. Maybe you will get some better ideas.
The only problem with this solution is when you use side mouse buttons in windows or in google chrome it also makes actions in CATIA. So be careful or hide a lot of elements if those are selected.
You can download it for free and use it. If you have any issues feel free to contact me.