I have a question that I'm sure once it clicks isn't super complicated (hopefully, lol) but at the moment I'm stuck.
I am currently writing a VBA in which I would like the user to make a selection within Catia, either on the part geometry, or within the spec tree, and have the CATPart which contains that selection end up being the destination for future operations. For example, I would like the user to identify a CATPart for which later operations will copy the main part bodies from other parts into the user selected CATPart if certain criteria are met.
Below is what I have for the user selection portion:
Dim oSel as Selection
Set oSel = CATIA.ActiveDocument.Selection
Dim oSelLB as Object
Set oSelLB = oSel
strArray(0) = "Part"
Dim sStatus as string
msgbox "Please select destination"
sStatus = oSelLB.SelectElement2(strArray, "Select part", False)
'The following line returns the name of the CATPart for the selection that was made.
'I just can't figure out an easier way to access the part to be able to paste other bodies into it later.
Dim DestName as String
DestName = oSelLB.Item(1).Value.Name
I am stuck at how to access the CATPart after the selection. I have tried to use the name of the selection to identify the CATPart and then search for the name, but this ends up making the program run time much longer than I believe it needs to be because it keeps having to perform a search every time it finds another part matching criteria it wishes to copy over.
Any help would be greatly appreciated!!! Thank you!