# tabletree package

## Module contents

class tabletree.Column(name, property_key, property_type, property_subtype=None, summary_options=None)

  Create a column for a property.

  Parameters:

    - name (str | I18nWord) – The name of the column.

    - property_key (str) – The property to be shown in the column.

    - property_type (ColumnType) – The type of the property.

    - property_subtype (ColumnImageType | ColumnUnitfulType | None) –

      The image format (ColumnImageType) for a column with ‘image’ property_type.

      The length unit (ColumnUnitfulType) for a column with ‘unitful’ property_type.

    - summary_options (dict[str, Any] | None) – The summary options for a column with ‘summary’ property_type.

  add_choice(choice)

    Add an option for editing and setting a filter to the property.

    Parameters:

      choice (str | I18nWord) – The value to be added as an option.

    Return type:

      Self

  set_filter_type(filter_type)

    Set filter type to the column.

    Parameters:

      filter_type (ColumnFilterType) –

      ‘none’:

        No filter can be set for the column.

      ’range’:

        The table items can be filtered with maximum and minimum values of the property.

      ’select’:

        The table items can be filtered with a set of values of the property.

      ’existence’:

        The table items can be filtered by whether they have non-nullish values as the property or not.

      ’free’:

        The table items can be filtered with a text or a regular expression.

    Return type:

      Self

  set_flag(flag, state)

    Change a flag state of the column.

    Parameters:

      - flag (ColumnFlag) –

        ‘is_resizable’ (default: true):

          If true, a user can change the column width.

        ’is_hidden’ (default: false):

          If true, the column is not shown in the table by default.

        ’is_statistical’ (default: false):

          If true, the numbers of each property values are shown on the status bar.

        ’is_editable’ (default: false):

          If true, a user can edit the values of the property.

        ’is_display_large’ (default: false):

          If true, the property is shown in an exclusive tab in the property list.

      - state (bool) – The new state of the flag.

    Return type:

      Self

  set_max_width(width)

    Set the maximum width of the column.

    Parameters:

      width (int | I18nWord) – The maximum width of the column.

    Return type:

      Self

  set_min_width(width)

    Set the minimum width of the column.

    Parameters:

      width (int | I18nWord) – The minimum width of the column.

    Return type:

      Self

  set_property_for_sort(key)

    Set a key used to sort the items.

    Parameters:

      key (str) – The property key used to sort the items.

    Return type:

      Self

class tabletree.Feature(name)

  Create a feature.

  Parameters:

    name (str | I18nWord) – The name of the feature.

  register_geometries(key, geoms)

    Register a set of geometry elements.

    Call this method within a frt session.

    Parameters:

      - key (str) – The key for the geometries.

      - geoms (Sequence[TypeAliasForwardRef('GeomElement')]) – The geometries to be registered.

    Return type:

      Self

  register_geometry(key, geom, colors=None)

    Register a geometry element and its results of measurements.

    Call this method within a frt session.

    Parameters:

      - key (str) – The key for the geometry.

      - geom (GeomElement) – The geometry to be registered.

      - colors (Sequence[HighlightColor.HighlightColorPreset | HighlightColor] | None) – The color(s) of the geometry. The number of colors must be either one or the same as the number of points in a PointCloud.

    Return type:

      Self

  set_file_as_link_property(key, file_path)

    Set a file as a link property.

    Parameters:

      - key (str) – The property key.

      - file_path (str) – The path to the file.

    Return type:

      Self

  set_image_as_property(key, image_path)

    Set an image as a property.

    Parameters:

      - key (str) – The property key.

      - image_path (str) – The path to the image file.

    Return type:

      Self

  set_property(key, value, huge=None)

    Set a new value to a user-defined property.

    Parameters:

      - key (str) – The property key.

      - value (Any) – The new value to be set to the property.

      - huge (bool | None) – If true, data size optimization is enabled. Set true if the value can be huge.

    Return type:

      Self

