if، ElseIf، Else، EndIf

if، ElseIf، Else، EndIf

if، ElseIf، Else، EndIf
یک دستور If بسازید، بسته به شرایط از نظر پارامترها، ویژگی ها را فعال یا غیرفعال کنید.
نحو
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( خاصیت , <value> );
model.component( <ctag> ).geom( <tag> ).feature( <ftag> ).get Type ( خاصیت );
شرح
از model.component( <ctag> ).geom( <tag> ).create( <ftag> <type> ) برای اضافه کردن ویژگی If، ElseIf، Else، یا EndIf بعد از ویژگی فعلی استفاده کنید.
از model.component( <ctag> ).geom(<tag>).feature().createAfter( <ftag> <type> <postag> ) برای اضافه کردن یک ویژگی If، ElseIf، Else یا EndIf بعد از ویژگی استفاده کنید . برچسب شده <postag> .
ویژگی زیر فقط برای If و ElseIf موجود است:
جدول 3-88: دارایی معتبر
نام
ارزش
پیش فرض
شرح
وضعیت
دو برابر
1
شرایط منطقی از نظر پارامترها.
مثال
اگر نوع  = 1 یک بلوک بسازید، در غیر این صورت یک مخروط بسازید:
کد برای استفاده با جاوا
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();
کد برای استفاده با متلب
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