model.view()
Create and manage views.
For views defined on the global level, under Results, omit component(<ctag>). from the syntax such as model.component(<ctag>).view().create(<vtag>,<gtag>) in the syntax examples below.
Syntax
model.component(<ctag>).view().create(<vtag>,<gtag>)
model.component(<ctag>).view().create(<vtag>,<viewdim>)
model.component(<ctag>).view().create(<vtag>,<gtag>,<workplane>)
model.component(<ctag>).view(<vtag>).set(<pname>,<pvalue>)
model.component(<ctag>).view(<vtag>).getType(<pname>)
 
model.component(<ctag>).view(<vtag>).axis().set(<pname>,<pvalue>)
model.component(<ctag>).view(<vtag>).axis().getType(<pname>)
model.component(<ctag>).view(<vtag>).camera().set(<pname>,<pvalue>)
model.component(<ctag>).view(<vtag>).camera().getType(<pname>)
model.component(<ctag>).view(<vtag>).copyToGeometry()
model.component(<ctag>).view(<vtag>).copyToWorkPlane()
model.component(<ctag>).view(<vtag>).geom()
model.component(<ctag>).view(<vtag>).getHiddenEntities()
model.component(<ctag>).view(<vtag>).getHiddenEntities(<mesh>)
model.component(<ctag>).view(<vtag>).getSDim()
model.component(<ctag>).view(<vtag>).isCurrent()
model.component(<ctag>).view(<vtag>).light().create(<ltag>,<ltype>)
model.component(<ctag>).view(<vtag>).light(<ltag>).set(<pname>,<pvalue>)
model.component(<ctag>).view(<vtag>).light(<ltag>).getType(<pname>)
model.component(<ctag>).view(<vtag>).hideObjects().create(<htag>)
model.component(<ctag>).view(<vtag>).hideObjects(<htag>).set(<pname>,<pvalue>)
model.component(<ctag>).view(<vtag>).hideObjects(<htag>).getType(<pname>)
model.component(<ctag>).view(<vtag>).hideEntities().create(<htag>)
model.component(<ctag>).view(<vtag>).hideEntities(<htag>).set(<pname>,<pvalue>)
model.component(<ctag>).view(<vtag>).hideEntities(<htag>).getType(<pname>)
model.component(<ctag>).view(<vtag>).hideEntities(<htag>).image()
model.component(<ctag>).view(<vtag>).hideMesh().create(<htag>)
model.component(<ctag>).view(<vtag>).hideMesh(<htag>).set(<pname>,<pvalue>)
model.component(<ctag>).view(<vtag>).hideMesh(<htag>).getType(<pname>)
model.component(<ctag>).view(<vtag>).hideMesh(<htag>).image()
Description
View Settings
model.component(<ctag>).view() returns a list of view that can be used when viewing geometry/mesh and plot groups. Each view has an axis and some properties on the top level. In 3D, a view also has a camera and a list of lights. All views also have a list of hide features.
model.component(<ctag>).view().create(<vtag>,<gtag>) creates a view tied to the geometry with the given tag. The dimension of the view is the same as the dimension for the geometry.
model.component(<ctag>).view().create(<vtag>,<viewdim>) creates a view with the given tag for the given dimension (1, 2, or 3). These views are not tied to any geometry and show up under the Views node under Results in the COMSOL Desktop.
model.component(<ctag>).view().create(<vtag>,<gtag>,<workplane>) creates a view tied to the work plane with the given tag in the geometry sequence with the given tag. The dimension of the view is 2.
model.component(<ctag>).view(<vtag>).set(<pname>,<pvalue>) sets the given property to the given value.
model.component(<ctag>).view(<vtag>).geom() returns the geometry sequence (or null for the views not associated with a geometry).
model.component(<ctag>).view(<vtag>).getSDim() returns the view’s space dimension.
model.component(<ctag>).view(<vtag>).getType(<pname>) returns the property with the given name of type Type.
Table 2-143: view properties.
true | false
true | false
true | false
true | false
true | false
true | false
true | false
true | false
true | false
true | false
true | false
Axis Settings
The axis settings apply to 2D views with an x- and a y-axis.
model.component(<ctag>).view(<vtag>).axis().set(<pname>,<pvalue>) sets the given axis property to the given value. Which axis properties that are available in the different dimensions are given in the table below.
model.component(<ctag>).view(<vtag>).axis().getType(<pname>) returns the axis property with the given name.
Table 2-144: axis properties.
on | off
autofit | isotropic | anisotropic
The automatic view scaling when viewscaletype is set to automatic: autofit (the default), isotropic, or anisotropic.
on | off
on | off
on | off
on | off
on | off
none | manual | automatic
A positive scalar value for the x scale when viewscaletype is set to manual.
A positive scalar value for the x weight when autocontext is set to anisotropic.
A positive scalar value for the yscale when viewscaletype is set to manual.
A positive scalar value for the yweight when autocontext is set to anisotropic.
The minimum z-coordinate.
The maximum z-coordinate.
Camera Settings
These settings apply to the camera for 3D views.
model.component(<ctag>).view(<vtag>).camera().set(<pname>,<pvalue>) sets the given camera property to the given value.
model.component(<ctag>).view(<vtag>).camera().getType(<pname>) returns the camera property with the given name.
Table 2-145: Camera properties.
isotropic | anisotropic
true | false
Use automatic update of the view when viewscaletype is automatic.
on | off
none | automatic | manual
Lighting Settings
These settings control the different types of lighting — direction light, spotlight, headlight, and point light — that you can add to a 3D view.
model.component(<ctag>).view(<vtag>).light().create(<ltag>,<ltype>) creates a light with the given tag and type. <ltype> can be any of 'DirectionalLight', 'PointLight', 'SpotLight', and 'HeadLight'.
model.component(<ctag>).view(<vtag>).light(<ltag>).set(<pname>,<pvalue>) sets the given light property to the given value. Different properties are available for the different types of lights according to the table below.
model.component(<ctag>).view(<vtag>).light(<ltag>).getType(<pname>) returns the light property with the given name.
Table 2-146: light properties.
Cast shadows, if castlight is set to true.
on | off
DirectionalLight, SpotLight
PointLight, SpotLight
PointLight, SpotLight
The following table lists the light properties for 3D views:
custom | black | blue | cyan | gray | green | magenta | red | white | yellow | none
true | false
true | false
true | false
Include scene light. Must be true for the other properties to be active.
true | false
true | false
true | false
Visual Effects Settings: Ambient Occlusion, Shadows, and Gamma Correction
The following table lists the properties for 3D views that control visual effects such as ambient occlusion, direct and floor shadows, and gamma correction:
The brightness, if displayoutputpreset is set to custom.
The contrast, if displayoutputpreset is set to custom.
The exposure value, if displayoutputpreset is set to custom.
The gamma value, if displayoutputpreset is set to custom.
The hue, if displayoutputpreset is set to custom.
default | custom
The saturation, if displayoutputpreset is set to custom.
"1" (Clamp)
The tone map to use if displayoutputpreset is set to custom. The "0" to "4" correspond to Filmic, None (the default), Extreme, Bright, and Natural, respectively.
Pitch angle for the floor shadows (in degrees), if flooreffectnormalsettings is set to angle.
The floor effect normal vector, if flooreffectnormalpreset is set to custom.
xyplane | yzplane | zxplane | yzplane | zyplane | xzplane | custom
The floor shadow normal preset, if flooreffectnormalsettings is set to explicit.
angle | explicit
The floor effect origin, if flooreffectoriginsettings is set to explicit.
farthestvertex | boundingsphere | boundingbox | explicit
Additional blur, if flooreffectshadowblur is set to true.
Use accurate depth comparison, when shadowmappingpreset is set to preset.
default | custom
Constant depth bias, if shadowmappingbiassettings is set to custom.
Limit light view frustums, when shadowmappingpreset is set to preset.
Use multisampling everywhere, when shadowmappingpreset is set to preset.
Number of occluder samples, when shadowmappingpreset is set to preset.
Use normal-aware smoothing, if shadowmappingaccuratedepthcomparison is set to true.
Normal offset bias, if shadowmappingbiassettings is set to custom.
Number of samples, when shadowmappingpreset is set to preset.
low | medium | high | custom
Resolution, when shadowmappingpreset is set to preset.
Slope depth bias, if shadowmappingbiassettings is set to custom.
Kernel rotations texture width, when ssaopreset is set to custom.
Number of samples, when ssaopreset is set to custom.
low | medium | high | custom
Maximum distance to occluder, when ssaoradiustype is set to explicit.
Fraction of scene bounding box, when ssaoradiustype is set to relative.
relative | explicit
Resolution, when ssaopreset is set to custom.
Roughness, when ssaopreset is set to custom.
Smooth, when ssaopreset is set to custom.
Hiding Geometry Objects, Geometric Entities, and Imported Meshes
model.component(<ctag>).view(<vtag>).hideObjects().create(<htag>) creates a hide feature of geometric objects in the geometry sequence. The API for controlling it is similar to the API for selection in the geometry sequence; see Geometry Object Selection Methods under model.geom().
model.component(<ctag>).view(<vtag>).hideEntities().create(<htag>) creates a hide feature of geometric entities in the analyzed geometry used, for example, for the physics. The API for controlling it is similar to the API for selections on the finalized geometry; see model.selection().
model.component(<ctag>).view(<vtag>).hideMesh().create(<htag>) creates a hide feature of geometric entities in the analyzed geometry from an imported mesh used, for example, for the physics. The API for controlling it is similar to the API for selections on the finalized geometry; see model.selection(). For example, the following code hides boundary 4 in the geometry based on the mesh in mesh1:
// Create mesh hide object in view 1
model.component("comp1").view("view1").hideMesh().create("hide1");
// Select mesh1
model.component("comp1").view("view1").hideMesh("hide1").mesh("mesh1");
// Hide boundary 4 (3D is assumed)
model.component("comp1").view("view1").hideMesh("hide1").geom(2).set(4);
model.component(<ctag>).view(<vtag>).getHiddenEntities() returns an integer array of hidden entities in each dimension. The entity numbers refer to the entities of the finalized geometry. model.component(<ctag>).view(<vtag>).getHiddenEntities(<mesh>) returns an integer array of hidden entities in each dimension. The entity numbers refer to the entities of specified meshing sequence with the tag <mesh> in its current state.
For plotting or exporting images of views with hidden objects, use the model.component(<ctag>).view(<vtag>).hideEntities(<htag>).image() and model.component(<ctag>).view(<vtag>).hideMesh(<htag>).image() methods. See Plotting and Exporting Images.
Copying Views
To copy a view to a geometry or work plane, you can use the copyToGeometry and copyToWorkPlane methods. For example,
model.component("comp1").view("view1").copyToWorkPlane();
copies the view view1 to a work plane.
Clipping Tool Settings
These settings control the different types of clipping tools — clip plane, clip box, clip sphere, and clip cylinder — that you can add to a 3D view.
model.component(<ctag>).view(<vtag>).clip().create(<ctag>,<ctype>) creates clipping tool with the given tag and type. <ctype> can be any of 'ClipPlane', 'ClipBox', 'ClipSphere', and 'ClipCylinder'.
model.component(<ctag>).view(<vtag>).clip(<ctag>).set(<pname>,<pvalue>) sets the given clipping tool property to the given value. Different properties are available for the different types of clipping tools according to the table below.
model.component(<ctag>).view(<vtag>).clip(<ctag>).getType(<pname>) returns the clipping tool property with the given name.
true | false
Set to false to disable the clipping action for the clipping tools.
true | false
true | false
true | false
true | false
custom | fromtheme | black | blue | cyan | gray | green | magenta | red | white | yellow | none
The coloring of the intersection highlight, if cliphighlightintersection is set to true.
true | false
true | false
true | false
true | false
true | false
Colorize cross sections, if clipshowcappedfaces is true.
domain | object
true | false
Highlight overlapping domains, if clipshowcappedfaces is true.
custom | fromtheme | black | blue | cyan | gray | green | magenta | red | white | yellow | none
The coloring of the overlapping domains, if clipcappedfaceshighlight
overlappingdomains
is true.
true | false
true | false
true | false
The following table lists the properties available for the clipping tools. Properties that are not available for all clipping tools have a note about availability in the Description column.
true | false
Set to false to disable the clipping action for the clipping tools.
true | false
true | false
true | false
The radius of the clipping tool. For ClipSphere and ClipCylinder only.
true | false
true | false
Environment Mapping Settings
These settings control the environment mapping that can provide reflections on the model geometry and as a skybox to provide a background in the view. You add environment mapping by, for example, specifying one of the built- in environment maps (images), such as envmap_park2:
 model.component(<ctag>).view(<vtag>).set("environmentmap","envmap_park2") adds an environment map that shows a city park. To see its reflection on a model geometry you need to clear any selections and also activate the setting for showing material color and texture: model.component(<ctag>).view(<vtag>).set("showmaterial",true);
You can also add an user-defined environment map by specifying its name followed by the suffix (Local) or (Model), depending on where the environment map is stored.
The environment map to use. Use none to turn off environment mapping.
low | medium | high | ultra
true | false
true | false
true | false
The blending of the skybox, if skybox is set to true. 1 means no blending.
The blurriness of the skybox, if skybox is set to true. 0 means no blurriness.
Skybox field of view, in degrees, if skyboxprojection is set to special.
special | fromcamera
The skybox projection, if skybox is set to true. With fromcamera. the camera’s projection is used.
positivex | negativex | positivey | negativey | positivez | negativez
skyrotationzero | skyrotationninety | skyrotationhundredeighty | skyrotationtwohundredseventy
See Also
model.result()