Forums Technical subjects Patchwork 3D – R&D and Roadmap Patchwork 3D 2022 release 2 – Scripting API improvements

Author Posts


1 – Position layers

Patchwork 3D 2022 release 2 is going to bring new fonctions to improve P3D Data API covering.

First, position layers API has been added.

It is now possible to manage position layers and get/set surface’s position, orientation and scale on any layer.

Example : this script create a new position layer and move, rotate and scale any surface in the first model

  • This topic was modified 1 year, 10 months ago by Romaric.


2 – kinematics & animations

In Patchwork 3D release 2, the kinematics and timeline API have been added too.

With the kinematics API, it is possible to add Nulls, Vectors and Axis in the kinematics tree and associate surfaces to these kinematics elements.

Using the timeline API, it is possible to manage timelines, create and edit animations.

Example : this script combines cameras API, kinematics API and Timeline API to show how to create some kinds of animation : Camera bookmark animation, simple channel animation, advanced channel animation with curve control.


def create_bookmark_camera_anim(db: Database) -> CameraBookmarkAnimation :
    anim = db.create_camera_bookmark_animation('bk_anim')
    group: CameraGroup = db.create_camera_group('CameraGroup For Animation')
    camera_1 = db.create_camera(group) = 'BKCamera1'
    camera_1.view_to = Vector3(0.0, 0.0, 0.0)
    camera_1.view_from = Vector3(1.0, 1.0, 1.0)
    camera_2 = db.create_camera(group) = 'BKCamera2'
    camera_2.view_from = Vector3(2.0, 1.0, 1.0)
    return anim

def create_simple_channel_animation(db: Database) -> ChannelsSimpleAnimation:
    anim = db.create_channels_simple_animation('anim_axis')
    axis = db.list_models()[0].create_axis('animated_axis')
    surf = create_surface(db.list_models()[0], 'AxisAnimatedSurface')
    anim.set_axis_channel_animation(object=axis, start=25, end=35)
    return anim

def create_curve_channel_animation(db: Database, null_obj: Null) -> ChannelsCurveAnimation:
    anim = db.create_channels_curve_animation('anim_vector_null')
    vector = db.list_models()[0].create_vector('animated_vector')

    surf = create_surface(db.list_models()[0], 'NullAnimatedSurface')
    anim.add_null_channel_animation(object=null_obj, channel='Translation/X')
    anim.add_null_channel_animation(object=null_obj, channel='Translation/Y')
    anim.add_null_channel_animation(object=null_obj, channel='Orientation/Z')
    return anim




Here is an example of how to create animations using Python API

You just need to create manually a box and a plane, then execute the script
And here is an overview of the result


What is automated is this script ?

This Script :

  • Creates a Matter product and assign a default material to each surface
  • Builds kinematics hierarchy, and put the box into it
  • Creates a timeline
  • Adds an advanced channel animation clip to animate the box position on the floor
  • Adds a simple channel animation clip to rotate the box
  • Adds a Bézier curve camera animation clip to turn the camera around the box
  • Adds a Bookmark animator animation clip to zoom the camera on the box


Just download the script and execute it in Patchwork 3D 2022 release 2, then you can edit it to adapt it to your needs

  • This reply was modified 1 year, 8 months ago by webmaster.
  • This reply was modified 1 year ago by webmaster.
  • This reply was modified 1 year ago by webmaster.

  • You must be logged in to reply to this topic.