Hi @malmal02122023
Your request does involve knowing the Inventor API in both assembly and drawing very well.
Linked in a previous post here is the below code. This will not work in your model but is a starting sample to learn what you need. Create a simple assembly with one occurrence. Place into the drawing this assembly. Manually check the workplane required can be made visible. If it can then run the code.
Sub Main
SetWorkPlaneVisibilityFromAsm()
End Sub
Public Sub SetWorkPlaneVisibilityFromAsm()
Dim oDrawingDoc As DrawingDocument
oDrawingDoc = ThisApplication.ActiveDocument
'Get referenced Assembly document
Dim oAsm As AssemblyDocument
oAsm = oDrawingDoc.ReferencedDocuments(1)
'Get first occurrence, suppose it's a Part
Dim oOcc As ComponentOccurrence
oOcc = oAsm.ComponentDefinition.Occurrences(1)
Dim oPartCompDef As PartComponentDefinition
oPartCompDef = oOcc.Definition
'Get YZ WorkPlane, suppose it's perpendicular to the view
Dim oWP As WorkPlane
oWP = oPartCompDef.WorkPlanes.Item("YZ Plane")
'Create proxy object
Dim oWPpx As WorkPlaneProxy
Call oOcc.CreateGeometryProxy(oWP, oWPpx)
'Set visibility
Call oDrawingDoc.Sheets(1).DrawingViews(1).
SetVisibility(oWPpx, True)
End Sub
In order to dig down into the occurrence thst holds the workplane you will need to target the leaf occurrences of the assembly, this article will show you how.
The below code will show you how to access leaf occurrences in your assembly. Open your assembly and run the code.
Sub Main
GetPartOccurrences()
End Sub
Public Sub GetPartOccurrences()
' Get the active assembly.
Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
' Get the assembly component definition.
Dim oAsmDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition
' Get all of the leaf occurrences of the assembly.
Dim oLeafOccs As ComponentOccurrencesEnumerator = oAsmDef.Occurrences.AllLeafOccurrences
' Iterate through the occurrences and print the name.
Dim oOcc As ComponentOccurrence
For Each oOcc In oLeafOccs
Logger.Info(oOcc.Name)
Next
End Sub
Now integrate the two codes together. So you are not just looking at occurrence 1 but rather all occurrences. You will need further filtering to pick up the workplane by name. Hopefully this gets you started.
If this solved a problem, please click (accept) as solution.
Or if this helped you, please, click (like)
Regards
Alan