Scene and nodes

How to set-up a scene using code

This is the main module of the engine. It contains both the nodes and the scene.

A node is an item or element in a model. For example a ship or a force. A Scene is a collection of nodes.

The common way of working is as follows:

  1. Create a scene

  2. Add nodes to it

Example:

s = Scene()                               # create an empty scene
s.new_poi('point 1')                      # creates a poi with name anchor
s.new_poi('point 2', position = (10,0,0)) # create a second poi at x=10
s.new_cable('line',poiA = 'point 1', poiB = 'point 2') # creates a cable between the two points
s.save_scene(r'test.dave')                # save to file

Nodes in a scene can be referenced by either name or by reference. The new_some_node_type functions return a reference to the newly created node.

s = Scene()
a = s.new_axis('axis')                     # a is now a reference to node 'axis'

p1 = s.new_poi('poi_1', parent = a )       # refer by reference
p2 = s.new_poi('poi_2', parent = 'axis' )  # refer by name

A reference to a node can also be obtained from the scene using square brackets:

s = Scene()
s.new_axis('axis')

a = s['axis']
print(a.position)

Node types

The following node types can be used:

Node-types

Icon

Type

Description

Geometry

../images/axis.png

Axis Scene.new_axis()

Axis is an local axis system. This is the main building block of the geometry.

../images/poi.png

Poi Scene.new_poi()

Point of interest is a position on an axis system. Used as connection point or reference point for other nodes.

../images/cube.png

RigidBody Scene.new_rigidbody()

This is a rigid body with a mass and cog.It creates its own axis system (it is a super-set of Axis)

Connections

../images/cable.png

DAVE.Scene.Cable Scene.new_cable()

Linear elastic cable between two or more pois

../images/beam.png

LinearBeam Scene.new_linear_beam()

Linear elastic beam between two or more pois

../images/lincon6.png

LC6d Scene.new_linear_connector_6d()

Connects two axis systems with six linear springs

../images/con2d.png

Connector2d Scene.new_connector2d()

Connects two axis systems with one rotational and one translational spring

Forces

../images/force.png

Force Scene.new_force()

This is a force/moment. If is defined in the global axis system and acts on a poi

../images/linhyd.png

HydSpring Scene.new_hydspring()

Create linear springs to model linearized hydrostatics

../images/trimesh.png

Buoyancy Scene.new_buoyancy()

Buoyancy mesh for non-linear, shape-based hydrostatics

Other

../images/visual.png

Visual Scene.new_visual()

3D visual to spice-up the looks of the scene

../images/trimesh.png

TriMeshSource Buoyancy.trimesh()

3D triangulated mesh for buoyancy calculations. Automatically created when a Bouyancy node is added.

Geometry is build using Axis systems, Rigid bodies and Pois.

Axis systems and rigid bodies have a position and an orientation. Pois only have a position

All can be positioned on a parent. If a node has a parent then this means that its position and orientation are expressed relative to that parent.

Axis and RigidBodies can have all their six individual degrees of freedom either fixed or free. If a degree of freedom is free then this means that the node is able to move/rotate in this degree of freedom.

If this is the first time you read this then please use the Gui to experiment.

Scene functions

Apart from methods to create nodes, Scene also harbours functionality to delete, import, re-order and export nodes.

Scene functions

Action

How

Description

Create a new scene

s = Scene()

Creates a new scene “s”. Optionally a file-name can be provided to load the contents of that file directly into the scene

Adding content

Adding a node

s.new_poi, s.new_axis, etc..

See list of node types and new_ functions in the next table.

Import nodes (1)

Scene.import_scene()

Imports all nodes from an other scene and places them as a group in the current scene.

Import nodes (2)

Scene.load_scene()

Imports all nodes from an other scene and adds them to the current scene. Beware of name-conflicts.

Access nodes

Get a node

s[‘node_name’]

gets a reference to a node with name “node_name”.

Get all nodes of a type

Scene.nodes_of_type()

gets a list of reference to all nodes with this type

Get all nodes that depend on

Scene.nodes_depending_on()

gets a list of reference to all nodes with this type

Get all child nodes

Scene.nodes_with_parent()

gets a list of reference to all nodes with this type

Deleting content

clear

Scene.clear()

Deletes all nodes from the scene

delete

Scene.delete()

Deletes a node from the scene. All nodes that depend on this node will be deleted as well.

dissolve

Scene.dissolve()

Removes a single node from the scene. Attempts to maintain child nodes. Often used in combination with import

Saving or exporting

Save to file

Scene.save_scene()

Saves the content of the scene to a file

Get as python code

Scene.give_python_code()

Returns python to re-create the scene in its current state.

Print node-tree

Scene.print_node_tree()

Prints a node-tree

Solving

Solve statics

Scene.solve_statics()

Brings the nodes in the scene to a static equilibrium

Goal seek

Scene.goal_seek()

Iteratively changes a property to set another property to some specified value.

Notes: rotations are defined as https://en.wikipedia.org/wiki/Axis%E2%80%93angle_representation#Rotation_vector