How to apply multiple "if" expressions (Subassembly composer)?

How to apply multiple "if" expressions (Subassembly composer)?

joseley_gildo
Contributor Contributor
3,779 Views
7 Replies
Message 1 of 8

How to apply multiple "if" expressions (Subassembly composer)?

joseley_gildo
Contributor
Contributor
For example, I want to apply to Delta X and Delta Y of a single point, assuming multiple "if" expressions:

if(TDrenagem.Value="Valeta",XDrenagemSolo+WSolo+.3,XDrenagemSolo+EDrenagemSolo*2+WSolo)

And

if(TDrenagem.Value="ValetaTrapezoidal",XDrenagemSolo+WSolo+.6,XDrenagemSolo+EDrenagemSolo*2+WSolo)

And

if(TDrenagem.Value="NA",WSolo,XDrenagemSolo+EDdrainagemSolo*2+WSolo)
0 Likes
Accepted solutions (1)
3,780 Views
7 Replies
Replies (7)
Message 2 of 8

joseley_gildo
Contributor
Contributor

I already tried to insert "else" "if-else" "else-if", but the expression does not accept the continuity of the code...

0 Likes
Message 3 of 8

acad_ahossain
Advocate
Advocate

Hi @joseley_gildo 

 

Can you attach PKT file to check all variables ?

0 Likes
Message 4 of 8

Udo_Huebner
Mentor
Mentor
Accepted solution

You could use a switch Statement instead.

Udo_Huebner_0-1690038982428.png

 

Gruß Udo Hübner (CAD-Huebner)
Message 5 of 8

johncarter3219
Observer
Observer

In Subassembly Composer, you can apply multiple "if" expressions using nested conditional statements. Combine the three expressions into one by checking each condition sequentially: If TDrenagem.Value is "Valeta", calculate XDrenagemSolo + WSolo + 0.3; If "ValetaTrapezoidal", calculate XDrenagemSolo + WSolo + 0.6; If "NA", calculate WSolo; Otherwise, calculate XDrenagemSolo + EDrenagemSolo * 2 + WSolo. Test the code with various input values to ensure proper functionality. Replace EDdrainagemSolo with EDrenagemSolo in the third expression.

Message 6 of 8

joseley_gildo
Contributor
Contributor
How did I not think of the switch? It worked, it was exactly what I was wanting.
Thank you very much for your contribution.
 
joseley_gildo_0-1690073292923.png

 

 
0 Likes
Message 7 of 8

joseley_gildo
Contributor
Contributor
I managed to solve it with the "switch" solution. But I was curious about the functioning of the "if", I tested separating the "if" with ";", but it does not accept the continuity of the expression...
thank you for your contribution
0 Likes
Message 8 of 8

tom_cools63N7X
Contributor
Contributor

Hello Everybody, 

 

I want also make a .pkt file/subassembly based on decisions.

To be more detailed, i want to put a code in the shape witch is based on different factors that will be determined in Civil3d by inputparameters. So one combination off that factors needs to give one unique code.

 

But the use of the "IF" and "AND" in de expression editor doesnt work in my pkt file...anyone knows why this is giving an error? The error message says (translated from dutch) "Cannot derive a general type because multiple types are possible"

 

tom_cools63N7X_3-1710422721680.png

I attached the pkt file also

 

Many tnx already if you are watching this and would give a solution for this problem!!

 

Grtz Tom Cools