You have to set the visibility using the DrawingView like so:
DrawingView.SetVisibiliy(oComponent, true)'or false
You might have to assign the DrawingView to a variable first, I
haven't actually tried this, but I was looking for something in the
past where I could do both visibility and turn on/off hidden line
mode on an occurence. I gave up when I found out that the API still
doesn't support the hidden line option. Should work for visiblity
though. You can lookup the DrawingView.SetVisibilty method in the
API docs.
Bob S.
On 2010/06/01 2:38 PM, puertoricanpete wrote:
> All,
> I am working on a macro to try and make certain components invisible in a drawing view and am having a hangup with the code I am posting below. As I test the code I find that I can cause components to be suppressed, but cannot change their visibility. I have had success with this basic code on assemblies, but am having some trouble with the drawing files.
>
> Can someone please point me in the right direction? Thanks and have a great day!
>
> Public Sub Inventor_Automatic_Component_Invisibility()
>
> Dim oDoc As DrawingDocument
> Set oDoc = ThisApplication.ActiveDocument
>
> Dim oSheet As Sheet
> Set oSheet = oDoc.ActiveSheet
>
> Dim oAssyDoc As AssemblyDocument
> Set oAssyDoc = oSheet.DrawingViews(1).ReferencedDocumentDescriptor.ReferencedDocument
>
> Dim oCompDef As Inventor.ComponentDefinition
> Set oCompDef = oAssyDoc.ComponentDefinition
>
> Dim oComponent As ComponentOccurrence
>
> For Each oComponent In oCompDef.Occurrences
> Select Case oComponent.Name
> Case "Part1"
> oComponent.Suppress
> Case "Part2"
> oComponent.Visible = False
> Case "Part3"
> oComponent.Suppress
> End Select
> Next
>
> End Sub