Sketch Driven Pattern in a part file True / False

Sketch Driven Pattern in a part file True / False

jletcher
Advisor Advisor
5,176 Views
5 Replies
Message 1 of 6

Sketch Driven Pattern in a part file True / False

jletcher
Advisor
Advisor

 

 I have ilogic controlling the visibility of the occurrences as of now the code shown below has "true" turning them off and "false" showing the item.

 

I was wondering if there is a way to reverse the "True" - "False", client is finding this confusing seeing there are other true/false options and true turns the item on..

 

Dim oPattern As SketchDrivenPatternFeature
oPattern = ThisDoc.Document.ComponentDefinition.Features.SketchDrivenPatternFeatures.Item("900C7G")
 
Dim oElements As FeaturePatternElements = oPattern.PatternElements

oElements(2).Suppressed = G_F
oElements(3).Suppressed = G_G
oElements(4).Suppressed = G_H
oElements(5).Suppressed = G_I
oElements(6).Suppressed = G_J
oElements(7).Suppressed = G_K
oElements(8).Suppressed = G_L
oElements(9).Suppressed = G_M
oElements(10).Suppressed = G_N
oElements(11).Suppressed = G_P
oElements(12).Suppressed = G_Q
oElements(13).Suppressed = G_R

ThisDoc.Document.update

 

 

 

 

 

0 Likes
Accepted solutions (1)
5,177 Views
5 Replies
Replies (5)
Message 2 of 6

WCrihfield
Mentor
Mentor

Not entirely sure what you need, but here is something like what I'm thinking your asking for.

Of course it's untested, but the idea is fairly simple.

 

Sub Main
	Dim oPattern As SketchDrivenPatternFeature
	oPattern = ThisDoc.Document.ComponentDefinition.Features.SketchDrivenPatternFeatures.Item("900C7G")
	 
	Dim oElements As FeaturePatternElements = oPattern.PatternElements

	oElements(2).Suppressed = RevBool(G_F)
	oElements(3).Suppressed = RevBool(G_G)
	oElements(4).Suppressed = RevBool(G_H)
	oElements(5).Suppressed = RevBool(G_I)
	oElements(6).Suppressed = RevBool(G_J)
	oElements(7).Suppressed = RevBool(G_K)
	oElements(8).Suppressed = RevBool(G_L)
	oElements(9).Suppressed = RevBool(G_M)
	oElements(10).Suppressed = RevBool(G_N)
	oElements(11).Suppressed = RevBool(G_P)
	oElements(12).Suppressed = RevBool(G_Q)
	oElements(13).Suppressed = RevBool(G_R)

	ThisDoc.Document.updateElement.Suppressed = False
End Sub
Function RevBool(ByVal oBool As Boolean) As Boolean
	If oBool = True Then oBool = False Else oBool = True
Return oBool
End Function

 

 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 6

jletcher
Advisor
Advisor

Thanks for the reply, unfortunately that did not work.

 

The () are not allowed as a parameter name so I took them out and tried but it still has false as being turned on.

 

 I'll try to clear it up.

 

 The code I provided allows me to control the visibility of  each pattern occurrence, in my form I have a check box that toggles what ones to turn on and off.  As of now the code I provided has False as default to turn the visibility on and true to turn them off. So if the client wants to show the spacer in "G_G" location he unchecks the check box (False) and that is backwards to the rest of the check box commands saying "True" turns on the visibility..

 

I was hoping to reverse the "True" and the "False" where "True" would be turning on the visibility.

 

 Hope that clears it up some..

0 Likes
Message 4 of 6

jletcher
Advisor
Advisor

Here is a sample part.

 

When you start the form you will notice the check boxes are uncheck and the spacers are show. If you put a check mark in it turns them off. This is what I would like to reverse, I want it to be checked to show and no check to turn them off.

0 Likes
Message 5 of 6

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @jletcher 

Do I understand correctly that you just want to flip it so that for example G_F = false will suppress the element at index 2?

 

Something like this then?

 

Dim oPattern As SketchDrivenPatternFeature
oPattern = ThisDoc.Document.ComponentDefinition.Features.SketchDrivenPatternFeatures.Item("900C7G")

Dim oElements As FeaturePatternElements = oPattern.PatternElements

oElements(2).Suppressed = If (G_F, False, True)
oElements(3).Suppressed = If (G_G, False, True)
oElements(4).Suppressed = If (G_H, False, True)
oElements(5).Suppressed = If (G_I, False, True)
oElements(6).Suppressed = If (G_J, False, True)
oElements(7).Suppressed = If (G_K, False, True)
oElements(8).Suppressed = If (G_L, False, True)
oElements(9).Suppressed = If (G_M, False, True)
oElements(10).Suppressed = If (G_N, False, True)
oElements(11).Suppressed = If (G_P, False, True)
oElements(12).Suppressed = If (G_Q, False, True)
oElements(13).Suppressed = If (G_R, False, True)

ThisDoc.Document.update
Message 6 of 6

jletcher
Advisor
Advisor

Perfect, thank you, thank you

 

Not sure if I would have figured that one out..

0 Likes