×
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

Exporting properties/parameter to text file

Exporting properties/parameter to text file

Exporting properties/parameter to text file

(OP)
Bit of a newb to VB in Catia and still working to get my head around the object structure.

I urgently need to put something together like the one in the thread560-308328: Script to export properties to Excel? from ntweisen to loop through the bodies in a part and pull out parameters.

The code below is a combination of parts of the above but it misses the loops and steps straight to writing the file and fails there as the datum isn't set.

Sub CATTextOuput()

Dim partDoc As PartDocument
Set partDoc = CATIA.ActiveDocument

Dim partProd As Product
Set partProd = partDoc.Product

Dim filename As String
filename = partDoc.Name
Version = partProd.Revision
Description = partProd.DescriptionRef

'Dim partcount As Integer
Dim Namebody As String
Dim bodynumber As Integer

Dim Part1 As Part
Set Part1 = partDoc.Part

Dim i As Integer

For i = 1 To partcount

Dim j As Integer
bodynumber = Part1.Bodies.Count

For j = 1 To bodynumber

Dim Body1 As Body
Set Body1 = Part1.Bodies.Item(j)
Namebody = Body1.HybridBodies(1)
Next 'j
Next 'i

Dim path As String
path = CATIA.ActiveDocument.path

Set Datos = CATIA.FileSystem.CreateFile(path & "\" & CATIA.ActiveDocument.Name & ".txt", True)
Set ostream = Datos.OpenAsTextStream("ForAppending")

'ostream.Write CATIA.ActiveDocument.Name & Chr(10)
ostream.Write "Name: " & filename & Chr(10)
ostream.Write "Version: " & Version & Chr(10)
ostream.Write "Description: " & Description & Chr(10)
ostream.Write "Namebody: " & Namebody & Chr(10)

ostream.Close

MsgBox "Check results in folder " & Chr(10) & path & "\" & Chr(10) & Chr(10) & "File:" & Chr(10) & partDoc.Name & ".txt" & Chr(10)

End Sub

Thanks in advance

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