Hide / Show in a product
Hide / Show in a product
(OP)
Hello,
I have an assembly , who contains sub-assemblies and parts.
I try to create a macro to hide all parts or products named "Test" , but it not works:
Sub CATMain()
Dim oProdDoc As ProductDocument
Set oProdDoc = CATIA.ActiveDocument
Dim oRootProd As Product
Set oRootProd = oProdDoc.Product
Dim Selection As Selection
Set Slelection = oProdDoc.Selection
Call Hide_Test(oRootProd, Selection)
End Sub
Sub Hide_Test(oInProduct, Selection1)
Dim oInstances As Products
Set oInstances = oInProduct.Product.Products
'-----No instances found then this is CATPart
If oInstances.Count = 0 Then
Selection1.Add oInProduct
If (oInProduct.PartNumber = "Test") Then
Selection1.VisProperties.SetShow catVisPropertyNoShowAttr
Else
Selection1.VisProperties.SetShow catVisPropertyShowAttr
End If
Selection1.Clear
'Exit Sub
Else
'-----Found an instance therefore it is a CATProduct
Selection1.Add oInProduct.ReferenceProduct
If (oInProduct.ReferenceProduct.PartNumber = "Test") Then
Selection1.VisProperties.SetShow catVisPropertyNoShowAttr
Else
Selection1.VisProperties.SetShow catVisPropertyShowAttr
End If
Selection1.Clear
Dim k As Integer
For k = 1 To oInstances.Count
Dim oInst As Product
Set oInst = oInstances.Item(k)
'apply design mode
oInstances.Item(k).ApplyWorkMode DESIGN_MODE
Call Hide_Test(oInst, Selection1)
Next
End If
End Sub
***
Any help please ?
I have an assembly , who contains sub-assemblies and parts.
I try to create a macro to hide all parts or products named "Test" , but it not works:
Sub CATMain()
Dim oProdDoc As ProductDocument
Set oProdDoc = CATIA.ActiveDocument
Dim oRootProd As Product
Set oRootProd = oProdDoc.Product
Dim Selection As Selection
Set Slelection = oProdDoc.Selection
Call Hide_Test(oRootProd, Selection)
End Sub
Sub Hide_Test(oInProduct, Selection1)
Dim oInstances As Products
Set oInstances = oInProduct.Product.Products
'-----No instances found then this is CATPart
If oInstances.Count = 0 Then
Selection1.Add oInProduct
If (oInProduct.PartNumber = "Test") Then
Selection1.VisProperties.SetShow catVisPropertyNoShowAttr
Else
Selection1.VisProperties.SetShow catVisPropertyShowAttr
End If
Selection1.Clear
'Exit Sub
Else
'-----Found an instance therefore it is a CATProduct
Selection1.Add oInProduct.ReferenceProduct
If (oInProduct.ReferenceProduct.PartNumber = "Test") Then
Selection1.VisProperties.SetShow catVisPropertyNoShowAttr
Else
Selection1.VisProperties.SetShow catVisPropertyShowAttr
End If
Selection1.Clear
Dim k As Integer
For k = 1 To oInstances.Count
Dim oInst As Product
Set oInst = oInstances.Item(k)
'apply design mode
oInstances.Item(k).ApplyWorkMode DESIGN_MODE
Call Hide_Test(oInst, Selection1)
Next
End If
End Sub
***
Any help please ?





RE: Hide / Show in a product
Why don't you simply search by name?
CODE --> CATScript
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: Hide / Show in a product
Thanks for your answer.
Unfortunately, i make a mistake : I want to hide parts with name different to "Test" :
If (oInProduct.PartNumber = "Test") Then
Selection1.VisProperties.SetShow catVisPropertyShowAttr
Else
Selection1.VisProperties.SetShow catVisPropertyNoShowAttr
Thanks again :)