TheKyle9
Mechanical
- Oct 1, 2015
- 14
Hi guys and gals,
I am trying write a macro that the user selects a part within an assembly, an .exe file opens, the user selects a color from a chart, and the whole part color is changed in CATIA. I understand this can all be done within CATIA, but I am trying some new things with my limited programming skills... which aren't very good
Thus far, I can run the macro in catia, and my external vb macro pops up, which is good. My question is: how do I send the result selection BACK into the catia macro so Catia know to change the color of the parts to the selected result?
How I would like this to function:
user selects a single part within an open assembly
macro is run
macro finds and selects all parts with same name
macro opens .exe
user picks color from list
all selected parts are changed to the color requested
First I will paste my Catia script
Second, What my VB color chart looks like
Third, What my code for my color table looks like
Here is what I have in as my catia macro:
Sub CATMain()
form="Y:\AUB\TRB\08 Pool\Schoeberlein\Catia Macro\COLORtable\COLORtable\obj\Release\COLORtable.exe"
dim Part1 'as Document
set Part1 = CATIA.ActiveDocument
dim Select1 'as Selection
set Select1 = Part1
''''''''''''''''''''''''''''''''Selects all parts with same name
'Select1.search.............
'''''''''''''''''''''''''''''''''Pulls External Color Table From .exe
Color = CATIA.SystemService.ExecuteProcessus("'"+form+"'")
''''''''''''''''''''''''''''''''Color Chart
'Green
if(Color=1) then
Select1= 192, 255, 192
end if
'Red
if(Color=2) then
Select1= 255, 128, 128
end if
'Blue
if(Color=3) then
Select1= 128, 255, 255
end if
'Yellow
if(Color=4) then
Select1= 255, 255, 128
end if
'White-ish
if(Color=5) then
Select1= 224, 224, 224
end if
End Sub
Here is an image of what my vb color table form looks like:
Finally, here is the code for my color table:
Public Class Form1
Private Sub green1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles green1.Click
Dim colorgreen As String
colorgreen = "Green"
TextBox1.Text = colorgreen
End Sub
Private Sub reset1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles reset1.Click
Dim clear As String
clear = " "
TextBox1.Text = clear
End Sub
Private Sub red1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles red1.Click
Dim colorred As String
colorred = "Red"
TextBox1.Text = colorred
End Sub
Private Sub blue1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles blue1.Click
Dim colorblue As String
colorblue = "Blue"
TextBox1.Text = colorblue
End Sub
Private Sub yellow1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles yellow1.Click
Dim coloryellow As String
coloryellow = "Yellow"
TextBox1.Text = coloryellow
End Sub
Private Sub white1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles white1.Click
Dim colorwhite As String
colorwhite = "White"
TextBox1.Text = colorwhite
End Sub
End Class
Hopefully I've explained what I'm trying to do well enough for some blanks to be filled in.
Thank you for your assistance
-Kyle
I am trying write a macro that the user selects a part within an assembly, an .exe file opens, the user selects a color from a chart, and the whole part color is changed in CATIA. I understand this can all be done within CATIA, but I am trying some new things with my limited programming skills... which aren't very good
Thus far, I can run the macro in catia, and my external vb macro pops up, which is good. My question is: how do I send the result selection BACK into the catia macro so Catia know to change the color of the parts to the selected result?
How I would like this to function:
user selects a single part within an open assembly
macro is run
macro finds and selects all parts with same name
macro opens .exe
user picks color from list
all selected parts are changed to the color requested
First I will paste my Catia script
Second, What my VB color chart looks like
Third, What my code for my color table looks like
Here is what I have in as my catia macro:
Sub CATMain()
form="Y:\AUB\TRB\08 Pool\Schoeberlein\Catia Macro\COLORtable\COLORtable\obj\Release\COLORtable.exe"
dim Part1 'as Document
set Part1 = CATIA.ActiveDocument
dim Select1 'as Selection
set Select1 = Part1
''''''''''''''''''''''''''''''''Selects all parts with same name
'Select1.search.............
'''''''''''''''''''''''''''''''''Pulls External Color Table From .exe
Color = CATIA.SystemService.ExecuteProcessus("'"+form+"'")
''''''''''''''''''''''''''''''''Color Chart
'Green
if(Color=1) then
Select1= 192, 255, 192
end if
'Red
if(Color=2) then
Select1= 255, 128, 128
end if
'Blue
if(Color=3) then
Select1= 128, 255, 255
end if
'Yellow
if(Color=4) then
Select1= 255, 255, 128
end if
'White-ish
if(Color=5) then
Select1= 224, 224, 224
end if
End Sub
Here is an image of what my vb color table form looks like:
Finally, here is the code for my color table:
Public Class Form1
Private Sub green1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles green1.Click
Dim colorgreen As String
colorgreen = "Green"
TextBox1.Text = colorgreen
End Sub
Private Sub reset1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles reset1.Click
Dim clear As String
clear = " "
TextBox1.Text = clear
End Sub
Private Sub red1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles red1.Click
Dim colorred As String
colorred = "Red"
TextBox1.Text = colorred
End Sub
Private Sub blue1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles blue1.Click
Dim colorblue As String
colorblue = "Blue"
TextBox1.Text = colorblue
End Sub
Private Sub yellow1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles yellow1.Click
Dim coloryellow As String
coloryellow = "Yellow"
TextBox1.Text = coloryellow
End Sub
Private Sub white1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles white1.Click
Dim colorwhite As String
colorwhite = "White"
TextBox1.Text = colorwhite
End Sub
End Class
Hopefully I've explained what I'm trying to do well enough for some blanks to be filled in.
Thank you for your assistance
-Kyle