Skip to main content
Version: 12.12.2

viktor.external.dynamo

DynamoFile

class viktor.external.dynamo.DynamoFile(file)

Dynamo file instantiated from an existing input .dyn file. This class allows for easy transformation of input nodes by means of the update() method.

Parameters

file (File) – Dynamo input file (.dyn).

generate()

Generate the (updated) Dynamo input file.

Return type

File

update(name, value)

Update the value of an input node with specified name.

Parameters
  • name (str) – Name of the input node.

  • value (Any) – New input value.

Return type

None

get_node_id(name)

Retrieve the unique node id by name.

Parameters

name (str) – Name of the node.

Return type

str

get_dynamo_result

viktor.external.dynamo.get_dynamo_result(file, id_)

Extract results from a Dynamo output file (.xml) by means of a node ‘id’, which can be obtained by calling get_node_id().

Example using BytesIO:

input_file = DynamoFile(file)
output_id = input_file.get_node_id("Area")  # output node called "Area"
...
output_file = dynamo_analysis.get_output_file(filename='output.xml')  # viktor.external.generic.GenericAnalysis
result = get_dynamo_result(output_file, id_=output_id)

Example using File:

input_file = DynamoFile(file)
output_id = input_file.get_node_id("Area")  # output node called "Area"
...
output_file = dynamo_analysis.get_output_file(filename='output.xml', as_file=True)  # viktor.external.generic.GenericAnalysis
with output_file.open_binary() as f:
    result = get_dynamo_result(f, id_=output_id)
Parameters
  • file (BinaryIO) – Dynamo output file (.xml).

  • id – Unique identifier of the output result node.

Return type

str

convert_geometry_to_glb

viktor.external.dynamo.convert_geometry_to_glb(file, filter=None)

Convert a Dynamo geometry file (.json) to a GLB file, which can directly be used in a GeometryResult.

Filter specific geometric objects by id, obtained by calling get_node_id():

input_file = DynamoFile(file)
sphere_id = input_file.get_node_id("Sphere")  # geometry node called "Sphere"
...
geometry_file = dynamo_analysis.get_output_file(filename='geometry.json', as_file=True)  # viktor.external.generic.GenericAnalysis
glb_file = convert_geometry_to_glb(geometry_file, filter=[sphere_id])
Parameters
  • file (File) – Dynamo geometry file (.json).

  • filter (Optional[List[str]]) – Filter geometric objects by id (default: include all).

Return type

File