JayEnn1
Automotive
- Sep 29, 2015
- 50
Good morning!
We have enjoyed using a nice macro from thread: thread560-435146, ( saving parts & products using part numbers as filenames )
but just recently ran into an issue where our customer has provided us with a CATShape item in the design. The macro seems
to crash/stop when it trys to process the CATShape. A work around is to remove the CATShape from the design, run macro, then
add the CATShape back into the design.
I've experimented around with the macro trying to get it to process or handle a CATShape with no luck. Could be because I don't
fully understand how CATShapes work considering their link to reference is to a CATProduct but it has its own CATShape file?
Any helpful ideas would be greatly appreciated. Here's the original macro.
CATIA.DisplayFileAlerts = False
Set oDocs = CATIA.Documents
docPath = oDocs.Item(1).Path
changePath = MsgBox("Current save location is: " & docPath & " Would you like to change file path?", vbYesNo)
If changePath = vbYes Then
docPath = InputBox("Enter new file path", "File path")
End If
For x = 1 To oDocs.Count
If TypeName(oDocs.Item(x)) = "ProductDocument" Then
Set oDoc1 = oDocs.Item(x)
Set oProduct1 = oDoc1.Product
oDoc1.SaveAs docPath & "\" & oProduct1.PartNumber & ".CATProduct"
End If
Next 'x
For v = 1 To oDocs.Count
If TypeName(oDocs.Item(v)) = "PartDocument" Then
Set oDoc2 = oDocs.Item(v)
Set oPart1 = oDoc2.Product
oDoc2.SaveAs docPath & "\" & oPart1.PartNumber & ".CATPart"
End If
Next 'v
Msgbox "Save Finished!",,"SAVE FINISH!"
End Sub
We have enjoyed using a nice macro from thread: thread560-435146, ( saving parts & products using part numbers as filenames )
but just recently ran into an issue where our customer has provided us with a CATShape item in the design. The macro seems
to crash/stop when it trys to process the CATShape. A work around is to remove the CATShape from the design, run macro, then
add the CATShape back into the design.
I've experimented around with the macro trying to get it to process or handle a CATShape with no luck. Could be because I don't
fully understand how CATShapes work considering their link to reference is to a CATProduct but it has its own CATShape file?
Any helpful ideas would be greatly appreciated. Here's the original macro.
CATIA.DisplayFileAlerts = False
Set oDocs = CATIA.Documents
docPath = oDocs.Item(1).Path
changePath = MsgBox("Current save location is: " & docPath & " Would you like to change file path?", vbYesNo)
If changePath = vbYes Then
docPath = InputBox("Enter new file path", "File path")
End If
For x = 1 To oDocs.Count
If TypeName(oDocs.Item(x)) = "ProductDocument" Then
Set oDoc1 = oDocs.Item(x)
Set oProduct1 = oDoc1.Product
oDoc1.SaveAs docPath & "\" & oProduct1.PartNumber & ".CATProduct"
End If
Next 'x
For v = 1 To oDocs.Count
If TypeName(oDocs.Item(v)) = "PartDocument" Then
Set oDoc2 = oDocs.Item(v)
Set oPart1 = oDoc2.Product
oDoc2.SaveAs docPath & "\" & oPart1.PartNumber & ".CATPart"
End If
Next 'v
Msgbox "Save Finished!",,"SAVE FINISH!"
End Sub