Skip to content

Scripting API

Move on objects

from ArtisanPlugin.Scripting import TransformApi as transform

The same gesture as Copy on objects, without leaving anything behind: take a motif that is already modelled and sit it down on the band, reoriented to the metal at that spot. This is the ArtisanMoveOnObjects command headless, and it accepts a single destination point rather than a list.

Usage

moved = transform.MoveOnObjects(objectIds, targetIds, point)   # -> how many objects were moved
ParameterDefaultMeaning
objectIds-Objects to move; None or empty falls back to the current viewport selection
targetIds-The objects to place on - surfaces, polysurfaces or meshes. No selection fallback: at least one is required
point-The single destination, pulled onto the target surface before use

The return value is an int: the number of objects that were actually transformed. It is not a list of ids, because there are no new ids - the objects are moved in place, keeping their Guids, layers and attributes. Nothing is copied and nothing is deleted. A count lower than the number of objects you passed means some were skipped, which happens silently when an object has no geometry or its frame cannot be projected onto the target mesh.

The placement maths is identical to CopyOnObjects: the targets are meshed at render quality into one base mesh, point is pulled onto it, and each object is framed from the mesh point and face normal nearest its own bounding-box centre, then mapped to the corresponding frame around the picked point. The selection therefore keeps its internal arrangement while each object reorients to the local normal where it lands.

Ids in objectIds are validated individually - Object <id> does not exist. for a stale Guid, Nothing selected: select (or pass) at least one object. when nothing resolves, and The objects have no valid geometry to place. when the selection has no measurable bounding box. Target failures throw At least one target object is required., Target object <id> does not exist. or The target objects produced no surface to place on: pass surfaces, polysurfaces or meshes.

Unlike CopyOnObjects, where an unprojectable point is skipped and the run continues, here a point that cannot be pulled onto the base mesh throws The point cannot be pulled onto the target objects.

The call mutates the document and ends with a viewport redraw; use a Transaction to keep it in one undo step.

from ArtisanPlugin.Scripting import TransformApi as transform, Transaction
from Rhino.Geometry import Point3d

with Transaction.Begin("Seat motif on shank"):
    moved = transform.MoveOnObjects(motifIds, [shankId], Point3d(0, 8, 2))