Using Geometry Parts
For a description of geometry parts, see Using Geometry Parts in the COMSOL Multiphysics Reference Manual.
To create a geometry part, enter
model.geom().create(<tag>, "Part", sDim);
where <tag> is the parts tag, and sDim is its space dimension (1, 2, or 3).
To add an input parameter to the part, enter
model.geom(<tag>).inputParam().set(<name>, <expr>, <descr>);
where the description <descr> can be omitted.
Similarly, add a local parameter by
model.geom(<tag>).localParam().set(<name>, <expr>, <descr>);
The containers model.component(<ctag>).geom(<tag>).inputParam() and model.component(<ctag>).geom(<tag>).localParam() also support the other methods listed in model.param() and model.result().param().
To load one or more geometry parts, enter
model.geom().load(<tags>, <filename>, <partTagsInFile>);
where <tags> is a list of part tags, <filename> is the filename of the MPH-file where the parts are defined, and <partTagsInFile> is a list of the parts’ tags in that file. If model.geom(<gtag>) is a geometry part, model.geom(<gtag>).loaded() returns true if the part was created by loading it from a file.
To get the filename of a loaded part, enter
model.geom(<gtag>).filename();
To change the filename of a loaded part, enter
model.geom(<gtag>).filename(<filename>);
where <filename> is the new filename.
For a loaded part, to return the comments from the MPH-file, enter
model.geom(<gtag>).commentsInFile();
For a loaded part, to return the last modification date from the MPH-file, enter
model.geom(<gtag>).dateModifiedInFile();
To get the tag that a loaded part has in the MPH-file, enter
model.geom(<gtag>).tagInFile();
To get the label that a loaded part has in the MPH-file, enter
model.geom(<gtag>).labelInFile();
For a loaded part, to return the version from the MPH-file, enter
model.geom(<gtag>).versionInFile();
To reload (update) a loaded part after its definition has been changed, enter
model.geom(<gtag>).reload();
To call a geometry part in a component geometry, add a PartInstance feature:
model.component(<ctag>).geom(<gtag>).create(<ftag>, "PartInstance");
See PartInstance for details.
To debug a call to part, you can step into it using
model.component(<ctag>).geom(<gtag>).stepInto(<ftag>);
You can then apply the usual geometry sequence methods on the local part instance, for example,
model.component(<ctag>).geom(<gtag>).feature(<ftag>).geom().run(<ftag2>);
to build the feature <ftag2> in the local part instance.
To make the part a part variant, enter
model.geom(<tag>).partVariant();
To check if the part is a part variant, enter
model.geom(<tag>).isPartVariant();
There is also a selcolorlevel property for geometry parts, which is a string array (by default all none) that indicates the colors of the selections (a read-only property). It is only available for domains and boundaries in 3D and domains in 2D.