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 Main()
Dim doc, sel, setName
setName = "Example"
Set doc = CATIA.ActiveDocument
Set sel = doc.Selection
Dim selSets
Set selSets = doc.Product.GetItem("CATIAVBSelectionSetsImpl") ' get SelectionSets object (a tricky part)
selSets.CreateSelectionSet setName ' create new selection set
selSets.AddCSOIntoSelectionSet setName ' add selected elements to selection set
sel.Clear
selSets.PutSelectionSetIntoCSO setName ' activate the content of selection set
' Dim a()
' selSets.GetListOfSelectionSet a
End Sub
Sub CATMain()
Dim SelCheck As Integer
SelCheck = CATIA.ActiveDocument.Selection.Count2
Dim HCheck As String
If SelCheck = 0 Then
MsgBox ("Items must be selected first")
Exit Sub
End If
If SelCheck <= 1 Then
HCheck = MsgBox("Are child components highlighted?", vbYesNo)
If HCheck = vbNo Then
MsgBox ("Hightlight items to be added and try again")
Exit Sub
End If
End If
Dim doc, sel, setName
Set doc = CATIA.ActiveDocument
Set sel = doc.Selection
Dim product1 As Product
Set product1 = doc.Product
Dim i As Integer
i = 1
Dim n As Integer
n = CATIA.ActiveDocument.Selection.Count2
Dim selSets
Dim NameCheck As String
Dim iSel As Selection
ReDim SelComp(n)
Dim Test As String
If CATIA.ActiveDocument.Selection.Count2 = 1 Then
setName = sel.Item(1).Value.PartNumber
Set selSets = doc.Product.GetItem("CATIAVBSelectionSetsImpl") ' get SelectionSets object (a tricky part)
selSets.CreateSelectionSet setName ' create new selection set
selSets.AddCSOIntoSelectionSet setName ' add selected elements to selection set
Else
NameCheck = MsgBox("Do you want each item to have a selection set?", vbYesNo)
If NameCheck = vbYes Then
For i = 1 To n
Set SelComp(i) = sel.Item(i).Value
Next
For i = 1 To n
Set iSel = CATIA.ActiveDocument.Selection
iSel.Clear
iSel.Add SelComp(i)
setName = iSel.Item(1).Value.PartNumber
Set selSets = doc.Product.GetItem("CATIAVBSelectionSetsImpl") ' get SelectionSets object (a tricky part)
selSets.CreateSelectionSet setName ' create new selection set
selSets.AddCSOIntoSelectionSet setName ' add selected elements to selection set
Next
Else
setName = InputBox("Selection Set Name", "Input Selection Set Name", sel.Item(1).Value.PartNumber)
Set selSets = doc.Product.GetItem("CATIAVBSelectionSetsImpl") ' get SelectionSets object (a tricky part)
selSets.CreateSelectionSet setName ' create new selection set
selSets.AddCSOIntoSelectionSet setName ' add selected elements to selection set
End If
End If
End Sub
sel.Clear
selSets.PutSelectionSetIntoCSO setName ' activate the content
selSets.CreateSelectionSet setName ' create new selection set
selSets.AddCSOIntoSelectionSet setName ' add selected elements to selection set