HarunMusic
Computer
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
' 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