Lea75
Mechanical
- Feb 24, 2009
- 51
Hello:
I'd like to know how it would be the script code for extract the properties of the parts inside the product to a .txt file.
I could obtain the code for extracting parameters of single parts, but I need to get all of them in the hole product.
Can anyone help me?
I put above my code.
Regards
+++++++++++++++++++++++++++
Sub CATMain()
Dim partDoc As PartDocument
Set partDoc = CATIA.ActiveDocument
Dim partProd As Product
Set partProd = partDoc.Product
Dim prodProps As Parameters
Set prodProps = partProd.UserRefProperties
Dim catParmP0 As Parameter
Set catParmP0 = prodProps.Item("P0")
Dim catParmP1 As Parameter
Set catParmP1 = prodProps.Item("P1")
Dim catParmP2 As Parameter
Set catParmP2 = prodProps.Item("P2")
Dim catParmP5 As Parameter
Set catParmP5 = prodProps.Item("P5")
Dim catParmP6 As Parameter
Set catParmP6 = prodProps.Item("P6")
Dim catParmP7 As Parameter
Set catParmP7 = prodProps.Item("P7")
Dim catParmP9 As Parameter
Set catParmP9 = prodProps.Item("P9")
Dim catParmP11 As Parameter
Set catParmP11 = prodProps.Item("P11")
Dim catParmP13 As Parameter
Set catParmP13 = prodProps.Item("P13")
Dim catParmP15 As Parameter
Set catParmP15 = prodProps.Item("P15")
' GUARDAR EN BLOC DE NOTAS
Dim filename As String
filename = CATIA.FileSelectionBox("Donde quiere guardar el fichero de resultado", "*.txt", CatFileSelectionModeSave)
Set Datos = CATIA.FileSystem.CreateFile(partProd.Name & ".fre" , True)
Set ostream = Datos.OpenAsTextStream("ForAppending")
ostream.Write ("P0=K") & catParmP0.Value & (" P1=K") & catParmP1.Value & (" P2=K") & catParmP2.Value & (" P5=K") & catParmP5.Value & (" P6=K") & catParmP6.Value & (" P7=K") & catParmP7.Value & (" P9=K") & catParmP9.Value& (" P11=K") & catParmP11.Value & (" P13=K") & catParmP13.Value & (" P15=K") & catParmP15.Value & (" (") & partProd.Name & (")") & Chr(10)
ostream.Close ' cierra el fichero de texto
MsgBox "PARAMETROS GENERADOS" & Chr(10) & "POR FAVOR, COMPRUEBE LOS RESULTADOS EN LA CARPETA SELECCIONADA " & chr(10)
End Sub
I'd like to know how it would be the script code for extract the properties of the parts inside the product to a .txt file.
I could obtain the code for extracting parameters of single parts, but I need to get all of them in the hole product.
Can anyone help me?
I put above my code.
Regards
+++++++++++++++++++++++++++
Sub CATMain()
Dim partDoc As PartDocument
Set partDoc = CATIA.ActiveDocument
Dim partProd As Product
Set partProd = partDoc.Product
Dim prodProps As Parameters
Set prodProps = partProd.UserRefProperties
Dim catParmP0 As Parameter
Set catParmP0 = prodProps.Item("P0")
Dim catParmP1 As Parameter
Set catParmP1 = prodProps.Item("P1")
Dim catParmP2 As Parameter
Set catParmP2 = prodProps.Item("P2")
Dim catParmP5 As Parameter
Set catParmP5 = prodProps.Item("P5")
Dim catParmP6 As Parameter
Set catParmP6 = prodProps.Item("P6")
Dim catParmP7 As Parameter
Set catParmP7 = prodProps.Item("P7")
Dim catParmP9 As Parameter
Set catParmP9 = prodProps.Item("P9")
Dim catParmP11 As Parameter
Set catParmP11 = prodProps.Item("P11")
Dim catParmP13 As Parameter
Set catParmP13 = prodProps.Item("P13")
Dim catParmP15 As Parameter
Set catParmP15 = prodProps.Item("P15")
' GUARDAR EN BLOC DE NOTAS
Dim filename As String
filename = CATIA.FileSelectionBox("Donde quiere guardar el fichero de resultado", "*.txt", CatFileSelectionModeSave)
Set Datos = CATIA.FileSystem.CreateFile(partProd.Name & ".fre" , True)
Set ostream = Datos.OpenAsTextStream("ForAppending")
ostream.Write ("P0=K") & catParmP0.Value & (" P1=K") & catParmP1.Value & (" P2=K") & catParmP2.Value & (" P5=K") & catParmP5.Value & (" P6=K") & catParmP6.Value & (" P7=K") & catParmP7.Value & (" P9=K") & catParmP9.Value& (" P11=K") & catParmP11.Value & (" P13=K") & catParmP13.Value & (" P15=K") & catParmP15.Value & (" (") & partProd.Name & (")") & Chr(10)
ostream.Close ' cierra el fichero de texto
MsgBox "PARAMETROS GENERADOS" & Chr(10) & "POR FAVOR, COMPRUEBE LOS RESULTADOS EN LA CARPETA SELECCIONADA " & chr(10)
End Sub