Planes visibility control in occurrences

Planes visibility control in occurrences

Daan_M
Collaborator Collaborator
449 Views
2 Replies
Message 1 of 3

Planes visibility control in occurrences

Daan_M
Collaborator
Collaborator

Hi,

 

I have an configurator in an assembly file in which multiple parts get put thogether. In some of these parts i put planes to help during the drawing of the parts. These planes in these parts are visible in my assembly;

 

Daan_M_0-1693385169512.png

My question is; How do i hide these planes?

 

I tried without result;

 

Dim oDoc As AssemblyDocument = ThisDoc.Document
Dim oACD As AssemblyComponentDefinition = oDoc.ComponentDefinition

For Each oWorkPlane In oACD.WorkPlanes
         oWorkPlane.Visible = False
Next

 

0 Likes
Accepted solutions (1)
450 Views
2 Replies
Replies (2)
Message 2 of 3

Andrii_Humeniuk
Advisor
Advisor
Accepted solution

Hi @Daan_M . I use this code in my work. It asks if you want to make all planes in the assembly visible or invisible.

Private Sub Main()
	Dim oInvApp As Inventor.Application = ThisApplication
	Dim oDoc As Document = oInvApp.ActiveDocument
	Dim oTM As TransactionManager = oInvApp.TransactionManager
	If TypeOf oDoc Is PartDocument Then
		Dim oPDoc As PartDocument = oDoc
		Dim oPDef As PartComponentDefinition = oDoc.ComponentDefinition
		Dim bVisible As Boolean = WhatDoing()
		Dim newTM As Transaction = oTM.StartTransaction(oPDoc, "VisiblePlanes")
		Call ControlPlaves(oPDef, bVisible)
		newTM.End()
	Else If TypeOf oDoc Is AssemblyDocument Then
		Dim oADoc As AssemblyDocument = oDoc
		Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
		Dim bVisible As Boolean = WhatDoing()
		Dim newTM As Transaction = oTM.StartTransaction(oADoc, "VisiblePlanes")
		Call ControlPlaves(oADef, bVisible)
		For Each oRefDoc As Document In oADoc.AllReferencedDocuments
			If oRefDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
				Dim oAsmDoc As AssemblyDocument = oRefDoc
				Dim oRefDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition
				If oRefDef.BOMStructure <> BOMStructureEnum.kPhantomBOMStructure Then
					Call ControlPlaves(oRefDef, bVisible)
				End If
			Else If oRefDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
				Dim oPartDoc As PartDocument = oRefDoc
				Dim oRefDef As PartComponentDefinition = oPartDoc.ComponentDefinition
				If oRefDef.BOMStructure <> BOMStructureEnum.kPhantomBOMStructure Then
					Call ControlPlaves(oRefDef, bVisible)
				End If
			End If
		Next
		newTM.End()
	End If
End Sub

Private Function WhatDoing() As Boolean
	Dim digResult As DialogResult = MessageBox.Show("Planes must be visible?", "Visibility of working planes", _
													MessageBoxButtons.YesNo, MessageBoxIcon.Question)
	If digResult.ToString = "No" Then
		Return False
	End If
	Return True
End Function


Private Function ControlPlaves(ByVal oDef As ComponentDefinition, Optional ByVal bVisible As Boolean = False)
	For Each oWP As WorkPlane In oDef.WorkPlanes
		On Error Resume Next
		oWP.Visible = bVisible
	Next
End Function

 

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes
Message 3 of 3

Daan_M
Collaborator
Collaborator

Thanks, this helped me make the code i need to hide the planes;

 

For Each oRefDoc As Document In oDoc.AllReferencedDocuments
		Dim oRefDef As PartComponentDefinition = oRefDoc.ComponentDefinition
			For Each oWP As WorkPlane In oRefDef.WorkPlanes
				On Error Resume Next
				oWP.Visible = False
			Next
Next