Grabbing visibility parameters from a model and using it in IDW rules

Grabbing visibility parameters from a model and using it in IDW rules

justin.eiterman
Explorer Explorer
225 Views
1 Reply
Message 1 of 2

Grabbing visibility parameters from a model and using it in IDW rules

justin.eiterman
Explorer
Explorer

I am trying to use the below code to suppress views in IDWs, but the problem is "Component.Visible" can only be used in the model rules. Is there an easy way to reference whether a sub assembly is visible or not in the IDW rules? Also, is there a way to speed it up so it finds whether or not every sub assembly is visible or not, rather than write this code for every assembly?

 

If Component.Visible.("mainAssemblyName.iam.subAssemblyName") = 1 Then

    For Each oSheet In odoc.Sheets

        Dim oView As DrawingView

        For Each oView In oSheet.DrawingViews   

            Select Case oView.Name

                Case "VIEW675"

                    oView.Suppressed = False

            End Select

        Next

    Next

End

0 Likes
226 Views
1 Reply
Reply (1)
Message 2 of 2

WCrihfield
Mentor
Mentor

Hi @justin.eiterman.  This isn't exactly the same work flow as your code is going through, but this should give you some ideas about how to do what you are trying to do.  You can either get the first 'Model' document from the first view of a model in the whole drawing by using the ThisDrawing.ModelDocument iLogic snippet, or you can get the 'Model' document from a specific DrawingView object, through its ReferencedDocumentDescriptor.ReferencedDocument property.  Then you would have to find the component using the normal API code route, rather than using that Component.Visible() snippet.

Here is a short example of some iLogic code that gets a model document, but more specifically an assembly, if one is available.  Then tries to find out if a specifically named component is visible within that assembly.  This example just tries to work with the first view on the active sheet, but can be modified as needed.  It doesn't actually suppress any drawing views yet, because I don't know which view you would want to suppress, so you will have to finish the view suppression bit yourself to suit your needs.

 

Sub Main
	Dim oDrawDoc As DrawingDocument = ThisDoc.Document
	oSheet = oDrawDoc.ActiveSheet
	oView = oSheet.DrawingViews.Item(1)
	'get model doc from 'first' model view in whole drawing like this...
	'Dim oModelDoc As Document = ThisDrawing.ModelDocument
	'or get model doc from specific view like this...
	Dim oModelDoc As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
	If oModelDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then 
		 If IsComponentVisible(oModelDoc, "Component1:1") = False Then
		 	'suppress the view of that named component
		End If
	End If
End Sub

Function IsComponentVisible(oAsmDoc As AssemblyDocument, oCompName As String) As Boolean
	oOccs = oAsmDoc.ComponentDefinition.Occurrences
	For Each oOcc As ComponentOccurrence In oOccs
		If oOcc.Name = oCompName Then Return oOcc.Visible
		If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
			IsComponentVisible(oOcc.Definition.Document, oCompName)
		End If
	Next
	Return False
End Function

 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)