Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.
Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.
How to find entities of expelicit selection in the Work plane of a 3D model (API model)
Posted Apr 26, 2014, 7:33 p.m. EDT Interfacing Version 4.4 0 Replies
Please login with a confirmed email address before reporting spam
I have created a geometry in the work plane of a 3D geometry (which is obviously in 2D mode at this stage).
and i have created explicit selection feature and set the selection object as well. when I try to read the entities associated to it, I get nothing. My code is working in the 2D model but for 3D model it is not working.
my code is :
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
import com.comsol.model.*
import com.comsol.model.util.*
model = ModelUtil.create('Model');
model.modelNode.create('comp1');
model.geom.create('geom1', 3);
model.geom('geom1').lengthUnit([native2unicode(hex2dec({'00' 'b5'}), 'unicode') 'm']);
model.geom('geom1').feature.create('wp1', 'WorkPlane');
model.geom('geom1').feature('wp1').geom.feature.create('r1', 'Rectangle');
model.geom('geom1').feature('wp1').geom.feature.create('r2', 'Rectangle');
model.geom('geom1').feature('wp1').geom.feature.create('r3', 'Rectangle');
model.geom('geom1').feature('wp1').geom.feature.create('r4', 'Rectangle');
model.geom('geom1').feature('wp1').geom.feature.create('r5', 'Rectangle');
model.geom('geom1').feature('wp1').geom.feature.create('dif1', 'Difference');
model.geom('geom1').feature('wp1').geom.feature.create('sel1', 'ExplicitSelection');
model.geom('geom1').feature('wp1').geom.feature('r1').set('size', {'110' '85'});
model.geom('geom1').feature('wp1').geom.feature('r1').set('pos', {'0' '0'});
model.geom('geom1').feature('wp1').geom.feature('r2').set('size', {'25' '25'});
model.geom('geom1').feature('wp1').geom.feature('r2').set('pos', {'95' '60'});
model.geom('geom1').feature('wp1').geom.feature('r3').set('size', {'15' '25'});
model.geom('geom1').feature('wp1').geom.feature('r3').set('pos', {'-5' '55'});
model.geom('geom1').feature('wp1').geom.feature('r4').set('size', {'50' '25'});
model.geom('geom1').feature('wp1').geom.feature('r4').set('pos', {'-10' '0'});
model.geom('geom1').feature('wp1').geom.feature('r5').set('size', {'50' '50'});
model.geom('geom1').feature('wp1').geom.feature('r5').set('pos', {'70' '-20'});
model.geom('geom1').feature('wp1').geom.feature('dif1').selection('input2').set({'r2' 'r3' 'r4' 'r5'});
model.geom('geom1').feature('wp1').geom.feature('dif1').selection('input').set({'r1'});
model.geom('geom1').feature('wp1').geom.feature('sel1').selection('selection').init;
model.geom('geom1').feature('wp1').geom.feature('sel1').selection('selection').set({'dif1'});
model.geom('geom1').run;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
if i try to get the entities of "sel1" by :
model.geom('geom1').feature('wp1').geom.selection('sel1').entities(2)
it gives me empty output while the JAVA object contents the "dif1" object ... i really appropriate if you can help me to find a way to solve this problem?
PS. i am using Matlab live link
Hello Mohammad Mousavi
Your Discussion has gone 30 days without a reply. If you still need help with COMSOL and have an on-subscription license, please visit our Support Center for help.
If you do not hold an on-subscription license, you may find an answer in another Discussion or in the Knowledge Base.