Rule with multiple options

Rule with multiple options

KaynePellegrino
Enthusiast Enthusiast
417 Views
20 Replies
Message 1 of 21

Rule with multiple options

KaynePellegrino
Enthusiast
Enthusiast

This is a long one.

------------------------

 

I make doors. They can be different Widths and Heights, among different Types.

Widths:

3-6 (41.75")

3-0 (35.75")

2-10 (33.75")

2-8 (31.75")

2-6 (29.75")

 

Heights:

8-0 (95.375")

6-8 (79.375")

 

Types:

1K (1-Panel)

2K (2-Panel

3F (3-Panel)

3S (3-Panel w/ Glass)

50 (5-Panel)

 

------------------------

 

I have a Width Param & Rule:

DoorWidthOptions [Text, Multi]: 3-6, 3-0, 2-10, 2-8, 2-6

DoorWidth [Num]: (Varies)

Door Width Rule:

'Door Width
If DoorWidthOptions = "3-6" Then
		DoorWidth = 41.75
	End If

If DoorWidthOptions = "3-0" Then
		DoorWidth = 35.75
	End If

If DoorWidthOptions = "2-10" Then
		DoorWidth = 33.75
	End If

If DoorWidthOptions = "2-8" Then
		DoorWidth = 31.75
	End If

If DoorWidthOptions = "2-6" Then
		DoorWidth = 29.75
	End If

 

I have a Height Param & Rule:

Works same as width, except with the 2 Height options

DoorHeightOptions [Text, Multi]: 8-0, 6-8

DoorHeight [Num]: (Varies)

Door HeightRule:

'Door Height
If DoorHeightOptions = "6-8" Then
		DoorHeight = 79.375
	End If

If DoorHeightOptions = "8-0" Then
		DoorHeight = 95.375
	End If

 

I have a Door Type Rule: Same rule for all other types as well,  not just '1K'

If DoorType = "1K" Then
		Component.IsActive("1K Skin: Back") = True
		Component.IsActive("1K Skin: Front") = True
		Component.IsActive("2K Skin: Back") = False
		Component.IsActive("2K Skin: Front") = False
		Component.IsActive("3F Skin: Back") = False
		Component.IsActive("3F Skin: Front") = False
		Component.IsActive("3F (3-6) Skin: Back") = False
		Component.IsActive("3F (3-6) Skin: Front") = False
		Component.IsActive("3S Skin: Back") = False
		Component.IsActive("3S Skin: Front") = False
		Component.IsActive("50 Skin: Back") = False
		Component.IsActive("50 Skin: Front") = False
	End If

 

------------------------

The doors are made of Skins (front and back of door), Stiles (sides of doors), and Rails (top and bottom of doors)

All Skin Models:

1K

2K

3F (Widths 2-6 to 3-0)

3F (Width 3-6)

3S

50

 

------------------------

 

Issue is.

 

When I run the 1K rule it works great cuz there's only one 1K model

But for the 3F there's two 3F models that are different sizes.

I need the 3F 3-6 model to be active only if I have the DoorType ="3F" AND the DoorWidthOptions = "3-6"

Then to suppress it if DoorWidthOptions = "3-0", "2-10", "2-8", or "2-6"

This is what I wrote and it doesn't work.

If DoorType = "3F" And DoorWidthOptions = ("2-6" or "2-8" or "2-10" or "3-0") Then
		Component.IsActive("1K Skin: Back") = False
		Component.IsActive("1K Skin: Front") = False
		Component.IsActive("2K Skin: Back") = False
		Component.IsActive("2K Skin: Front") = False
		Component.IsActive("3F Skin: Back") = True
		Component.IsActive("3F Skin: Front") = True
		Component.IsActive("3F (3-6) Skin: Back") = False
		Component.IsActive("3F (3-6) Skin: Front") = False
		Component.IsActive("3S Skin: Back") = False
		Component.IsActive("3S Skin: Front") = False
		Component.IsActive("50 Skin: Back") = False
		Component.IsActive("50 Skin: Front") = False
	End If

 

How do I write this to mean if DoorWidthoptions has one selected of a few options so I don't need to write it out for each option

 

3F and 3-0

3F and 2-10

3F and 2-8

3F and 2-6

 

How can it be 3F and (3-0, 2-10, 2-8, or 2-6)

0 Likes
418 Views
20 Replies
Replies (20)
Message 2 of 21

SMillsYS3X2
Advocate
Advocate

For starters consider converting width options to inches and subtracting .25. And the same for door height and subtract 0.625. Numbers is a lot easier than juggling a bunch of string options with long case statements.

Then you can start with making everything inactive and build a If-elseif-end if statement for any variables to turn on each component much easier. Example;

Component.IsActive("1K Skin: Back") = False
Component.IsActive("1K Skin: Front") = False
Component.IsActive("2K Skin: Back") = False
Component.IsActive("2K Skin: Front") = False
Component.IsActive("3F Skin: Back") = False
Component.IsActive("3F Skin: Front") = False
Component.IsActive("3F (3-6) Skin: Back") = False
Component.IsActive("3F (3-6) Skin: Front") = False
Component.IsActive("3S Skin: Back") = False
Component.IsActive("3S Skin: Front") = False
Component.IsActive("50 Skin: Back") = False
Component.IsActive("50 Skin: Front") = False
If DoorType = "3F" And DoorWidthO >= 29.75 And DoorWidthO <= 35.75
	Component.IsActive("3F Skin: Back") = True
	Component.IsActive("3F Skin: Front") = True
ElseIf DoorType = "3S" And DoorWidthO >= 29.75 And DoorWidthO <= 35.75
	Component.IsActive("3S Skin: Back") = True
	Component.IsActive("3S Skin: Front") = True
End If

Or better yet use shorter case statements. example;

Component.IsActive("1K Skin: Back") = False
Component.IsActive("1K Skin: Front") = False
Component.IsActive("2K Skin: Back") = False
Component.IsActive("2K Skin: Front") = False
Component.IsActive("3F Skin: Back") = False
Component.IsActive("3F Skin: Front") = False
Component.IsActive("3F (3-6) Skin: Back") = False
Component.IsActive("3F (3-6) Skin: Front") = False
Component.IsActive("3S Skin: Back") = False
Component.IsActive("3S Skin: Front") = False
Component.IsActive("50 Skin: Back") = False
Component.IsActive("50 Skin: Front") = False
Select Case DoorType
Case "3F"
	Select Case DoorWidthO
	Case 29.75 To 35.75
		Component.IsActive("3F Skin: Back") = True
		Component.IsActive("3F Skin: Front") = True	
	Case 2 To 29.75
		'Etc Etc Etc
	Case Else
		'Etc Etc Etc
	End Select
Case "3S"
	Select Case DoorWidthO
	Case 12 To 20
		Component.IsActive("3S Skin: Back") = True
		Component.IsActive("3S Skin: Front") = True
	Case 2 To 12
		'Etc Etc Etc
	End Select
End Select

 

0 Likes
Message 3 of 21

KaynePellegrino
Enthusiast
Enthusiast

SMillsYS3X2

 

The first half is FANTASTIC. That actually is gonna save me so much time and I'm upset I hadn't thought of it sooner.

 

But the second half, its for "3F Skin" OR "3F (3-6) Skin" that I'm trying to solve

 

"3F (3-6) Skin" only has 1 model state with a width and height of 3-6 x 8-0

"3F Skin" has multiple widths and heights based on the model state, none of which are 3-6 width

 

'"3F Skin" Active
If
DoorType = "3F" And DoorWidthOptions = "3-0" Then Component.IsActive("3F Skin: Back") = True Component.IsActive("3F Skin: Front") = True End If If DoorType = "3F" And DoorWidthOptions = "2-10" Then Component.IsActive("3F Skin: Back") = True Component.IsActive("3F Skin: Front") = True End If If DoorType = "3F" And DoorWidthOptions = "2-8" Then Component.IsActive("3F Skin: Back") = True Component.IsActive("3F Skin: Front") = True End If If DoorType = "3F" And DoorWidthOptions = "2-6" Then Component.IsActive("3F Skin: Back") = True Component.IsActive("3F Skin: Front") = True End If
'"3F (3-6) Skin" Active If DoorType = "3F" And DoorWidthOptions = "3-6" Then Component.IsActive("3F (3-6) Skin: Back") = True Component.IsActive("3F (3-6) Skin: Front") = True End If

I need it where the 4 rules in red are one rule

Though I'm presenting one project, knowing how to do that would help with other projects with very similar organization issues.

 

But, the reason I have the 2 parameters to determine both the height and width of the doors is so the parameters with 'options' in the name can be on the forms I make so they're easier to read/understand by those I share the file with, and so it's faster to change the settings when making new model states. To click a few buttons as opposed to typing in long numbers in multiple boxes.

 

If doing numbers is easier and or cost less computing power then I'll do that instead, but I really like my forms having the bubbles

 

Could you explain the 'Case select' stuff a little. I haven't seen that yet but it looks close to what I'm looking for

0 Likes
Message 4 of 21

SMillsYS3X2
Advocate
Advocate

Glad that helps. A quick revision of the red section,  assuming you convert DoorWidthOptions to a double variable, I would do something like this - 

Dim DoorWidthOptions As Double = '???
Select Case DoorType
Case "3F"
	Select Case DoorWidthOptions
	Case 36
		Component.IsActive("3F Skin: Back") = True
		Component.IsActive("3F Skin: Front") = True
	Case 22
		Component.IsActive("3F Skin: Back") = True
		Component.IsActive("3F Skin: Front") = True
	Case 20
		Component.IsActive("3F Skin: Back") = True
		Component.IsActive("3F Skin: Front") = True
	Case 18
		Component.IsActive("3F Skin: Back") = True
		Component.IsActive("3F Skin: Front") = True
	End Select
End Select

And after looking at that, you could probably just say Case 18 to 36 instead.  🤷‍

Dim DoorWidthOptions As Double = '???
Select Case DoorType
Case "3F"
	Select Case DoorWidthOptions
	Case 18 to 36
		Component.IsActive("3F Skin: Back") = True
		Component.IsActive("3F Skin: Front") = True
	End Select
End Select

 

Case statements are a basic function of visual basic programming. Here is Microsoft's long definition of it - 
https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/select-case-stat...

EDIT: And sorry, after looking at that. The case statement will only activate if DoorType = "3F"Not if it's value is "3F Skin" or "3F (3-6) Skin", or even "3F ", or "3f". Or to say it another way, the string value must be an exact match. Even capital or lowercase letters and spaces will prevent it from being recognized as a match.


EDIT2: And to get different values for DoorType, and narrow DoorWidthOptionsto specifically to those numbers.... Maybe this is what your looking for?

 

Dim DoorWidthOptions As Double = '???
Select Case DoorType
Case "3F", "3F Skin", "3F (3-6) Skin"
	Select Case DoorWidthOptions
	Case 18, 20, 22, 36
		Component.IsActive("3F Skin: Back") = True
		Component.IsActive("3F Skin: Front") = True
	End Select
End Select

 

0 Likes
Message 5 of 21

SMillsYS3X2
Advocate
Advocate

-

0 Likes
Message 6 of 21

KaynePellegrino
Enthusiast
Enthusiast

Oh gosh, I don't know what double variable means either 😅

 

And I'm not sure the 'case select' stuff is what I need, or if I just don't understand it.

 

Here's my rule for selecting the Door Type (First part inspired by the code you sent me, makes it much cleaner)

 - Colored it so you can see exactly what parts of the rules are attached to activating which components in the assembly

'Door Type
Component.IsActive("1K Skin: Back") = False
Component.IsActive("1K Skin: Front") = False
Component.IsActive("2K Skin: Back") = False
Component.IsActive("2K Skin: Front") = False
Component.IsActive("3F Skin: Back") = False
Component.IsActive("3F Skin: Front") = False
Component.IsActive("3F (3-6) Skin: Back") = False
Component.IsActive("3F (3-6) Skin: Front") = False
Component.IsActive("3S Skin: Back") = False
Component.IsActive("3S Skin: Front") = False
Component.IsActive("50 Skin: Back") = False
Component.IsActive("50 Skin: Front") = False

If DoorType = "1K" Then
		Component.IsActive("1K Skin: Back") = True
		Component.IsActive("1K Skin: Front") = True
	End If

If DoorType = "2K" Then
		Component.IsActive("2K Skin: Back") = True
		Component.IsActive("2K Skin: Front") = True
	End If

If DoorType = "3F" And DoorWidthOptions = "3-0" Then
		Component.IsActive("3F Skin: Back") = True
		Component.IsActive("3F Skin: Front") = True
	End If

If DoorType = "3F" And DoorWidthOptions = "2-10" Then
		Component.IsActive("3F Skin: Back") = True
		Component.IsActive("3F Skin: Front") = True
	End If

If DoorType = "3F" And DoorWidthOptions = "2-8" Then
		Component.IsActive("3F Skin: Back") = True
		Component.IsActive("3F Skin: Front") = True
	End If

If DoorType = "3F" And DoorWidthOptions = "2-6" Then
		Component.IsActive("3F Skin: Back") = True
		Component.IsActive("3F Skin: Front") = True
	End If

If DoorType = "3F" And DoorWidthOptions = "3-6" And DoorHeightOptions = "8-0" Then
		Component.IsActive("3F (3-6) Skin: Back") = True
		Component.IsActive("3F (3-6) Skin: Front") = True
	End If

If DoorType = "3S" Then
		Component.IsActive("3S Skin: Back") = True
		Component.IsActive("3S Skin: Front") = True
	End If

If DoorType = "50" Then
		Component.IsActive("50 Skin: Back") = True
		Component.IsActive("50 Skin: Front") = True
	End If

 

The issue is that I have 4 blocks of code to determine if the '3F Skin' component should be active.

The '3F Skin' (not the same as the '3F (3-6) Skin') can be 6-8 or 8-0 tall, and can be 3-0, 2-10, 2-8, or 2-6 wide. So I have multiple model states for the '3F Skin' ipt. for each size it can be.

But the '3F (3-6) Skin' is only 8-0 tall and 3-6 wide. I only have one model state for this ipt.

What I have above works. I just hate that I have to have a different paragraph for each variation for the '3F Skin' with the different widths.

 

I want to write it like this, where it sees more than one option for the DoorWidthoptions = "__" or "__" or "__". That way I don't have a new paragraph for each combo of the DoorType and DoorWidthOptions parameters.

If DoorType = "3F" And DoorWidthOptions = "3-0" or "2-10" or "2-8" or "2-6" Then
		Component.IsActive("3F Skin: Back") = True
		Component.IsActive("3F Skin: Front") = True
	End If
If DoorType = "3F" And DoorWidthOptions = "3-6" And DoorHeightOptions = "8-0" Then
Component.IsActive("3F Skin: Back") = True
Component.IsActive("3F Skin: Front") = True
End If

 

When the DoorWidthOptions is selected I also have another rule that changes another parameter, "DoorWidth"

When the DoorHeightOptions is selected I also have another rule that changes another parameter, "DoorHeight"

This is the code for it

'Door Height
If DoorHeightOptions = "6-8" Then
		DoorHeight = 79.375
	End If

If  DoorHeightOptions = "8-0" Then
		DoorHeight = 95.375
	End If


'Door Width
If DoorWidthOptions = "3-6" Then
		DoorWidth = 41.75
	End If

If DoorWidthOptions = "3-0" Then
		DoorWidth = 35.75
	End If

If DoorWidthOptions = "2-10" Then
		DoorWidth = 33.75
	End If

If DoorWidthOptions = "2-8" Then
		DoorWidth = 31.75
	End If

If DoorWidthOptions = "2-6" Then
		DoorWidth = 29.75
	End If

 

 

 

 

 

 

 

After pasting the last code I think I understood what you were saying with using Numbers instead of 'String options with long case statements'

Would it work better to have the code like this? It works, but just making sure I'm understanding it

'Door Type
Component.IsActive("1K Skin: Back") = False
Component.IsActive("1K Skin: Front") = False
Component.IsActive("2K Skin: Back") = False
Component.IsActive("2K Skin: Front") = False
Component.IsActive("3F Skin: Back") = False
Component.IsActive("3F Skin: Front") = False
Component.IsActive("3F (3-6) Skin: Back") = False
Component.IsActive("3F (3-6) Skin: Front") = False
Component.IsActive("3S Skin: Back") = False
Component.IsActive("3S Skin: Front") = False
Component.IsActive("50 Skin: Back") = False
Component.IsActive("50 Skin: Front") = False

If DoorType = "1K" Then
		Component.IsActive("1K Skin: Back") = True
		Component.IsActive("1K Skin: Front") = True
	End If

If DoorType = "2K" Then
		Component.IsActive("2K Skin: Back") = True
		Component.IsActive("2K Skin: Front") = True
	End If

If DoorType = "3F" And DoorWidth <= 40 Then
		Component.IsActive("3F Skin: Back") = True
		Component.IsActive("3F Skin: Front") = True
	End If

If DoorType = "3F" And DoorWidth >= 40  And DoorHeightOptions = "8-0" Then
		Component.IsActive("3F (3-6) Skin: Back") = True
		Component.IsActive("3F (3-6) Skin: Front") = True
	End If

If DoorType = "3S" Then
		Component.IsActive("3S Skin: Back") = True
		Component.IsActive("3S Skin: Front") = True
	End If

If DoorType = "50" Then
		Component.IsActive("50 Skin: Back") = True
		Component.IsActive("50 Skin: Front") = True
	End If

I read the 'Case Select' link you sent and I might need to take some sort of basic coding class or watch some videos to understand the terminology better. Like I understand what It's saying and how it connects in the example, I just don't get yet how to use my parameters in that kind of code to get it to work how I need.

0 Likes
Message 7 of 21

KaynePellegrino
Enthusiast
Enthusiast

Also, here's some pictures so you see what I see

Form in top left of display with all my options

If DoorType = "1K" Then

1K Selected.jpg

 

If DoorType = "2K" Then

2K Selected.jpg

 

If DoorType = "3F" And DoorWidth <= 40 Then

3F Selected.jpg

 

If DoorType = "3F" And DoorWidth >=40 Then

3F (3-6) Selected.jpg

 

If DoorType = "3S" Then

3S Selected.jpg

 

If DoorType = "50" Then

50 Selected.jpg

 

0 Likes
Message 8 of 21

SMillsYS3X2
Advocate
Advocate

Yeah, understanding when a variable you are using is a integer, double, string, or boolean and what happens when they are converted to another type is one of the basics of programming. And there is more types, but those 4 are the usual starting point for most people.

Looking at that code, I think you could have a problem with these lines;

If DoorType = "3F" And DoorWidth <= 40 Then
		Component.IsActive("3F Skin: Back") = True
		Component.IsActive("3F Skin: Front") = True
	End If

If DoorType = "3F" And DoorWidth >= 40  And DoorHeightOptions = "8-0" Then
		Component.IsActive("3F (3-6) Skin: Back") = True
		Component.IsActive("3F (3-6) Skin: Front") = True
	End If

When DoorType = "3F" and DoorWidth = 40 and DoorHeightOptions = "8-0", you will have all 4 of those components active/on. Why do you keep separating your If - End If statements? Don't want to use If - ElseIf - End If ?

______________

Quick explanation of variable types;

Double are numbers with decimals. Examples - 0.0, 12.347, 0.00415, 128.0
Integer are whole numbers. No decimal or fractions.
String are letters. Even if/when they look like numbers. Need to add " to the beginning and end of string's values.

Boolean are true or false. Yes or no. 0 or 1. It is or is not.

0 Likes
Message 9 of 21

SMillsYS3X2
Advocate
Advocate

A quick re-write of the 3F section using if-elseif-endif statement;

If DoorType = "3F" Then
	If DoorWidthOptions = "3-0" Then
		Component.IsActive("3F Skin: Back") = True
		Component.IsActive("3F Skin: Front") = True
	ElseIf DoorWidthOptions = "2-10" Then
		Component.IsActive("3F Skin: Back") = True
		Component.IsActive("3F Skin: Front") = True
	ElseIf DoorWidthOptions = "2-8" Then
		Component.IsActive("3F Skin: Back") = True
		Component.IsActive("3F Skin: Front") = True
	ElseIf DoorWidthOptions = "2-6" Then
		Component.IsActive("3F Skin: Back") = True
		Component.IsActive("3F Skin: Front") = True
	ElseIf DoorWidthOptions = DoorWidthOptions = "3-6" And DoorHeightOptions = "8-0" Then
		Component.IsActive("3F (3-6) Skin: Back") = True
		Component.IsActive("3F (3-6) Skin: Front") = True
	End If
ElseIf DoorType = "X" Then
	'Etc etc etc
ElseIf DoorType = "Y" Then
	'Etc etc etc
ElseIf DoorType = "Z" Then
	'Etc etc etc
End If 
0 Likes
Message 10 of 21

KaynePellegrino
Enthusiast
Enthusiast

Thank you very much for the explanation, it helps a lot!

I'm getting slowly, thank you for being patient 

 

With "Why do you separate...", I honestly didn't realize how to use 'Else' codes. Like I tried it once and couldn't get it, so I forgot about it and wrote all my stuff out; long ways.

But also, I picked 40 knowing that we would never make something that's exactly 40" wide. So i felt it was a safe number. But, curious, would it have been better to write something like:

If DoorType = "3F" And DoorWidth = 35.75, 33.75, 31.75, AndOr 29.75 Then
"Component1" = True
ElseIf DoorWidth = 41.75 Then
"Component2" = True
End If

 

But I can't find a way to have multiple options in one line. Is there no way to write "one" or "the other" in the same line when saying " If "____" = "

 

Example: This (With multiple options for the same outcome in one line)

If "Variable1" = "OptionA1" And "Variable2" = "OptionB1" OR "OptionB2" Then '(Multiple Options in the Same Line, separated by some kind of 'or' statement)
		"Component1" = True
Else If "Variable2" = "OptionB3" Then
"Component2" = True End If

 

 As opposed to how you wrote it (Multiple lines for each combo that equal the same outcome)

If DoorType = "3F" Then
	If DoorWidthOptions = "3-0" Then
		Component.IsActive("3F Skin: Back") = True
		Component.IsActive("3F Skin: Front") = True
	ElseIf DoorWidthOptions = "2-10" Then
		Component.IsActive("3F Skin: Back") = True
		Component.IsActive("3F Skin: Front") = True
	ElseIf DoorWidthOptions = "2-8" Then
		Component.IsActive("3F Skin: Back") = True
		Component.IsActive("3F Skin: Front") = True
	ElseIf DoorWidthOptions = "2-6" Then
		Component.IsActive("3F Skin: Back") = True
		Component.IsActive("3F Skin: Front") = True
	ElseIf DoorWidthOptions = DoorWidthOptions = "3-6" And DoorHeightOptions = "8-0" Then
		Component.IsActive("3F (3-6) Skin: Back") = True
		Component.IsActive("3F (3-6) Skin: Front") = True
	End If

 

Message 11 of 21

J_Pfeifer_
Advocate
Advocate

Slow down, instead of typing everything out manually. Try different things to familiarize yourself with the language. 

 

Sub main()
Dim X as integer = 1
Dim X1 as integer = 2 

Dim Y as integer = 3
Dim Y1 as integer = 4

If (x = x1 and y = y1) or y = 4 then
     'do something
Else if X = Y then 
     'Do something else
Else

End if 





End sub

 

Not even sure if what I typed above works exactly. However, you can place parentheses within the and side of the or. This will evaluate that section as one of the or's. You can do the same for the other side. Below is a bit of code Ive used. 

If (MiddleLetter.StartsWith("D") = True Or MiddleLetter.StartsWith("K") = True) And LastLetter.StartsWith("H") = False Then 
				Tank_Leg_Stand_TC = True	
			Else
				Tank_Leg_Stand_TC = False
			End If 
Message 12 of 21

SMillsYS3X2
Advocate
Advocate

Depends on your intent. I didn't know you could write If - ElseIf - End If statements with both those functions and that it would work. I would be careful as I am not a good enough programmer to predict how long single lines like that would work out. And I think the case statements are more clear. I personally would use a lot of brackets (like in a long math equation that has +-* and / in it) just so I know what the order of operations that line would take. Here is the quick experiment I ran to try to figure it out.

Dim A,B,C As String
A = "1"
B = "0"
C = "0"

If A = "1" And (B = "1" Or C = "1")
	MessageBox.Show("1", "Test")
Else
	MessageBox.Show("2", "Test")
end if

Change lines 2 to 4 and see what message shows when it runs, 1 or 2. Change the code on line 6 as well.

 

EDIT: Just noticed. This is a bad line. The red text should be removed.

ElseIf DoorWidthOptions = DoorWidthOptions = "3-6" And DoorHeightOptions = "8-0" Then

 

0 Likes
Message 13 of 21

J_Pfeifer_
Advocate
Advocate

Correct, its all about using the correct tool for the job. Sometimes you need to quickly evaluate a single variable against many different options. This is where I personally use case statements. 

 

Its hard to place into words. I have models that could contain both a "K" or "D" For the middle letter. However the option thats turned on will only apply to those that do not include or have the final letter of the model ID as "H".

 

KG - true 

DG - true

 

KH - false

DH - False

 

NG - false

NH - false

 

This flips on a variable in the back ground that then gets used later. Only specific sets of model ID's actually require this item. However any ID that ends with H physically cannot have the object applied to it at fabrication. 

0 Likes
Message 14 of 21

SMillsYS3X2
Advocate
Advocate

One more quick note to help - Instead of using a number and checking if it is less than or equal (<=) AND greater than or equal (>=), just use either of those and if it is greater (>) or less than (<). 🤷‍ No overlap of possible values needed.

0 Likes
Message 15 of 21

KaynePellegrino
Enthusiast
Enthusiast

Thank you!

I think I was able to get it working with the stuff you sent. Still needs some cleaning up, but I'll need to do some studying to do that

Message 16 of 21

J-Camper
Advisor
Advisor

@KaynePellegrino ,

I think you just needed to think about the 3F door width options differently.  If you test for negative match first, then you don't need to list out all the other options.  I rewrote the main if statements you had into a select case as it is easier to add more DoorType options later, but try this:

'Door Type
Component.IsActive("1K Skin: Back") = False
Component.IsActive("1K Skin: Front") = False
Component.IsActive("2K Skin: Back") = False
Component.IsActive("2K Skin: Front") = False
Component.IsActive("3F Skin: Back") = False
Component.IsActive("3F Skin: Front") = False
Component.IsActive("3F (3-6) Skin: Back") = False
Component.IsActive("3F (3-6) Skin: Front") = False
Component.IsActive("3S Skin: Back") = False
Component.IsActive("3S Skin: Front") = False
Component.IsActive("50 Skin: Back") = False
Component.IsActive("50 Skin: Front") = False

Select Case DoorType
	Case "1K" 
		Component.IsActive("1K Skin: Back") = True
		Component.IsActive("1K Skin: Front") = True
	Case "2K" 
		Component.IsActive("2K Skin: Back") = True
		Component.IsActive("2K Skin: Front") = True
	Case "3F"
		If DoorWidthOptions <> "3-6"
			Component.IsActive("3F Skin: Back") = True
			Component.IsActive("3F Skin: Front") = True
		Else 
			If DoorHeightOptions = "8-0"
				Component.IsActive("3F (3-6) Skin: Back") = True
				Component.IsActive("3F (3-6) Skin: Front") = True
			Else
				MessageBox.Show(String.Format("DoorType = {0} | DoorWidthOptions = {1} | DoorHeightOptions = {2}", DoorType, DoorWidthOptions, DoorHeightOptions).ToString, "Un-Accounted For Result:")
			End If
		End If
	Case "3S" 
		Component.IsActive("3S Skin: Back") = True
		Component.IsActive("3S Skin: Front") = True
	Case "50" 
		Component.IsActive("50 Skin: Back") = True
		Component.IsActive("50 Skin: Front") = True
	Case Else
		MessageBox.Show(String.Format("DoorType = {0}", DoorType).ToString, "Un-Accounted For DoorType:")
End Select

 

You would need a more complex system if you needed more branches than isolating the 3-6 option from the rest of the width options.  I saw an unfinished branch if you have a 3-6 door width that isn't 8-0 tall, so I added a message in case that ever happens, or you can replace the message with whatever you want to happen in that case.  

Let me know if you have any questions

Message 17 of 21

KaynePellegrino
Enthusiast
Enthusiast

J-Camper

 

Thank you! This works too. Only part I don't get just from not knowing code very well, how does this work?

If DoorWidthOptions <> "3-6"

Like what does "<>" do exactly

0 Likes
Message 18 of 21

J-Camper
Advisor
Advisor

<> means "is not equal to".  Essentially it is the opposite of =.

That line says "If DoorWidthOptions is not set to 3-6, then do this:"  Every option that is not 3-6 will have that group of code to run.  If the option is set to 3-6 then the Else statement after that section will run instead.

Message 19 of 21

Curtis_Waguespack
Consultant
Consultant

@KaynePellegrino, I only skimmed through the discussion very quickly, so I might be a bit off base here, but I wanted to add that you can evaluate the condition for true/false, and set the skins to active statuses to be equal or Not equal to that as well. Just another approach, that might reduce the number of lines of code you need to set the IsActive lines.
Hope that helps,
Curtis

 

This example might or might not be accurate, but should give you an idea of what I am referring to.

 

Active_Condition = (DoorType = "3F" And (DoorWidthOptions = "2-6" Or DoorWidthOptions = "2-8" Or DoorWidthOptions = "2-10" Or DoorWidthOptions = "3-0"))

Component.IsActive("1K Skin: Back") = Active_Condition
Component.IsActive("1K Skin: Front") = Active_Condition
Component.IsActive("2K Skin: Back") = Not Active_Condition
Component.IsActive("2K Skin: Front") = Not Active_Condition
Component.IsActive("3F Skin: Back") = Not Active_Condition
Component.IsActive("3F Skin: Front") = Not Active_Condition
Component.IsActive("3F (3-6) Skin: Back") = Not Active_Condition
Component.IsActive("3F (3-6) Skin: Front") = Not Active_Condition
Component.IsActive("3S Skin: Back") = Not Active_Condition
Component.IsActive("3S Skin: Front") = Not Active_Condition
Component.IsActive("50 Skin: Back") = Not Active_Condition
Component.IsActive("50 Skin: Front") = Not Active_Condition

 

EESignature

0 Likes
Message 20 of 21

KaynePellegrino
Enthusiast
Enthusiast

J-Camper,

 

Got it, that's actually super nice to know

0 Likes