GetVisibility fails for Associative DrawingView

GetVisibility fails for Associative DrawingView

J-Camper
Advisor Advisor
224 Views
2 Replies
Message 1 of 3

GetVisibility fails for Associative DrawingView

J-Camper
Advisor
Advisor

I have a simple function in a larger rule which checks if an object [mostly used to check ComponentOccurence object] is visible in a DrawingView.  I've recently found that the Function "GetVisibilty" on the DrawingView Object throws an exception when the DrawingView is associative.  Am i missing something obvious?  Is this behavior intended?  Sample function:

 

Sub Main
	
	Dim PickView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a drawing view")
	If IsNothing(PickView) Then Exit Sub ' If nothing gets selected then we're done
	
	If PickView.ReferencedDocumentDescriptor.ReferencedDocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then Logger.Debug("Please select a drawing view of an assembly document")
	
	Dim firstCO As ComponentOccurrence = PickView.ReferencedDocumentDescriptor.ReferencedDocument.ComponentDefinition.Occurrences.Item(1)
	
	Logger.Debug(firstCO.Name & " Visibility: " & TestGetVisibility(PickView, firstCO))
	
End Sub



Function TestGetVisibility(v As DrawingView, ob As Object) As Boolean

	Try
		Return v.GetVisibility(ob)
	Catch
		Logger.Debug("Assuming the component is visible if the view rep is locked")
		Return True
	End Try
	
End Function

 

0 Likes
225 Views
2 Replies
Replies (2)
Message 2 of 3

A.Acheson
Mentor
Mentor

Would I be right in saying that you need to ensure to check if the occurrence is a proxy occurrence or not? Link here. I  couldn't make that function work before so I looked into the assembly and looped through the design view rep for visibility of occurrences. I would like to see an answer to that too as it has baffled me. 

 

Syntax

DrawingView.GetVisibilityObject As Object ) As Boolean

Parameters

NameTypeDescription
ObjectObjectInput object to get the visibility state of. Valid objects are 2d and 3d sketches, work features, surface features, occurrences and proxies for all of these. The object needs to be supplied in the context of the document referenced by the drawing view. For instance, to set the visibility state of a 3D sketch within a part instanced in an assembly (and the drawing view is of the assembly), the input should be a Sketch3DProxy object created in context of the assembly. An error will occur if no corresponding object exists in the drawing view.

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 3

J-Camper
Advisor
Advisor

@A.Acheson,

 

I don't think so, it lists proxies as an appropriate object type in the description: "... and proxies for all of these."

Here is my logger info for running code posted 2 different times:

INFO| 1: >>---------------------------
DEBUG|Assuming the component is visible if the view rep is locked
DEBUG|TEMP-SD66-DWA-FORTESTING-66-01-A1:1 Visibility: True
INFO| 2: >>---------------------------
DEBUG|TEMP-SD66-DWA-FORTESTING-66-01-A1:1 Visibility: True

Run #1: Associative

Run 1: Associative DrawingViewRun 1: Associative DrawingView

Run #2: Not Associative

Run 2: DrawingView is NOT AssociativeRun 2: DrawingView is NOT Associative

0 Likes