MerolaAlba
Automotive
Hi everyone,
I have a basic vba question.
I recorded a macro in CATVBA that allows the user to select a specific CATPart in an assembly, I'm going to insert it in a GUI via VBA editor to make a Slider "graphical menu" to speed up process of going up and down the spec tree and to make it attractive to management ;-)
I'm trying to alter a user selected parameter of a selected CATPart in an assembly via CADSelection. I've recorded the macro several times and tried to incorporate oSelection in several places and tweaked around with this for a while now, but i can't seem to finish this.
Am i declaring oSelection in the incorrect place, or am i missing something else?
My tree is:
Product;
-Part;
-Part_Teste_2;
-Part_Teste_3;
-Part_Teste_4;
-Part_Teste_5;
All of the above "Part_Teste" have 3 parameters one of them is called "Comprimento"
How do I change make sure that the macro alters the selected CATPArt's parameter instead of ("Part_Teste_3.CATPart")?
The macro that I have so far is:
I have a basic vba question.
I recorded a macro in CATVBA that allows the user to select a specific CATPart in an assembly, I'm going to insert it in a GUI via VBA editor to make a Slider "graphical menu" to speed up process of going up and down the spec tree and to make it attractive to management ;-)
I'm trying to alter a user selected parameter of a selected CATPart in an assembly via CADSelection. I've recorded the macro several times and tried to incorporate oSelection in several places and tweaked around with this for a while now, but i can't seem to finish this.
Am i declaring oSelection in the incorrect place, or am i missing something else?
My tree is:
Product;
-Part;
-Part_Teste_2;
-Part_Teste_3;
-Part_Teste_4;
-Part_Teste_5;
All of the above "Part_Teste" have 3 parameters one of them is called "Comprimento"
How do I change make sure that the macro alters the selected CATPArt's parameter instead of ("Part_Teste_3.CATPart")?
The macro that I have so far is:
Code:
Language="VBSCRIPT"
Sub CATMain()
Set oProductDoc = CATIA.ActiveDocument
Set oProd = oProductDoc.Product
Set oDocs = CATIA.Documents
Set oSelection = CATIA.ActiveDocument.Selection
If oSelection.Count < 1 then
MsgBox "Pick some components using cad selection.","No components were selected"
Else
Set oPartDoc = oDocs.Item("Part_Teste_3.CATPart")
Set oPart = oPartDoc.Part
Set oParam = oPart.Parameters
Set oLength = oParam.Item("Comprimento")
oLength.Value = 50.000000
End If
oSelection.Clear
oProd.Update
End Sub