Skip to content

Scripting API

Smart profile

from ArtisanPlugin.Scripting import SmartProfileApi

A smart profile is the Smart Profiles tool of the Solid tab (ArtisanProfiles) without its panel. It sweeps RING_PROFILE sections along an existing curve to make bands, wires, frames and free-form rims whose section can change along the way. Each section sits at a normalized position t along the curve (0 = start, 1 = end) and has its own profile asset, width, height, rotation and sideways displacement.

The result stays linked to the curve: when you edit the curve, the profile regenerates. It differs from Profile sweep in what it sweeps through. Profile sweep lofts through closed curves that you draw in place, while a smart profile places profile assets parametrically along one rail.

Create

profiles = SmartProfileApi.Create(curveIds, count = 0, positions = None,
                                  widths = None, heights = None, rotations = None,
                                  displacements = None, profiles = None, sectionTypes = None,
                                  width = 0, height = 0, profile = None, sectionType = None,
                                  thickness = 0, comfort = 0,
                                  startCapDistance = None, endCapDistance = None,
                                  rebuildPoints = 0, orientationIds = None,
                                  element = None)                  # -> [ISmartProfile]

You get one smart profile per curve, as one ISmartProfile handle each. The sections are decided in priority order:

  1. positions: one section per t. The parallel lists widths, heights, rotations, displacements, profiles and sectionTypes are optional; a 0 or an empty entry takes the uniform value.
  2. count (2 or more): identical sections spread evenly. Closed curves skip t = 1.
  3. element: the sections of a saved SmartProfile element.
  4. Your saved default sections.
  5. Otherwise, two sections, one at each end.

A smart profile always has at least two sections.

ParameterDefaultMeaning
width / height0 -> 1Section size in mm, for sections without their own
profiledefault RING_PROFILEAsset name or "id:<n>", for sections without their own
sectionTypeCOMFORTCOMFORT, SOLID or THICKNESS
thickness0.7Wall thickness of THICKNESS sections, mm
comfort0.3Comfort-fit depth of COMFORT sections, mm
startCapDistance / endCapDistance1Dome height of the ends of open curves, literal mm (0 = flat)
rebuildPoints00 keeps the profiles as drawn. 4 or more rebuilds each profile to that many points for a smoother loft
orientationIdscurve frameSolids or meshes whose surface orients the sections, such as the ring the profile runs on
element—A saved SmartProfile element to start from. Its sections are used unless you pass positions or count, and explicit arguments override it
from ArtisanPlugin.Scripting import SmartProfileApi, Transaction

with Transaction.Begin("Tapered rim"):
    p = SmartProfileApi.Create([railId],
                               positions = [0, 0.5, 1],
                               widths    = [1.2, 2.4, 1.2],
                               heights   = [1.0, 1.6, 1.0],
                               profile   = "Knife Edge")[0]

Edit

ISmartProfile exposes the curve (CurveId) and the sections as parallel read-only lists: SectionPositions, SectionWidths, SectionHeights, SectionRotations, SectionProfiles, SectionTypes and SectionMirrorOf (-1, or the index of the section it mirrors). Sections are always sorted by t, so an index refers to the n-th section along the curve. Every change regenerates the profile in place, keeping the same id:

MethodDoes
SetSection(index, width = 0, height = 0)Resizes one section. 0 keeps the value, so you can change only the width
SetSectionPosition / SetSectionRotation / SetSectionDisplacement / SetSectionProfile / SetSectionReversedEdit one section
SetSectionType(index, type, thickness = 0, comfort = 0)COMFORT, SOLID or THICKNESS
AddSection(t, width = 0, height = 0, profile = None)Inserts a section. It must be at least 0.002 away from the others
RemoveSection(index)Removes one
MirrorSection(index)Adds a section at 1 - t, with the rotation negated, that keeps following its source
SetSections(json)Replaces every section from a JSON array: [{"t": 0, "width": 2, "height": 1, "rotation": 0, "displacement": 0, "profile": "…", "type": "COMFORT"}, …]. Only t is required, and at least 2 entries
SetAllSections(width, height) / SetWidth / SetHeight / SetProfileApply to every section
SetStartCapDistance / SetEndCapDistance / SetRebuildPointsGlobal settings
SetElement(name)Applies a saved SmartProfile element. The curve and the orientation objects stay

A mirrored section follows its source, so edit the source instead.

Queries

All(), Find(id), Count(), Selected(), ByLayer(name).

From the MCP

create_smart_profile takes the sections as an array of objects ({"t": 0.5, "width": 2.4, …}). edit_object reaches every method above by its snake_case name:

{"set_section": {"index": 1, "width": 1.6}}
{"add_section": {"t": 0.25, "width": 1.8}}
{"sections": [{"t": 0, "width": 1}, {"t": 1, "width": 2}]}

In the Python package, this page corresponds to ra.smart_profile.