- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I'm trying to turn off the visibility of the certain component occurrences in my assembly. In some cases I also had to turn off the sub-assembly components. For Example: in the below code i have a sub-components present in the M.P.R.D which are automatically turned off with the M.P.R.D. I need some the sub -components to be turned on for my requirements. I have written below code for that.
Sub Visibility()
Dim oAss As AssemblyDocument
Set oAss = ThisDocument
Dim oAssComp As AssemblyComponentDefinition
Set oAssComp = oAss.ComponentDefinition
Dim oOcc As ComponentOccurrences
Set oOcc = oAssComp.Occurrences
oAssComp.RepresentationsManager.DesignViewRepresentations.Item("Master").Activate
Dim oLOD As RepresentationsManager
On Error Resume Next
Set oLOD = oAssComp.RepresentationsManager.DesignViewRepresentations.Add("CNC")
Dim Occ As ComponentOccurrence
Debug.Print oOcc.Count
For Each Occ In oOcc
If Left(Occ.Definition.Document.PropertySets.Item(3).Item("Part Number").Value, 3) = "LTC" Then
Occ.Visible = False
ElseIf Left(Occ.Definition.Document.PropertySets.Item(3).Item("Part Number").Value, 3) = "TOP" Then
Occ.Visible = False
ElseIf Left(Occ.Definition.Document.PropertySets.Item(3).Item("Part Number").Value, 3) = "FLE" Then
Occ.Visible = False
ElseIf Left(Occ.Definition.Document.PropertySets.Item(3).Item("Part Number").Value, 3) = "351" Then
Occ.Visible = False
ElseIf Left(Occ.Definition.Document.PropertySets.Item(3).Item("Part Number").Value, 3) = "M.P" Then
Occ.Visible = False
ElseIf Left(Occ.Definition.Document.PropertySets.Item(3).Item("Part Number").Value, 3) = "LAP" Then
Occ.Visible = False
End If
Next
For Each Occ In oOcc.SubOccurrences
If Left(Occ.Definition.Document.PropertySets.Item(3).Item("Part Number").Value, 3) = "MPR" Then
Occ.Visible = True
End If
Next
oAss.Save
oAssComp.RepresentationsManager.DesignViewRepresentations.Item("CNC").Activate
End Sub
Solved! Go to Solution.