If, ElseIf, Else, EndIf
Construct an If statement, enabling or disabling features depending on conditions in terms of parameters.
Syntax
model.component(<ctag>).geom(<tag>).create(<ftag>,<type>);
model.component(<ctag>).geom(<tag>).createAfter(<ftag>,<type>,<postag>);
model.component(<ctag>).geom(<tag>).feature(<ftag>).set(property,<value>);
model.component(<ctag>).geom(<tag>).feature(<ftag>).getType(property);
Description
Use model.component(<ctag>).geom(<tag>).create(<ftag>,<type>) to add an If, ElseIf, Else, or EndIf feature after the current feature.
Use model.component(<ctag>).geom(<tag>).feature().createAfter(<ftag>,<type>,<postag>) to add an If, ElseIf, Else, or EndIf feature after the feature tagged <postag>.
The following property is available for If and ElseIf only:
Table 3-90: Valid Property.
Example
Build a block if variant = 1, else build a cone:
Code for Use with Java
Model model = ModelUtil.create("Model1");
model.param().set("variant", "1");
model.component().create("comp1");
GeomSequence g = model.component("comp1").geom().create("geom1", 3);
g.create("if1", "If");
g.feature("if1").set("condition", "variant==1");
g.create("blk1", "Block");
g.create("else1", "Else");
g.create("cone1", "Cone");
g.create("endif1", "EndIf");
g.run();
model.param().set("variant", "2");
g.run();
Code for Use with MATLAB
model = ModelUtil.create('Model1');
model.param.set('variant', '1');
model.component.create('comp1');
g = model.component('comp1').geom.create('geom1', 3);
g.create('if1', 'If');
g.feature('if1').set('condition', 'variant==1');
g.create('blk1', 'Block');
g.create('else1', 'Else');
g.create('cone1', 'Cone');
g.create('endif1', 'EndIf');
g.run;
model.param.set('variant', '2');
g.run;