Utility (i3dio.utility)

This module contains various small utility functions, that don’t really belong anywhere else

utility.as_fs_relative_path(filepath)[source]

Checks if a filepath is relative to the FS data directory

Checks the addon settings for the FS installation path and compares that with the supplied filepath, to see if it originates from within that directory.

Parameters

filepath (str) – The filepath to check.

Returns

The $data-replaced filepath if applicable, or a cleaned-up absolute path.

Return type

str

utility.get_fs_data_path(as_path=False)[source]

Returns the path to the Farming Simulator data directory.

Return type

str | Path

utility.sort_blender_objects_by_name(objects)[source]
Return type

List[Union[Object, Collection]]

utility.sort_blender_objects_by_outliner_ordering(objects)[source]
Return type

List[Union[Object, Collection]]

utility.vector_compare(a, b, epsilon=1e-07)[source]

Compares two vectors elementwise, to see if they are equal

The function will run through the elements of vector a and compare them with vector b elementwise. If the function reaches a set of values not within epsilon, it will return immediately.

Parameters
  • a (Vector) – The first vector

  • b (Vector) – The second vector

  • epsilon (float) – The absolute tolerance to which the elements should be within

Return type

bool

Returns

True if the vectors are elementwise equal to the precision of epsilon

Raises

TypeError – If the vectors aren’t vectors with equal length