jmarkus
Mechanical
- Jul 11, 2001
- 377
Hi,
I'm trying to step through a CATProduct (and all sub-products) and display each level at a time with the following routine. It works the first time through, and the second time it shows me the selection contains the right items, but it doesn't apply the HIDE to them.
For example.
In the first step it turns off CATProduct A & B, but then it reports the selection CATParts a,b, & c but doesn't turn them off.
What am I missing?
Thanks (as always),
Jeff
I'm trying to step through a CATProduct (and all sub-products) and display each level at a time with the following routine. It works the first time through, and the second time it shows me the selection contains the right items, but it doesn't apply the HIDE to them.
For example.
Code:
CATProduct 1
containing CATProduct A
containing CATPart a
containing CATPart b
containing CATPart c
containing CATProduct B
containing CATPart i
containing CATPart ii
containing CATPart iii
Code:
Sub CATMAIN()
Dim documentlist
Dim MainDocument As ProductDocument
Set documentlist = CATIA.Documents
Set MainDocument = CATIA.ActiveDocument
Set oTopProduct = MainDocument.Product
Call TurnOff(oTopProduct)
End Sub
Sub TurnOff(oTopProduct)
Dim selection1 As Selection
Set selection1 = oTopProduct.Parent.Selection
Dim visPropertySet1 As VisPropertySet
Set visPropertySet1 = selection1.VisProperties
Dim ItemToHide As Product
Dim lNumberOfItems As Long
lNumberOfItems = oTopProduct.Products.Count
For i = 1 to lNumberOfItems
Set ItemToHide = oTopProduct.Products.Item(i)
selection1.Add ItemToHide
SelectionList = SelectionList & chr(10) & selection1.Item(i).LeafProduct.Name
next
MsgBox "Selection is " & SelectionList
Set visPropertySet1 = selection1.VisProperties
VisPropertySet1.SetShow 1 'HIDE
MsgBox "Selected components should be off"
Dim k,m
k = ItemToHide.Products.Count
For m = 0 to k
VisPropertySet1.SetShow 0 'SHOW
Call TurnOff(ItemToHide.ReferenceProduct)
VisPropertySet1.SetShow 1 'HIDE
Next
End Sub
What am I missing?
Thanks (as always),
Jeff