×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Hide / Show in a product

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 ?

RE: Hide / Show in a product

(OP)
Hi Ferdo,
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 :)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources