visibility solid body with af combination of 4 custom properties.

visibility solid body with af combination of 4 custom properties.

gma
Advocate Advocate
852 Views
10 Replies
Message 1 of 11

visibility solid body with af combination of 4 custom properties.

gma
Advocate
Advocate

Hello,

 

I have a part, with a lot of derived components(Solid bodies).

I use 4 different custom properties, and I want to use the 4 different custom properties to visibility  one solid bodies. Each 4 custom properties can be different.

 

1. Custom properties: S18 (S10, S11)

2. Custom properties: 6 (9, 18)

3 Custom properties: RD (SQ)

4. Custom properties: 20 (25)

 

Is it possible to visibility one solid body with a rule?

 

So when i have a kind of a kombination with the 4 custom properties, then the rule will finde the solid body, and set it to visibility.

 

gma_0-1604528307612.png

 

Thank you in advance.

 

Best regards

Gøsta

 

 

0 Likes
853 Views
10 Replies
Replies (10)
Message 2 of 11

FINET_Laurent
Advisor
Advisor

Morning,

 

What are you refering to when talking about custom properties ? iProperties ? Parameters?

 

Regards,

 

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 3 of 11

FINET_Laurent
Advisor
Advisor

I did this one quickly, maybe this helps. Are you familiar with iLogic ?

 

Sub Main
	
Param1 = S18
Param2 = 6
Param3 = RD
Param4 = 20 

Dim sParameters As String = Param1 & Param2 & Param3 & Param4 'merge all parameters one next to the other 

Select Case sParameters 'create a case for all combinaisons 
	
	Case S186RD20 
		
		Call SupressAllFeatures 'see function at the bottom of the code 
		Feature.IsActive("featurename") = True ' the one body you want to be visible in that case
	 
	Case S106RD20
		
		Call SupressAllFeatures 
		Feature.IsActive("featurename") = True
Case S116RD20 Call SupressAllFeatures Feature.IsActive("featurename") = True End Select End Sub Function SupressAllFeatures 'function that supress all bodies in the part Dim oDoc As PartDocument oDoc = ThisApplication.ActiveDocument Dim oFeature As PartFeature For Each oFeature In oDoc.ComponentDefinition.Features oFeature.Suppressed = True Next End Function

 Regards,

 

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 4 of 11

JhoelForshav
Mentor
Mentor

@gma 

I don't know if I understand correctly but the way I interpret this question is that you want to control the visibility property of some solid bodies with custom iProperty values?

I made an example ipt for you but I don't know which version of inventor you're running. Attached ipt is inventor 2020.

 

In the ipt there are 4 solid bodies named Solid1, Solid2 Solid3, Solid4.

There are also 4 custom iproperties of type "Yes or No" named SOLID1, SOLID2, SOLID3, SOLID4.

 

I've set this rule to trigger on iProperty change:

Dim oDoc As PartDocument = ThisDoc.Document
Dim oSurfBods As SurfaceBodies = oDoc.ComponentDefinition.SurfaceBodies
oSurfBods.OfType(Of SurfaceBody).Where(Function(b) b.Name = "Solid1")(0).Visible = If (iProperties.Value("Custom", "SOLID1") = True, True, False)
oSurfBods.OfType(Of SurfaceBody).Where(Function(b) b.Name = "Solid2")(0).Visible = If (iProperties.Value("Custom", "SOLID2") = True, True, False)
oSurfBods.OfType(Of SurfaceBody).Where(Function(b) b.Name = "Solid3")(0).Visible = If (iProperties.Value("Custom", "SOLID3") = True, True, False)
oSurfBods.OfType(Of SurfaceBody).Where(Function(b) b.Name = "Solid4")(0).Visible = If(iProperties.Value("Custom", "SOLID4") = True, True, False)

 The values of these properties will therefore control the visibility of the solids. Is this what you're trying to accomplish? 🙂

Message 5 of 11

gma
Advocate
Advocate

Iproperties

0 Likes
Message 6 of 11

FINET_Laurent
Advisor
Advisor

Maybe this ?

 

Sub Main
	
Dim Param1 As String = iProperties.Value("Custom", "PropertyName") 'Change the property name to the desired one
Dim Param2 As String = iProperties.Value("Custom", "PropertyName")
Dim Param3 As String = iProperties.Value("Custom", "PropertyName")
Dim Param4 As String = iProperties.Value("Custom", "PropertyName")

Dim sParameters As String = Param1 & Param2 & Param3 & Param4 'merge all parameters one next to the other 

Select Case sParameters 'create a case for all combinaisons, like so 
	
	Case S186RD20 
		
		Call SupressAllFeatures 'see function at the bottom of the code 
		Feature.IsActive("featurename") = True ' the one body you want to be visible in that case
	 
	Case S106RD20
		
		Call SupressAllFeatures 
		Feature.IsActive("featurename") = True

	Case S116RD20
		
		Call SupressAllFeatures 
		Feature.IsActive("featurename") = True

	'Case xxx...

End Select

End Sub


Function SupressAllFeatures 'function that supress all bodies in the part

Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument
Dim oFeature As PartFeature
For Each oFeature In oDoc.ComponentDefinition.Features
	oFeature.Suppressed = True
Next

End Function 

 

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 7 of 11

FINET_Laurent
Advisor
Advisor

Coding the 15 cases is a pain tho.. ^^'

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 8 of 11

gma
Advocate
Advocate

Nothings happen.... 

 

No bodys are visibilitied

0 Likes
Message 9 of 11

FINET_Laurent
Advisor
Advisor

Can you share the code ?

 

Regards,

 

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 10 of 11

gma
Advocate
Advocate
Sub Main
	
Dim Param1 As String = iProperties.Value("Custom", "Serie") 'Change the property name to the desired one
Dim Param2 As String = iProperties.Value("Custom", "Z")
Dim Param3 As String = iProperties.Value("Custom", "Hul")
Dim Param4 As String = iProperties.Value("Custom", "HulDia")

Dim sParameters As String = Param1 & Param2 & Param3 & Param4 'merge all parameters one next to the other 

Select Case sParameters 'create a case for all combinaisons, like so 
	
	Case S18Z6ZRD20 
		
		Call SupressAllFeatures 'see function at the bottom of the code 
		Feature.IsActive("Solid1::S18Z6ZRD20") = True ' the one body you want to be visible in that case
	 
	Case S18Z6ZRD25
		
		Call SupressAllFeatures 
		Feature.IsActive("Solid1::S18Z6ZRD25") = True

'	Case S116RD20
		
'		Call SupressAllFeatures 
'		Feature.IsActive("featurename") = True

	'Case xxx...

End Select

End Sub


Function SupressAllFeatures 'function that supress all bodies in the part

Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument



Dim oFeature As PartFeature For Each oFeature In oDoc.ComponentDefinition.Features oFeature.Suppressed = True Next End Function

 

 

 

0 Likes
Message 11 of 11

gma
Advocate
Advocate

Unavngivet.jpg

0 Likes