assetApproxSize function

Syntax

  • string assetApproxSize(searchQuery, axisSelector, n )

Parameters

  1. searchQuerystring
    Search query to apply on list of all files in the workspace. See fileSearch for details about the syntax.
  2. axisSelectorstring
    { x | y | z | xy | yz | xyz }—selector of axes for the current scope.
  3. nfloat
    Number (integer >= 1) of assets to consider (one is randomly picked out of the n best assets).

Returns

Asset with one of the best n size fits (according to axisSelector).

Description

The assetApproxSize function returns one of the n best size fitting assets, from the file list specified in string, according to the specified axisSelector.

Note:

assetApproxSize(string, axisSelector, 1) = assetBestSize(string, axisSelector)

Related

Examples

Inserting assets based on their (physical) size

CGA examples with n = 1, n = 2 and n = 3:

The goal is to insert assets from a pool, depending on their (physical) size. The pool of assets is seen in the following image. Colors are (only) used to visually emphasize the size ratio.

Asset ratio pool
Note:
  • The geometry varies in the next three images by using only the n parameter.
  • Small parts get blue assets while large parts get red assets.

n = 1:
Lot -->
	s('.9,'.9,'.9) center(xz) recursiveSplit(0)
recursiveSplit(n) -->
	case scope.sx >= 1.5 && scope.sz >= 1.5:
		split(x){~scope.sx/3: split(z){~scope.sz/3: recursiveSplit(n+1)}*}*
	else: innerRectangle(scope) { shape : doInsert }
doInsert -->
	alignScopeToAxes(y)
	i(assetApproxSize("/myProject/assets/cube_*.obj","xz",1))
Asset size with n = 1
n = 2:

..
	i(assetApproxSize("/myProject/assets/cube_*.obj","xz",2))
Asset size with n= 2
n = 3:

..
	i(assetApproxSize("/myProject/assets/cube_*.obj","xz",3))
Asset size with n =3

In this topic