view::namedFunction in std::view
Create a named view: a camera paired with the objects the view shows or hides.
Added in KCL 3.0.
A view is data, not an action. Creating one moves no camera and changes nothing about what is visible; a consumer such as the modeling app or a STEP export activates it later, which is why the same file yields the same views on every machine.
The name is display text, so it may contain spaces and punctuation. It is
required, because a view is identified by the name you give it and not by
the variable you bind it to, so renaming a variable never renames a view.
Names are unique within one file and compared exactly, which makes Front
and front two different views. Four names are rejected:
- the empty string, which identifies nothing;
- a name of nothing but whitespace, which displays as nothing;
- a name that starts or ends with whitespace, which a reader cannot see but the exact comparison above counts;
Default View, which is reserved for the view of the scene generated on successful execution of the program.
baseline and except together decide what the view shows. You start from a
clean state: baseline sets the visibility every object takes, and except
lists the objects that depart from it. Every view writes its baseline out, so
what a view shows can be read from the call alone:
baseline = Visibility::Showalone: everything is visible;baseline = Visibility::Showwithexcept = [a, b]: everything is visible exceptaandb;baseline = Visibility::Hidewithexcept = [a, b]: onlyaandbare visible;baseline = Visibility::Hidealone: nothing is visible.
Duplicates in except are dropped, so listing an object twice does the same
as listing it once.
Plane support
A named view can control only an independently visible plane.
Supported planes:
- A plane returned by
offsetPlane()that has not been used as the support plane for a sketch.
Unsupported planes:
- The default planes:
XY.-XY.XZ.-XZ.YZ.-YZ.
- A plane returned by
offsetPlane()after it has been used as the support plane for a sketch. The executor hides that plane as sketch support. - A plane returned by
planeOf(), whether it remains unused or is used as sketch support. The engine creates it as hidden construction geometry. - An object coerced to
Plane. It describes a plane but does not have the internal properties of a plane object that can be used by a named view.
Unsupported planes are handled in two ways:
- Passing a default plane or an object coerced to
Planecausesview::named()to return an error. - Passing a
planeOf()result or an offset plane used as sketch support still creates the named view. That plane is omitted when the view is activated, so listing it inexcepthas no effect and does not reveal the construction geometry that the executor hid.
Passing a planeOf() result to offsetPlane() creates a new plane. That new
result is supported if it is not subsequently used as sketch support; the
original planeOf() result remains unsupported.
Arguments
| Name | Type | Description | Required |
|---|---|---|---|
name | string | The name of the view, as a reader should see it. Required, unique within the file, and compared exactly. | Yes |
camera | CameraView | The camera the view activates. Call view::oriented() or view::directed() to build one. | Yes |
baseline | Visibility | The default visibility of every object the program creates: visible under Visibility::Show, hidden under Visibility::Hide. Use except below to override that default for individual objects. | Yes |
except | [Solid or Sketch or GdtAnnotation or Helix or Plane or ImportedGeometry; 1+] | The objects the baseline does not apply to: the hidden ones under a Show baseline, and the only visible ones under Hide. | No |
Returns
NamedView - A named view: a camera paired with the set of objects it shows or hides.