metaexpr module

The geometry class in Houdini has an intrinsic “metaexpr_code”. This represents a serialization of the metaball expression for the geometry.

The metaball expression describes how to combine metaballs to form the surface.

In HOM, you can access this with:
geo.intrinsicValue(‘metaexpr_code’)
in SOHO, you can access this with:
geo.globalValue(‘intrinsic:metaexpr_code’)

The code in this module parses the metaball code into an expression tree structure, which is much more comprehensible.

The intrinsic is both read/write, so it’s also possible to set the metaball expression this way (using the setIntrinsicValue method in HOM), though it’s probably more efficient to set the “metaExpression” detail attribute directly.

metaexpr.build(opcodes)

Given an array of opcodes, build an expr

class metaexpr.expr(opcode)

The expr class is used to represent the metaball expression. Each node in the graph has:

  • self.Op: the operation
  • self.Kids: children (or operands)

Each child will either be a sub-expression (i.e. an instance of an expr object) or an integer representing a primitive number.

jsonString()

Serialize into a JSON string where the form for each node in the graph is [opcode,[children]] where children is a list of either primitive numbers or other child expressions.

serialize(opcodes, id)

Serialize into an array of opcodes (i.e. the opposite of the build function).

metaexpr.serialize(expr, first_id)

Given an expression and a “first_id”, generate a serialization of the expression. The first_id is usually set to the number of primitives in the geometry.

metaexpr.test()

Self-test