class tabletree.I18nWord

  A word.

  en: str | int | None

    The English for the vocabulary.

  ja: str | int | None

    The Japanese for the vocabulary.

  key: str

    The key for the vocabulary.

  zh_cn: str | int | None

    The Chinese for the vocabulary.

class tabletree.ModelInfo
  part_names: PartNames

class tabletree.NameColumn

  Create a style for a name column of a table.

  set_flag(flag, state)

    Change a flag state of the column.

    Parameters:

      - flag (ColumnFlag) –

        ‘is_resizable’ (default: true):

          If true, a user can change the column width.

        ’is_hidden’ (default: false):

          If true, the column is not shown in the table by default.

        ’is_statistical’ (default: false):

          If true, the numbers of each property values are shown on the status bar.

        ’is_editable’ (default: false):

          If true, a user can edit the values of the property.

        ’is_display_large’ (default: false):

          If true, the property is shown in an exclusive tab in the property list.

      - state (bool) – The new state of the flag.

    Return type:

      Self

  set_max_width(width)

    Set the maximum width of the column.

    Parameters:

      width (int | I18nWord) – The maximum width of the column.

    Return type:

      Self

  set_min_width(width)

    Set the minimum width of the column.

    Parameters:

      width (int | I18nWord) – The minimum width of the column.

    Return type:

      Self

  set_property_for_sort(key)

    Set a key used to sort the items.

    Parameters:

      key (str) – The property key used to sort the items.

    Return type:

      Self

class tabletree.PartNames
  DisplayPartName: str
  DisplayPartNumber: str
  partName: str
  partNumber: str

class tabletree.Table(name)

  Create a table.

  Parameters:

    name (str | I18nWord) – The name of the table.

  add_column(column)

    Add a column to the table.

    Parameters:

      column (Column) – The column to be added.

    Return type:

      Self

  add_item(item)

    Add an item to the table.

    Parameters:

      item (Feature | Self) – The item to be added.

    Return type:

      Self

  add_view(view, default_on_event=None)

    Add a 3D view to the table.

    Parameters:

      - view (View) – The 3D view.

      - default_on_event (Sequence[ViewEventType] | None) –

        None:

          The view is not triggered by default.

        ’on_single_clicked’:

          The view is triggered on a single click. If more than one views are added with this option, the last one is triggered on a single click by default.

        ’on_double_clicked’:

          The view is triggered on a double click. If more than one views are added with this option, the last one is triggered on a single click by default.

    Return type:

      Self

  register_geometries(key, geoms)

    Register a set of geometry elements.

    Call this method within a frt session.

    Parameters:

      - key (str) – The key for the geometries.

      - geoms (Sequence[TypeAliasForwardRef('GeomElement')]) – The geometries to be registered.

    Return type:

      Self

  register_geometry(key, geom, colors=None)

    Register a geometry element and its results of measurements.

    Call this method within a frt session.

    Parameters:

      - key (str) – The key for the geometry.

      - geom (GeomElement) – The geometry to be registered.

      - colors (Sequence[HighlightColor.HighlightColorPreset | HighlightColor] | None) – The color(s) of the geometry. The number of colors must be either one or the same as the number of points in a PointCloud.

    Return type:

      Self

  set_file_as_link_property(key, file_path)

    Set a file as a link property.

    Parameters:

      - key (str) – The property key.

      - file_path (str) – The path to the file.

    Return type:

      Self

  set_image_as_property(key, image_path)

    Set an image as a property.

    Parameters:

      - key (str) – The property key.

      - image_path (str) – The path to the image file.

    Return type:

      Self

  set_item_name_column(name_column)

    Set a NameColumn to the table.

    Parameters:

      name_column (NameColumn) – The NameColumn to be set.

    Return type:

      Self

  set_property(key, value, huge=None)

    Set a new value to a user-defined property.

    Parameters:

      - key (str) – The property key.

      - value (Any) – The new value to be set to the property.

      - huge (bool | None) – If true, data size optimization is enabled. Set true if the value can be huge.

    Return type:

      Self

