Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub CATMain()
- 'Error handling in case of empty CATIA window, no open objects.
- On Error Resume Next
- Set currDocument = CATIA.ActiveDocument
- If Err.Number <> 0 Then
- Err.Clear
- MsgBox "An assembly file needs to be opened and active for this macro.", vbCritical, "Wrong context"
- Exit Sub
- End If
- IF Instr(CATIA.ActiveDocument.Name,".CATProduct") THEN
- sFilePath = CATIA.ActiveDocument.Path + "\"
- ExportNextProduct CATIA.ActiveDocument.Product, sFilePath
- Else
- MsgBox "An assembly file needs to be opened and active for this macro.", vbCritical, "Wrong context"
- END IF
- MsgBox "STP file export complete.", vbInformation, "Finished"
- End Sub
- Sub ExportNextProduct(oCurrentProduct as Product, sFilePath as String)
- Dim oCurrentTreeNode As Product
- Set FileSys = CATIA.FileSystem
- For i = 1 To oCurrentProduct.Products.Count
- Set oCurrentTreeNode = oCurrentProduct.Products.Item(i)
- sFileName = oCurrentTreeNode.Nomenclature + " " + oCurrentTreeNode.DescriptionRef + ".stp"
- IF oCurrentTreeNode.Source = catProductMade and oCurrentTreeNode.Definition <> "ASM" Then
- IF FileSys.FileExists(sFilePath + sFileName) = FALSE Then
- oCurrentTreeNode.ReferenceProduct.Parent.ExportData sFilePath + sFileName, "stp"
- END IF
- END If
- If oCurrentTreeNode.Products.Count > 0 AND oCurrentTreeNode.Definition = "ASM" Then
- ExportNextProduct oCurrentTreeNode, sFilePath
- END If
- Next
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement