select case code related to a multibody solids visibility.

select case code related to a multibody solids visibility.

SpokenEarth
Advocate Advocate
621 Views
6 Replies
Message 1 of 7

select case code related to a multibody solids visibility.

SpokenEarth
Advocate
Advocate

Hi forum, I'm having trouble with the select case code related to a multibody solids visibility.
I need a help with a code so when I'm fire from the Form the selected type, the feature in the model window is visible and other existing ones are not.
Thanks in advance for any help you can give.

0 Likes
Accepted solutions (1)
622 Views
6 Replies
Replies (6)
Message 2 of 7

bradeneuropeArthur
Mentor
Mentor

Can you explain a little more in detail what you try to do?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 7

SpokenEarth
Advocate
Advocate

When I select from the form1, under TYPE DIN32676SERIES2 STANDARD I want the solid body DIN32676 SERIES1 from the model browser to be invisible. 

0 Likes
Message 4 of 7

JelteDeJong
Mentor
Mentor

you could add this to your rule to hide a body

Dim nameOfBodyTohide = "DIN32676 SERIES1"
Dim doc As PartDocument = ThisDoc.Document
Dim def As PartComponentDefinition = doc.ComponentDefinition
Dim bodies As IEnumerable(Of SurfaceBody) = def.SurfaceBodies.Cast(Of SurfaceBody)
Dim body As SurfaceBody = bodies.
    Where(Function(b) b.Name.Equals(nameOfBodyTohide)).First()
body.Visible = False

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 5 of 7

SpokenEarth
Advocate
Advocate

Thanks JelteDeJong, the code works fine, and almost accomplish what I need.
But how can automatically toggle the visibility?
For example, when am fire SIZE:DIN32676 SERIES2:STANDARD I would like to have the solid body DIN32676 SERIES1 invisible, and solid DIN32676 SERIES2 STANDARD visible

0 Likes
Message 6 of 7

JelteDeJong
Mentor
Mentor
Accepted solution

You can create a new rule and add this. with this rule the bodies get selected depending on the type

Public Sub Main()
	Select Case TYPE
		Case "DIN 32676 SERIES 1"
			setVisibility("DIN32676 SERIES1", True)
			setVisibility("DIN32676SERIES2 STANDARD" , False)
			
		Case "DIN 32676 SERIES 2 STANDARD"
			setVisibility("DIN32676 SERIES1", false)
			setVisibility("DIN32676SERIES2 STANDARD" , True)
		
		Case "...."
			' You might want to add more cases 
	End Select	
End Sub

Public Sub setVisibility(bodyName As String, visible As Boolean)
	Dim doc As PartDocument = ThisDoc.Document
	Dim def As PartComponentDefinition = doc.ComponentDefinition
	Dim bodies As IEnumerable(Of SurfaceBody) = def.SurfaceBodies.Cast(Of SurfaceBody)
	Dim body As SurfaceBody = bodies.
	    Where(Function(b) b.Name.Equals(bodyName)).First()
	body.Visible = visible
End Sub

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 7 of 7

SpokenEarth
Advocate
Advocate

PERFECT!!!.....Thank you so much

You are always so you are very helpful.

Achilles

0 Likes