Change visibility for Surfaces in an Assembly

Change visibility for Surfaces in an Assembly

They_Call_Me_Jake
Advocate Advocate
284 Views
2 Replies
Message 1 of 3

Change visibility for Surfaces in an Assembly

They_Call_Me_Jake
Advocate
Advocate

Not sure what I'm doing wrong or if it is a bug but if I could get some help I would appreciate it. I have and Assembly with some Sub-Assemblies in it. In those Sub-Assemblies are some parts with surfaces that where from copying other parts into it. We use those copied in surfaces to do a sculpt but it leaves the surface visible. I have tried numerous ways to try and turn off the visibility but nothing I try seems to work. Does anyone have an idea of what I am doing wrong here.

Sub Main()
	Dim oAsm = ThisDoc.Document
	Dim oAsmDef As ComponentDefinition = oAsm.ComponentDefinition
		
	HideCompositeSurfaces(oAsmDef, "Carriage Base:1")
	
End Sub 

Sub HideCompositeSurfaces(oAsmDef As ComponentDefinition, targetName As String)
	
	Dim target As ComponentOccurrence = Nothing
	Dim oLeafOccs As ComponentOccurrencesEnumerator = oAsmDef.Occurrences.AllLeafOccurrences
	Dim oOcc As ComponentOccurrence

    For Each oOcc In oLeafOccs		
        If oOcc.Name = targetName Then			
			target = oOcc			
		End If		
	Next
	
	Dim oContainingOccurrence As ComponentOccurrence = target.ContainingOccurrence
	Dim oContainingOccurrenceDef As ComponentDefinition = oContainingOccurrence.Definition
	
	For Each oWorkSurface In target.Definition.WorkSurfaces
			
'			Dim oWorkSurfaceProxy As WorkSurfaceProxy = Nothing
'			oContainingOccurrence.CreateGeometryProxy(oWorkSurface, oWorkSurfaceProxy)
			oWorkSurface.Visible = False
			
		Next
	
End Sub
0 Likes
285 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor

It sounds to me like you might benefit from setting up DesignViewRepresentations at each level of the assembly structure, starting with the part.  Create a DVR in the Part, then turn those surfaces off, and that DVR will record that setting.  Then in the sub assembly, create a DVR, and set the component representing that part to the DVR you created in the part, and that setting will be recorded in its DVR.  Then in your top assembly, create a DVR and set the component that represents the sub assembly to its DVR.  That's the normal, manual way of handling those sorts of things.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

They_Call_Me_Jake
Advocate
Advocate

@WCrihfield thanks for the reply. I'm wanting to do this thru code instead of manually. I have actually done this before and I have copied my code that does in fact work into this iLogic rule but for some reason it's not working here when it works in external code.

0 Likes