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!

Exporting properties/parameter to text file

Status
Not open for further replies.

cmcg24

Aerospace
Oct 23, 2014
1
US
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 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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top