Part Visiblity in all levels

Part Visiblity in all levels

k14348
Advocate Advocate
349 Views
1 Reply
Message 1 of 2

Part Visiblity in all levels

k14348
Advocate
Advocate

Hi,

   i have one common part for all my assembly levels. i want to hide(visibility off) that part via vba. Concept will be like once i run the program it should ask which part u want to hide then i will select tat part in browser after that selected part should be hide in all levels.1111.JPG

 

Thanks

-karthikeyan M

0 Likes
Accepted solutions (1)
350 Views
1 Reply
Reply (1)
Message 2 of 2

frederic.vandenplas
Collaborator
Collaborator
Accepted solution

Hi,

 

This should do the trick, it's written quick and dirty, sorry for that

 

Sub HideAllSelectedOccurences()
Dim oCommandMgr As CommandManager
Set oCommandMgr = ThisApplication.CommandManager

Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument
Dim oAsmDef As AssemblyComponentDefinition Set oAsmDef = oAsmDoc.ComponentDefinition Dim oOcc As ComponentOccurrence Set oOcc = oCommandMgr.Pick(kAssemblyLeafOccurrenceFilter, "Pick occurrence to hide") Dim strFileName As String strFileName = oOcc.ReferencedDocumentDescriptor.FullDocumentName Dim oLeafOccs As ComponentOccurrencesEnumerator Set oLeafOccs = oAsmDef.Occurrences.AllLeafOccurrences Dim oOcc1 As ComponentOccurrence
On Error Resume Next For Each oOcc1 In oLeafOccs If oOcc1.ReferencedDocumentDescriptor.FullDocumentName = strFileName Then oOcc1.Visible = False End If Next oOcc1 End Sub 

 

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"