Skip to content

Scripting API

Hinge

from ArtisanPlugin.Scripting import HingeApi

A hinge is what lets a bangle, a locket or a hinged shank open: interleaved knuckles cut from the metal itself, threaded on a pin. The tool takes a solid you have already modelled, cuts it at the point you mark, builds the male and female knuckles and the pin, and hands back the resulting parts - the same operation the ArtisanHinge panel performs when you pick a point on a solid and press Accept.

Create

ids = HingeApi.Create(brepId, point, diameter = 0.7, cutDiameter = 4, thickness = 1,
                      numberOfMales = 1, openingAngle = -1)              # -> [ids]
ParameterDefaultMeaning
brepIdrequiredThe solid to hinge - must be a brep, or geometry convertible to one
pointrequiredWhere the hinge goes on the solid (a Point3d)
diameter0 -> tool default 0.7Pin diameter, mm
cutDiameter0 -> tool default 4Diameter of the knuckle cut, mm
thickness0 -> tool default 1Knuckle wall thickness, mm
numberOfMales0 -> tool default 1Number of male knuckles
openingAngle-1 -> tool default 10How far the hinge opens, degrees

Unlike Link and Named pendant, Hinge takes no plane: it works on an existing object. brepId must resolve to a brep - or to geometry with a brep form, which is converted - otherwise ArgumentException is thrown with the message “Object … is not a solid/brep.”

The numeric parameters follow the house 0-keeps-default convention, with openingAngle as the exception: 0 is a valid opening angle (a hinge that stays shut), so it uses -1 as its keep-default sentinel and only values of 0 or greater are applied. Defaults start from the Hinge model the command uses and are overwritten by the user’s saved hinge defaults when they have any.

point marks where the hinge sits on the solid, exactly as the tool’s pick-point-on-solid does. It is not required to lie exactly on a face: the API projects it to the closest point on the brep with a very generous tolerance and takes the surface normal there to build the cutting plane. A point far off the solid will still project somewhere, but the resulting plane is unlikely to be usable and the computation typically fails with “Hinge computation failed. Check that the point lies on the solid.”

The order matters and is worth stating plainly. The geometry is computed first; only if it succeeds is the source object deleted and the new parts added. So a thrown InvalidOperationException means your original solid is still there, unchanged.

Create returns the list of Guids of the resulting parts. There is no handle and no query methods. Note that the parts are added with the source object’s attributes, so they inherit its layer and material rather than being moved onto the metal layer - Hinge modifies an existing piece rather than adding a fresh accessory to it. Being a licensed and destructive mutation, this is the facade most worth wrapping in a Transaction, so that the delete and the additions undo together in one step.