l3ob
Aerospace
- Apr 28, 2004
- 56
I have a VBscript that works well in a catpart but it fails in a catproduct. I want to be able to select the catpart or a sub-product within the top-product to make it active and/or set the partdocument from the list of documents within the product. In the code below, assuming I don't know the name of document "PartName.CATPart", I need to have code to select the tree item and Set partDoc1 from that selection.
Sub CATMain()
Set doc1 = CATIA.Documents
'--------------
Set partDoc1 = doc1.Item("PartName.CATPart")
>>> name not known, so I need to replace this line
>>> with selection process below
'--------------
InputObjectType(0)= "AnyObject"
Set oSelA = doc1.Selection
oSelA.clear
Result = oSelA.SelectElement(InputObjectType, "Select Tree Item", False)
If Result = "Cancel" Then
MsgBox ("Command Canceled")
Exit Sub
End If
Set partDoc1 = oSelA.Item(1)
>>>> this is where I'm stuck. I can't get the document
>>>> out of the selection to set partDoc1
Set part1 = partDoc1.Part
Set hybridShapeFactory1 = part1.HybridShapeFactory
Sub CATMain()
Set doc1 = CATIA.Documents
'--------------
Set partDoc1 = doc1.Item("PartName.CATPart")
>>> name not known, so I need to replace this line
>>> with selection process below
'--------------
InputObjectType(0)= "AnyObject"
Set oSelA = doc1.Selection
oSelA.clear
Result = oSelA.SelectElement(InputObjectType, "Select Tree Item", False)
If Result = "Cancel" Then
MsgBox ("Command Canceled")
Exit Sub
End If
Set partDoc1 = oSelA.Item(1)
>>>> this is where I'm stuck. I can't get the document
>>>> out of the selection to set partDoc1
Set part1 = partDoc1.Part
Set hybridShapeFactory1 = part1.HybridShapeFactory