DrawingView.GetVisibility returns an error

DrawingView.GetVisibility returns an error

Anonymous
Not applicable
938 Views
12 Replies
Message 1 of 13

DrawingView.GetVisibility returns an error

Anonymous
Not applicable

Hello,

 

I have a strange problem with the following code. It seems to work fine, but for a specific occurrence it returns an error code. I have no idea what the problem is and hope that someone here can help. I've attached the files, open the IDW and run the code. The code works fine for the first occurrence, but it fails on the second.

 

Sub TestGetVisibility()

    Dim oDoc As DrawingDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oSheet As Sheet
    Set oSheet = oDoc.Sheets(1)
    
    Dim oDrawingView As DrawingView
    Set oDrawingView = oSheet.DrawingViews(1)
        
    Dim oDocDesc As DocumentDescriptor
    Set oDocDesc = oDrawingView.ReferencedDocumentDescriptor
    
    Dim oAssCompDef As AssemblyComponentDefinition
    Set oAssCompDef = oDocDesc.ReferencedDocument.ComponentDefinition
        
    Dim oOcc As ComponentOccurrence
    Set oOcc = oAssCompDef.Occurrences.item(1)
    
    MsgBox oOcc.Name & " Visible=" & oDrawingView.GetVisibility(oOcc)
    
    Set oOcc = oAssCompDef.Occurrences.item(2)
    
    MsgBox oOcc.Name & " Visible=" & oDrawingView.GetVisibility(oOcc)
    
End Sub

 

I'm using Inventor 2013, haven't tested it on 2014 yet.

 

Best regards,

Daniël Reesing

 

EDIT: Just tested it on 2014 and the same problem exists.

0 Likes
939 Views
12 Replies
Replies (12)
Message 2 of 13

jdkriek
Advisor
Advisor

Try assigning occurences to thier own variable

 

    ' Occ 1
    Dim oOcc As ComponentOccurrence
    Set oOcc = oAssCompDef.Occurrences.Item(1)
    MsgBox oOcc.name & " Visible=" & oDrawingView.GetVisibility(oOcc)
    
    ' Occ 2
    Dim oOcc2 As ComponentOccurrence
    Set oOcc2 = oAssCompDef.Occurrences.Item(2)
    MsgBox oOcc2.name & " Visible=" & oDrawingView.GetVisibility(oOcc2)
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


0 Likes
Message 3 of 13

Anonymous
Not applicable

No luck, same problem

0 Likes
Message 4 of 13

jdkriek
Advisor
Advisor

I see now, that is wierd.

 

Even when I loop - it errors out on that next part...

 

  For Each oOcc In oAssCompDef.Occurrences
        MsgBox oOcc.name & " Visible=" & oDrawingView.GetVisibility(oOcc)
    Next
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


0 Likes
Message 5 of 13

Anonymous
Not applicable

Indeed the problem is with that specific part, but I cannot seem to find what's wrong with it....

 

To prevent problems with my code in the future I would like to find the source of this problem.

0 Likes
Message 6 of 13

jdkriek
Advisor
Advisor

Well the code is fine, I tested it on one of my own Assemblies with 50 parts and it loops through all of them just fine and gives the visibility status. Something about that specific part of yours.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


0 Likes
Message 7 of 13

Anonymous
Not applicable

Yes, too bad this is a base part that is copied and reused by one of my macros.

 

I guess I can recreate it from scratch, but I'd still like to know whats wrong with it.

 

Daniël

0 Likes
Message 8 of 13

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,

 

I did some tests and think this is a problem. I logged it:

 

GetVisibility failed in the second occurrence in the specific drawing

0 Likes
Message 9 of 13

Anonymous
Not applicable

Thanks!

0 Likes
Message 10 of 13

xiaodong_liang
Autodesk Support
Autodesk Support

more info from our engineer team:

 

This seems an API design issue, the status of the visibility of the occurrence is partial visible (see attached image).

But currently the API only returns True or False to indicate the occurrence is visible or not. Currently a workaround is to consider this failure as the partial visibility status, you can add an error handling to catch this kind of error.

0 Likes
Message 11 of 13

Anonymous
Not applicable

Thank you for the feedback.

 

I tried setting the occurence fully visible, but I still get an error. What's even more strange is that when I set both occurrences invisible, they both give an error. When I set occurrence 2 visible again, occurrence 1 displays visible=false fine again (but occurrence 2 still gives an error).

 

Also when I make the partial visible one (occurrence 2) fully invisible (and the other one visible), it still throws an error for occurrence 2 which is invisible. So assuming an occurrence is partial visible if it throws an error is not really reliable.

 

Daniël

 

 

0 Likes
Message 12 of 13

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,

 

Sorry, I have to append the further testing to the issue we've logged:

 

#1501725: GetVisibility failed in the second occurrence in the specific drawing

0 Likes
Message 13 of 13

WK-VA
Contributor
Contributor

Hi all,

 

this is still (2021!) a problem. I posted my issue here:

Detect visibility of objects in drawing - Autodesk Community - Inventor

 

The results of GetVisibility method are completely unreliable.

 

I've had all scenarios:

  • visible occurrence: GetVisibility results true (correct)
  • visible occurrence: GetVisibility results false (incorrect)
  • visible occurrence: GetVisibility throws error
  • invisible occurrence: GetVisibility results false(correct)
  • invisible occurrence: GetVisibility results true (incorrect)
  • invisible occurrence: GetVisibility throws error

And I've got only "visible/invisible" occurrences in my test case, no "partially visible" occurrences involved. At least not that I know of... what's the exact definition of "partially visible"?

 

I can intercept the error, well and what next? I need the information whether the occurrence is visible or not... so where's the point in error handling? The Occurrence's own .visible property hold wrong information as well...

 

Is that issue "GetVisibility failed in the second occurrence in the specific drawing" as mentioned by @xiaodong_liang disclosed to public reading or just an internal Autodesk thing?

 

And I want to highlight that this is NOT specific to one single document... the problem can be reproduced with newly created documents as randomly as the error occurs.

 

Best regards,

W. Kretzschmar

0 Likes