class tabletree.View(view_id, name)

  Create a 3D view for the items.

  Parameters:

    - view_id (str) – The unique id of the view.

    - name (str | I18nWord) – The name of the view.

  available_on(event_types)

    Set types of events that can trigger the view.

    Parameters:

      event_types (Sequence[TypeAliasForwardRef('ViewEventType')]) – The types of events that can trigger the view. If not set, the view is triggered only when it is invoked from the context menu of items.

    Return type:

      Self

  create_section_at(key_position, key_normal, key_rotation_axis=None)

    Create a section in the view.

    Parameters:

      - key_position (str) – The property key for the position of the section.

      - key_normal (str) – The property key for the unit vector normal to the section plane.

      - key_rotation_axis (str | None) – The property key for the unit vector used as the manipulator rotation axis.

    Return type:

      Self

  highlight(highlights)

    Highlight geometry elements in the view.

    Parameters:

      highlights (list[Highlight]) – A list of Highlight objects.

    Return type:

      Self

  show_only_neighbors_of(keys)

    Set the geometries to be displayed in the neighbor view.

    Only the elements themselves and neighbors of them are shown in the view.

    Parameters:

      keys (Sequence[str]) – The keys for the geometries to be displayed in the neighbor view.

    Return type:

      Self

  view_from(key_position, key_direction, key_upward)

    Set the view direction and position.

    Parameters:

      - key_position (str) – The property key for the view position.

      - key_direction (str) – The property key for the view direction.

      - key_upward (str) – The property key for the unit vector which defines the upward orientation of the view.

    Return type:

      Self

  zoom_into(keys)

    Zoom into geometries in the view.

    Parameters:

      keys (Sequence[str]) – The keys for geometries to be zoomed into.

    Return type:

      Self

tabletree.generate_tabletree(items, columns, views, model_info)

  Generate a tabletree from top-level items.

  Parameters:

    - items (Sequence[Feature | Table]) – The items of the root table.

    - columns (Sequence[Column]) – The columns of the root table.

    - views (Sequence[View]) – The views of the root table.

    - model_info (ModelInfo) – The model information.

  Return type:

    TableTree

tabletree.write_tabletree(tabletree, tabletree_out_directory, blobs_out_directory)

  Write a tabletree into a file.

  Parameters:

    - tabletree (TableTree) – The tabletree to be written.

    - tabletree_out_directory (str) – The output directory for tabletree file.

    - blobs_out_directory (str) – The output directory for resources.

  Return type:

    bool

### Types

tabletree.ColumnFlag

  alias of `Literal`[‘is_resizable’, ‘is_hidden’, ‘is_statistical’, ‘is_editable’, ‘is_display_large’]

tabletree.ColumnFilterType

  alias of `Literal`[‘none’, ‘range’, ‘select’, ‘existence’, ‘free’]

tabletree.ColumnSummaryType

  alias of `Literal`[‘count’, ‘sum’, ‘custom’]

tabletree.ColumnType

  alias of `Literal`[‘boolean’, ‘dictionary’, ‘image’, ‘integer’, ‘link’, ‘real’, ‘string’, ‘summary’, ‘unitful’]

tabletree.ColumnUnitfulType

  alias of `Literal`[‘length’, ‘area’, ‘volume’, ‘lengthDensity’, ‘areaDensity’, ‘volumeDensity’]

tabletree.ColumnImageType

  alias of `Literal`[‘uri’, ‘bmp’, ‘png’, ‘jpeg’]

tabletree.PointCloud Sequence[geode.PointOnFace | geode.PointOnEdge] | Sequence[tabletree.view_util.Point]

  Represent a PEP 604 union type

  E.g. for int | str

tabletree.GeomElement frtobjs.Body | frtobjs.Face | frtobjs.Edge | geode.FacetedEdge | tabletree.view_util.Polyline | geode.FacetedFace | tabletree.view_util.Polygon | geode.PointOnEdge | geode.PointOnFace | tabletree.view_util.Point | PointCloud | tabletree.view_util.Text | tabletree.view_util.Arrow | tabletree.view_util.Circle

  Represent a PEP 604 union type

  E.g. for int | str

