Hiding certain components in a view in a drawing.

jwangADDR3
Explorer
Explorer

Hiding certain components in a view in a drawing.

jwangADDR3
Explorer
Explorer

Hello!

 

I am trying to hide (turn off visibility for) parts of assemblies and subassemblies when I am making drawings drafts. The parts that need to be hidden based on their names, like "screws" and "bolt". I would also need to access subassemblies and I believe I do that by calling a subfunction.

 

I think I am having trouble accessing the DrawingView type or at least taking data from this type. I am trying to use .contain() but unsure how to convert the DrawingView or AssemblyDocument to string.

 

Also- Anyone know a website to see a complete list of things I can do to each types? 

 

 

Sub Main()
'Selecting a view; the result is VIEW1
	Dim oView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select view")
'Trying to extract an assembly from this VIEW
	Dim oAssembly As AssemblyDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument
'Defining oComp to contain components
	Dim oComp As ComponentOccurrence

'Hiding the components
	For Each oComp In ThisApplication.ActiveDocument.ComponentDefinition.Occurrences
		name = UCase(assembly.Name)
		If oComp.name.Contains("SCREW") Or name.Contains("NUT") Or name.Contains("WASHER") Then			
			oComp.Visible = False		                
			MsgBox("test1")
		Else
			MsgBox("test2")
		End If
	next
End Sub

 

 

Thanks! 

Jamin

0 Likes
Reply
Accepted solutions (1)
908 Views
2 Replies
Replies (2)

WCrihfield
Mentor
Mentor
Accepted solution

Hi @jwangADDR3.  Probably the best way to control visibility of stuff in a drawing view is by making use of the DVRs (DesignViewRepresentations).  When you place a view of a model on a drawing sheet, the drawing view editor dialog displays, allowing you to set certain aspects about that view.  On the Component tab of that dialog is a place where you can set which design view (same as the DVR mentioned above) for that drawing view.

WCrihfield_0-1679591776825.png

That design view is created within the model.  It is what records what things are visible (not suppression status, just visibility status), what appearances and colors are being used on everything, and other similar settings.

WCrihfield_1-1679591839457.png

And you can find out more about what 'objects' are available, what methods & properties they have, and even sample code sometimes from the online help documentation.  You can find the online help documentation at the following link.

WCrihfield_2-1679592010993.png

...or

https://help.autodesk.com/view/INVNTOR/2022/ENU/ 

...then navigate here:

WCrihfield_3-1679592088549.png

 

 

By the way...in your code, you should replace this line:

For Each oComp In ThisApplication.ActiveDocument.ComponentDefinition.Occurrences

...with this:

For Each oComp In oAssembly.ComponentDefinition.Occurrences

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

jwangADDR3
Explorer
Explorer

Hey thank you for the reply. DVR helps a lot because I already have a few rules that allows me to hide all of the fasteners from the assembly file. 

0 Likes