IDW Visibility of Body

IDW Visibility of Body

halganabi
Contributor Contributor
173 Views
1 Reply
Message 1 of 2

IDW Visibility of Body

halganabi
Contributor
Contributor

I have IDW that has many Views of part X 
Part X is multibody has bodies (A,B,C,D)

I need a code to turn off Visibily of a specific body in all views 
the name of the body is entered by the user 

halganabi_0-1729437057336.png

 

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

jnowel
Advocate
Advocate

This should do the trick.
You can add another "For Loop" to apply the changes in all sheets instead of the ActiveSheet

 

Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oTrans As Transaction = ThisApplication.TransactionManager.StartTransaction(oDoc, "Hide Body") 'just added Transaction so you can undo easier

Dim oSheet As Sheet = oDoc.ActiveSheet

Dim sBodyName As String
sBodyName = InputBox("Enter Name of SurfaceBody to Hide", "IDW Visibility of Body", "Default Entry")

Dim iHit As Integer = 0

For Each oView As DrawingView In oSheet.DrawingViews
	If oView.DesignViewAssociative Then Continue For
	For Each oDrawCurve As DrawingCurve In oView.DrawingCurves		
		'Dim oGeoParent As Object
		Dim oGeoParent As SurfaceBody
		oGeoParent = oDrawCurve.ModelGeometry.Parent
		If TypeOf oGeoParent Is SurfaceBody Then
			If oGeoParent.Name.ToUpper = sBodyName.ToUpper Then 'Added .ToUpper so entry is not case-senstive
				Logger.Info("Hidden " & oGeoParent.Name & " in " & oView.Name & " (" & oSheet.Name & ")")
				iHit += 1
				oView.SetVisibility(oGeoParent, False)
				Exit For
			End If
		End If
	Next
Next

If iHit > 0 Then
	MessageBox.Show("'" & sBodyName & "' hidden in all views (except in associative views)", "IDW Visibility of Body", MessageBoxButtons.OK)
Else
	MessageBox.Show("'" & sBodyName & "' NOT found in applicable views", "IDW Visibility of Body", MessageBoxButtons.OK)
End If

oTrans.End
0 Likes