tabletree.ViewEventType

  alias of `Literal`[‘on_single_clicked’, ‘on_double_clicked’]

### view_util

class tabletree.view_util.Arrow(head, tail)

  Create an arrow.

  Parameters:

    - head (Sequence[float]) – Where the arrow ends.

    - tail (Sequence[float]) – Where the arrow starts.

  set_options(double_headed=False, reverse_headed=False, head_length=-1.0)

    Set options for the arrow.

    Parameters:

      - double_headed (bool) – If true, arrowheads are drawn at both ends of the arrow.

      - reverse_headed (bool) – If true, the arrow becomes inward-headed.

      - head_length (float) – The length of the arrowhead(s).

    Return type:

      Self

class tabletree.view_util.Circle(center, r, normal)

  Create a circle.

  Parameters:

    - center (Sequence[float]) – The center of the circle.

    - r (float) – The radius of the circle.

    - normal (Sequence[float]) – The normal vector to the plane the circle is on.

class tabletree.view_util.Highlight(key: str, color: Literal['info', 'warn', 'error'], /)
class tabletree.view_util.Highlight(key: str, color: HighlightColor, /, *, priority: int | None = None)

  Create a Highlight object.

  Parameters:

    - key (str) – The key for the geometries to be highlighted.

    - color (Literal['info', 'warn', 'error'] | ~tabletree.src.api.view_util.highlight.HighlightColor) – The highlight colors of the geometries.

    - priority (int | None) –

      The priority. A Highlight with higher priority overrides others. If the same value is set, highlight colors are overridden in the order geometries are highlighted. The value must be less than 1,000,000. The preset priorities are

          "info": 10,000,
          "warn": 20,000,
          "error": 30,000.

class tabletree.view_util.HighlightColor

  Create a color for highlighting.

  HighlightColorPreset

    alias of `Literal`[‘info’, ‘warn’, ‘error’]

  property b: int

    The blue value.

  property config_accessor

    Obtain a config accessor, or rgb if color index is not set.

  fallback_color: list[int] = [255, 255, 255]
  property g: int

    The green value.

  index: int
  static preset_to_config_accessor(color)

    Obtain a config accessor of a preset color.

    Parameters:

      color (Literal['info', 'warn', 'error']) – The preset color.

    Return type:

      ConfigAccessor

  property r: int

    The red value.

  property rgb: list[int]

    Obtain the rgb values.

  set_color_index(index)

    Set a color with a config index.

    Parameters:

      index (int) – The color index in the config.

    Return type:

      Self

  set_color_rgb(r, g, b)

    Set a color with rgb values.

    Parameters:

      - r (int) – 0 ≦ r ≦ 255

      - g (int) – 0 ≦ g ≦ 255

      - b (int) – 0 ≦ b ≦ 255

    Return type:

      Self

class tabletree.view_util.Point(position)

  Create a point.

  Parameters:

    position (Sequence[float]) – The position of the point.

  property pos: list[float]

    Obtain the position.

  set_text(text)

    Set a text to the point.

    Parameters:

      text (str) – The text to be displayed on the point.

    Return type:

      Self

class tabletree.view_util.Polygon(vertices, facets)

  Create a Polygon.

  Parameters:

    - vertices (list[Sequence[float]]) – The list of vertices.

    - facets (list[tuple[int, int, int]]) – The list of triangles. A triangle consists of three indices of vertices.

class tabletree.view_util.Polyline(vertices)

  Create a Polyline.

  Parameters:

    vertices (list[Sequence[float]]) – The list of vertices.

class tabletree.view_util.Text(content, position)

  Create a text.

  Parameters:

    - content (str) – The text content.

    - position (Sequence[float]) – The position of the text.

  set_options(width=10.0, height=15.0)

    Set options for the text.

    Parameters:

      - width (float) – The width of the letters.

      - height (float) – The height of the letters.

    Return type:

      Self