Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Sub CATMain()
'Dim oPartDoc As PartDocument
For i = 1 To CATIA.Documents.Count
Set oPartDoc = CATIA.Documents.Item(i)
If TypeName(oPartDoc) = "PartDocument" Then
'dim oSelection as selection
Set oSelection = oPartDoc.Selection
oSelection.Search "(CATPrtSearch.AxisSystem.Visibility=Visible + (CATPrtSearch.Surface.Visibility=Visible + (CATPrtSearch.Wireframe.Visibility=Visible + CATPrtSearch.Sketch.Visibility=Visible))),all"
oSelection.VisProperties.SetShow catVisPropertyNoShowAttr
oPartDoc.ExportData oPartDoc.Path & "\" & oPartDoc.Product.PartNumber, "stp"
oSelection.Clear
Set oSelection = Nothing
End If
Next
End Sub
Sub CATMain()
'cancel alerts for now
CATIA.DisplayFileAlerts = False
'exit Sub if the active document is not a CATProduct
If TypeName(CATIA.ActiveDocument) <> "ProductDocument" Then GoTo exitSub
'initialize the selection
Set oSelection = CATIA.ActiveDocument.Selection
'exit Sub if there is nothing selected
If oSelection.Count = 0 Then GoTo exitSub
'create some sort of collection to hold the selected items
'you could use Collection object instead of Scripting.Dictionary
'depending on how you want this to run
Set oDic = CreateObject("Scripting.Dictionary")
For i = 1 To oSelection.Count
'the assumption is that Products are selected and nothing else
Set oSelectedObject = oSelection.Item(i).Value
If TypeName(oSelectedObject) = "Product" Then
oDic.Add i, oSelectedObject.ReferenceProduct.Parent
End If
Next
'check again the validity of selected elements and exit if
'your custom collection is empty (i.e. no proper element has been selected)
If oDic.Count = 0 Then GoTo exitSub
'search the selection for elements to hide
oSelection.Search "(CATPrtSearch.AxisSystem.Visibility=Visible + (CATPrtSearch.Surface.Visibility=Visible + (CATPrtSearch.Wireframe.Visibility=Visible + CATPrtSearch.Sketch.Visibility=Visible))),all"
oSelection.VisProperties.SetShow catVisPropertyNoShowAttr
oSelection.Clear
'loop inside your custom collection and export each document.
For i = 1 To oDic.Count
Set oProdDoc = oDic.Item(i)
oProdDoc.ExportData oProdDoc.Path & "\" & oProdDoc.Product.PartNumber, "stp"
Next
'Exit sub
exitSub:
CATIA.DisplayFileAlerts = True
End Sub
Sub CATMain()
'cancel alerts for now
CATIA.DisplayFileAlerts = False
'exit Sub if the active document is not a CATProduct
If TypeName(CATIA.ActiveDocument) <> "ProductDocument" Then Exit Sub
'initialize the selection
Set oSelection = CATIA.ActiveDocument.Selection
'exit Sub if there is nothing selected
If oSelection.Count = 0 Then Exit Sub
'create some sort of collection to hold the selected items
'you could use Collection object instead of Scripting.Dictionary
'depending on how you want this to run
Set oDic = CreateObject("Scripting.Dictionary")
For i = 1 To oSelection.Count
'the assumption is that Products are selected and nothing else
Set oSelectedObject = oSelection.Item(i).Value
If TypeName(oSelectedObject) = "Product" Then
oDic.Add i, oSelectedObject.ReferenceProduct.Parent
End If
Next
'check again the validity of selected elements and exit if
'your custom collection is empty (i.e. no proper element has been selected)
If oDic.Count = 0 Then Exit Sub
'search the selection for elements to hide
oSelection.Search "(CATPrtSearch.AxisSystem.Visibility=Visible + (CATPrtSearch.Surface.Visibility=Visible + (CATPrtSearch.Wireframe.Visibility=Visible + CATPrtSearch.Sketch.Visibility=Visible))),all"
oSelection.VisProperties.SetShow catVisPropertyNoShowAttr
oSelection.Clear
'loop inside your custom collection and export each document.
For i = 1 To oDic.Count
Set oProdDoc = oDic.Item(i)
oProdDoc.ExportData oProdDoc.Path & "\" & oProdDoc.Product.PartNumber, "stp"
Next
End Sub