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!

Macro palette for coloring 2

Status
Not open for further replies.

HarunMusic

Computer
Nov 21, 2014
71
BA
I find this macro, but it wont work, i can run it from windows but i it wont work, i cant run it from catia. I m using win7 x64 and CATIA V5 R20.
' COLORS, (c)ema, lm:1.4.2009
'
form="v:\vbscripts\vbs\e3colors.exe"
form="V:\vb6\Visual Studio 2008\Projects\e3colors\e3colors\bin\Debug\e3colors.exe"
'
Language="VBSCRIPT"
Sub CATMain()
' ******************************* test if part is open ********************************
' 'If CATIA is open but no documents are open, exit sub.
' If CATIA.Documents.Count = 0 Then
' 'MsgBox "There is no CATIA Part file open. Open a Part file and run this script again.", ,msgboxtext
' MsgBox "Neni otevreny catpart. Otevri Part a spust program znovu.", ,msgboxtext
' Exit Sub
' End If
' 'If a Product, Drawing, etc is active, exit sub
' If InStr(CATIA.ActiveDocument.Name, ".CATPart") < 1 Then
' 'MsgBox "Active CATIA Document is not a Part. Open a Part file and run this script again.", ,msgboxtext
' MsgBox "Otevreny dokument neni catpart. Otevri Part a spust program znovu.", ,msgboxtext
' Exit Sub
' End If
' ******************************* variables *******************************************
Set cad = CATIA.ActiveDocument
' Set hsf = cad.Part.HybridShapeFactory
' Set spa = cad.GetWorkbench("SPAWorkbench")
' Set prt = cad.Part
Set vis = cad.Selection.VisProperties
' Set spa = cad.GetWorkbench("SPAWorkbench")
' Set viewer = CATIA.ActiveWindow.ActiveViewer
Set objNetwork = CreateObject("Wscript.Network")
msgboxtext="e3colors - barva dobra"
demo=0
' ******************************* set color of selected elements **********************
if(cad.Selection.count=0)then
msgbox "Neni vybran zadny element k obarveni." & vbCrLf & "Vyber plochy a spust makro znovu.", ,msgboxtext
exit sub
end If
rc = CATIA.SystemService.ExecuteProcessus("'"+form+"'")
if Err.Number <> 0 Then
msgbox "Nelze spustit tabulku pro nastaveni barev:" & vbCrLf & form, ,msgboxtext
exit sub
end If
' msgbox rc
if(rc=0)then
exit sub
end if
if(rc>15)then
msgbox "Invalid return code:" & rc, ,msgboxtext
exit sub
end if
if(demo=1)then
msgbox "demo mode running ..." & vbCrLf & "only red color is available as an example" & vbCrLf & "contact x@ema3.com to get licence", ,msgboxtext
vis.SetRealColor 255,0,0,0
cad.Selection.Clear
exit sub
end if
if(rc=1)then
vis.SetRealColor 175,255,175,0
end if
if(rc=2)then
vis.SetRealColor 255,255,175,0
end if
if(rc=3)then
vis.SetRealColor 255,175,175,0
end if
if(rc=4)then
vis.SetRealColor 95,0,0,0
end if
if(rc=5)then
vis.SetRealColor 95,95,175,0
end if
if(rc=6)then
vis.SetRealColor 95,0,95,0
end if
if(rc=7)then
vis.SetRealColor 0,0,255,0
end if
if(rc=8)then
vis.SetRealColor 0,0,95,0
end if
if(rc=9)then
vis.SetRealColor 255,255,0,0
end if
if(rc=10)then
vis.SetRealColor 255,175,0,0
end if
if(rc=11)then
vis.SetRealColor 255,95,0,0
end if
if(rc=12)then
vis.SetRealColor 255,0,255,0
end if
if(rc=13)then
vis.SetRealColor 0,175,175,0
end if
if(rc=14)then
vis.SetRealColor 0,127,255,0
end if
if(rc=15)then
vis.SetRealColor 255,1255,255,0
end if
cad.Selection.Clear
End Sub
 
Replies continue below

Recommended for you

Hi,

As you can see, there are some paths and exe files set in this macro...

form="v:\vbscripts\vbs\e3colors.exe"
form="V:\vb6\Visual Studio 2008\Projects\e3colors\e3colors\bin\Debug\e3colors.exe"

What do you want exactly? If you want to color some features in CATPart in a specific colors, this can be done easy with your own macro.

Regards
Fernando

 
i want to make palette of maybe 10 colors, which i frequently use, but i don't know how ...
 
i don't want to kill ema3.com business but it seems that if you make your own form with those 15 buttons you could reuse most of this code.

Eric N.
indocti discant et ament meminisse periti
 
I wish that my palette is always open when I'm working in CATIA, it is always there. The way I used it the following: first select the surface or surfaces and then click the color in the palette, and so on.

thx for helping
 
you can have the graphic properties toolbar open all the time. this will come with a color function where you can add your own personal colors.

Eric N.
indocti discant et ament meminisse periti
 
Yes u can, indeed, i used tool bar and the graphic properties and i know difference between, so if u can help don't act smart guy.
 
Of course, i m very thankful to u, every time u answer to my post, but i don't like people who act like smart guys. Every time i have good reasons for my questions, and people on this forum relay help me with 2 3 things.

Thx again.
 
star for you ferdo!

[noevil]

Eric N.
indocti discant et ament meminisse periti
 
you post on this forum a sample from another web site. Did you ask the owner of this code about your problem?
How familiar are you with VBA?

Eric N.
indocti discant et ament meminisse periti
 
i did not, i think that was web page with macros, not forum, and i m very bad with VBA, that s why im posting here, i need few things and i don't have time or will to learn it, so, indeed i m lazy to do it by my own.
 
easiest, fastest,and more efficient way would be to contact the developer

download.aspx


Eric N.
indocti discant et ament meminisse periti
 
Eric; could you share the address of the CATIA Macro website. Looks like a good source of macros.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top