make_image
make_image(safe_url, title, [id: text])
Creates an image that can be viewed in the "Imagery" tab if it is associated with an asset.
The safe_url can be created using make_url
.
Example: make_image(make_url(templated_url: templated_url, substitution: map("PATH", "myPath")), "title")
digest
digest(items, [digits: 12])
Generates a deterministic digest of the given primitives (based on sha1). The output is in decimal digits without a leading zero, so it can be used as an integer.
Warning: if digits exceeds 15, it may not be possible to properly convert it to a number.
Example: digest(tuple("some text", 5), digits: 12)
will always return 488277805109
.
get_terrain_height
get_terrain_height(location, [dataset_name], [search_radius])
Queries the terrain height at the specified coordinate for the specified dataset.
A terrain height of -1000.0
is returned if no terrain height can be found at the location.
If the terrain is sourced through point cloud, the following arguments are available to refine your search:
dataset_name
: provide one or more dataset names to perform the terrain query using only the specified datasetssearch_radius
: override the distance within which the terrain search is performed. Defaults to searching within a 10.0m radius
authorize_service
authorize_service(service_name)
Returns a TemplatedUrl
if the service authentication is successful.
The TemplatedUrl
can then be passed to the make_url
function for user substitution.
Authentication in on a per-org basis, so individual login credentials are not required.
make_comment_anchor
make_comment_anchor(object, [offset: vec3, component_key: string])`
Makes an anchor that a comment can be attached to.
object
: model object that the comment will be anchored to.offset
: a vec3 offset within the coordinate system of object.component_key
: user-specified string to disambiguate between multiple anchors on the same object.
get_current_scope_ids
get_current_scope_ids()
Returns the list of object ids in the current "scope".
For example, when using "Switch Scope ID and Load" hyperlink mode in Analytics Reports, this function returns the id of the selected object.
Example:
Create "u_scope_ids"
on Model with get_current_scope_ids()
and on an appropriate report column, apply a "formula" filter specifying u_scope_ids
.
Query: dt_lookup
dt_lookup(name, field, value)
Returns the first record from the given data table where the field matches the given value.
Example: find(model().dt_your_table_name
)
is preferred unless performance is needed.
QA: fetch_analytics_report
fetch_analytics_report(report_name, [ dataset_id: ""]) " ])
Fetches all rows of of an analytics report that intersects the model bounds into a list of JSON objects.
If [dataset_id]
is provided, report_name
should be the name of the report as it is stored on the server, otherwise report_name
refers to the name of an analytics report in your project.
get_analytics_report
Deprecated: Use fetch_analytics_report(report_name)
instead
get_analytics_report(report_name)
viz
viz(args)
General function for building 3D visualizations that can be displayed by visualizing the field in the report. Takes a sub-command and then arguments specific to the command.
The following commands are supported:
Command | Action |
| Draws a poly-line between any number of absolute-coordinate points |
| Same as "line" but puts an arrow head on the last point |
| Draws a circular arc centered on center_point, between the two offsets. The offsets are relative, not coordinates. The radius of the arc is based on the larger of the two offsets. |
| Draws text at the given coordinate |
| Applies styling to all the objects within the list |
Valid style strings consist of space-separated tokens, and may contain:
a color name or #hex code
the word
"solid"
or"stipple"
to control line stylewidth:num
e.g."width:0.2"
where num is specified without units and controls line thickness in meters
The list passed to the "style"
sub-command can be composed of other things constructed by viz()
, as well as a set of recognized geometrical objects, mainly catenaries and 3D polylines.
Examples
All of these are custom fields on Pole (so referenced properties access pole properties):
viz("line", top, top + vec3(0, 0, 2m))
creates a vertical line from the top of the pole, upwardsviz("arrow", top, top + vec3(0, 0, 2m))
creates an arrow pointing up from the top of the poleviz("arc", top, vec3(0, 0, 2m), vec3(longitudinal_direction, 0) * 2m)
creates an arc from vertical down in the longitudinal direction of the pole.viz("text", top + vec3(0,0,1m), "hello")
displays the text "hello" 1m above the poleviz("style", "solid red width:0.1", list(viz(...), viz(...), u_more_viz_items))
styles the nested visualizations
make_field_mutation
Creates a project action that writes to one or more fields of an object, when executed.
make_field_mutation(object, [label, field1:value1, field2:value2, ...])
The first argument is the object to be mutated. This is followed by an optional label for the resulting project action. If a list of objects is provided, the mutation will be applied to each object in the list.
All named arguments must correspond to existing settable fields on the object, with the provided values being written to those fields.
Values must be of a type that is assignable to the fields existing type.
Examples
Update user-defined properties on the model:
make_field_mutation(
model(),
u_text_property: "New Value",
u_int_property: 23,
u_bool_property: true,
u_real_property: 23m
)
Set the length of the current object to 2m
:
make_field_mutation(self, length: 2m)
Set all pole types in the model to 5m
long:
make_field_mutation(model().PoleLibrary, length: 5m)