×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

PARAMETERS TO EXCEL

PARAMETERS TO EXCEL

RE: PARAMETERS TO EXCEL

Hello.

Selecting a "Geometrical Set", with this macro generates a text file.

CODE --> CATScrip

'##ALGORITMO CATScript
'Export parameters and values of Geometrical Set to txt File
Sub CATMain()
'Documento Activo
Dim oPartDoc As Part
On Error Resume Next
Set oPartDoc = CATIA.ActiveDocument.Part 
If Err.Number <> 0 Then                 
Message = MsgBox("This script only works with a CATPart as active document", vbCritical, "Error")
Exit Sub
End If
' What do want to select
Dim EnableSelectionFor(0)
  EnableSelectionFor(0) = "HybridBody"
' Reset the Selection
Set sSEL = CATIA.ActiveDocument.Selection
  sSEL.Clear
' Define Selection
  MsgBox "Select the 'Geometrical Set' where the parameters are"
  UserSelection = sSEL.SelectElement2(EnableSelectionFor, "Seleccione otro Geometrical Set", False)
' Evaluation if the selectio is correct or not
If UserSelection <> "Normal" Then
      MsgBox "Error con la seleccion"
    Exit Sub
Else
Set oGeoSet = sSEL.Item(1).Value
REM  MsgBox "The Geometrical Set select is : " & oGeoSet.Name
End If

Set ParametersList = CATIA.ActiveDocument.Part.Parameters
Set SubList = ParametersList.SubList(oGeoSet,FALSE)

'--------------------------------------------------------------------------------
'  Location where the file will be saved
'--------------------------------------------------------------------------------
Dim filename As String
filename = CATIA.FileSelectionBox("Where to save the resulting file?", "*.txt", CatFileSelectionModeSave)
Set Datos = CATIA.FileSystem.CreateFile(filename & ".txt" , True)
Set oSTR = Datos.OpenAsTextStream("ForAppending")
oSTR.Write ("Parameters extract to: " & oPartDoc.Name & ".CATPart" & Chr(10))
oSTR.Write ("The Geometrical Set select is : " & oGeoSet.Name & Chr(10))
oSTR.Write (" "& Chr(10))
oSTR.Write ("Line as: 'Name of Parameter = Value' "& Chr(10))
oSTR.Write (" "& Chr(10))

For i = 1 to SubList.Count
	Set Parameter = SubList.Item(i)
	oSTR.Write (Parameter.Name & " = " & Parameter.ValueAsString & "." & Chr(10) )
	REM MsgBox Parameter.Name & " = " & Parameter.ValueAsString
Next
oSTR.Close

MsgBox "Parameters export : " & (i-1) & "x"  & Chr(10) & "The file was saved in : "  &  chr(10) & filename & ".txt"& chr(10)&  chr(10) & "Process terminated    :D"
End Sub 

As usual, I hope it suits your needs

regards.
Urim

RE: PARAMETERS TO EXCEL

(OP)
works fine for one geo set. but if i choose several geo sets macro exports inly one geo set to txt.

RE: PARAMETERS TO EXCEL

If we could not mention a macro for once, that'd be great.

RE: PARAMETERS TO EXCEL

(OP)
what's wrong with that? if you want to talk about something else just go for a new thread.

RE: PARAMETERS TO EXCEL

A new thread...oh look, it's about a macro too! I'll write macros when I'm in my stone cold grave.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources