Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Back feed results from an exe into catia

Status
Not open for further replies.

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:
Capture_v4nd6a.jpg


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
 
Replies continue below

Recommended for you

Hello Ferdo,

My catia macro is in (Catvbs)

No, I do not absolutely an external program, but would like to know how to backfeed the results from an external program into catia. Purely learning purposes.

Im using windows7

-Kyle
 
Understood.

The program has to be designed specially to communicate with CATIA otherwise is useless. Check these threads please. If you cannot manage, come back with questions.

It would be much easier in catvba (second option) but I saw many companies which doesn't have installed vba for CATIA (even if they have for MSOffice). This would be the third option, use Office to work with CATIA (search also in forum for some examples done in Excel).

Regards
Fernando

- Romania
- EU
 

you might not need a connection from your color.exe to catia...

your script should run like this:

make selection then run you color.exe and wait for return code (the color selected)

use the return of the exe to color your parts.



Eric N.
indocti discant et ament meminisse periti
 
okay, thanks fellas, Ill delve more into this on my own and see if I can come up with anything better-

hopefully once I get something more concrete, I'll re post and you guys can take a look...

thanks,
Kyle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor