.NET API
SmartProfileApi
Smart Profiles: profile sections swept along a curve, varying along the way.
from ArtisanPlugin.Scripting import SmartProfileApi
See also the guide, Accessories › Smart profile, and the Python package, ra.smart_profile.
Methods
| Method | |
|---|---|
All | ISmartProfile handles for every object of this kind in the active document (empty when there is no document). |
ByLayer | ISmartProfile handles on the layer with the given full path (empty when the layer does not exist). |
Count | Number of objects of this kind in the active document. |
Create | Sweeps profile sections along existing curves (the ArtisanProfiles “Smart Profiles” tool, headless): one smart profile per curve, linked to it (editing the curve regenerates it). |
Find | The handle for id, or null when the id does not belong to an object of this kind. |
Selected | Smart profiles currently selected in the active doc. |
All
IReadOnlyList<ISmartProfile> SmartProfileApi.All()
ISmartProfile handles for every object of this kind in the active document (empty when there is no document).
Returns IReadOnlyList<ISmartProfile>.
ByLayer
IReadOnlyList<ISmartProfile> SmartProfileApi.ByLayer(string layerName)
ISmartProfile handles on the layer with the given full path (empty when the layer does not exist).
| Parameter | Type | Default |
|---|---|---|
layerName | string | required |
Returns IReadOnlyList<ISmartProfile>.
Count
int SmartProfileApi.Count()
Number of objects of this kind in the active document.
Returns int.
Create
IReadOnlyList<ISmartProfile> SmartProfileApi.Create(
IEnumerable<Guid> curveIds,
int count = 0,
IEnumerable<double> positions = null,
IEnumerable<double> widths = null,
IEnumerable<double> heights = null,
IEnumerable<double> rotations = null,
IEnumerable<double> displacements = null,
IEnumerable<string> profiles = null,
IEnumerable<string> sectionTypes = null,
double width = 0,
double height = 0,
string profile = null,
string sectionType = null,
double thickness = 0,
double comfort = 0,
double startCapDistance = double.NaN,
double endCapDistance = double.NaN,
int rebuildPoints = 0,
IEnumerable<Guid> orientationIds = null,
string element = null)
Sweeps profile sections along existing curves (the ArtisanProfiles “Smart Profiles” tool, headless): one smart profile per curve, linked to it (editing the curve regenerates it). Each section sits at a normalized position t in 0..1 along the curve and has its own RING_PROFILE asset, width, height, rotation and displacement. Sections, in priority order: positions (with optional parallel widths, heights, rotations, displacements, profiles, sectionTypes; 0 / empty = the uniform value) replace everything; else count (2+) identical sections spread evenly (closed curves skip t = 1); else the user’s saved default sections; else 2 sections at the ends. At least two sections. width / height (0 = 1 mm), profile (default RING_PROFILE, or “id:sectionType COMFORT (default) | SOLID | THICKNESS with thickness (0.7) and comfort (0.3) apply to every section without its own value. startCapDistance / endCapDistance dome the ends of open curves (literal mm, NaN keeps 1). rebuildPoints 0 keeps the profiles as drawn, 4+ rebuilds them. orientationIds = solids/meshes whose surface orients the sections (e.g. the ring the profile runs on). Curves with kinks give mitred pieces: fillet them first. element = name of a saved SmartProfile element (ElementsApi.List(“SmartProfile”)) to start from, in place of the saved defaults (its sections are used unless positions / count are given); explicit arguments override it. Returns one ISmartProfile handle per curve.
| Parameter | Type | Default |
|---|---|---|
curveIds | IEnumerable<Guid> | required |
count | int | 0 |
positions | IEnumerable<double> | null |
widths | IEnumerable<double> | null |
heights | IEnumerable<double> | null |
rotations | IEnumerable<double> | null |
displacements | IEnumerable<double> | null |
profiles | IEnumerable<string> | null |
sectionTypes | IEnumerable<string> | null |
width | double | 0 |
height | double | 0 |
profile | string | null |
sectionType | string | null |
thickness | double | 0 |
comfort | double | 0 |
startCapDistance | double | double.NaN |
endCapDistance | double | double.NaN |
rebuildPoints | int | 0 |
orientationIds | IEnumerable<Guid> | null |
element | string | null |
Returns IReadOnlyList<ISmartProfile>.
Find
ISmartProfile SmartProfileApi.Find(Guid id)
The handle for id, or null when the id does not belong to an object of this kind.
| Parameter | Type | Default |
|---|---|---|
id | Guid | required |
Returns ISmartProfile.
Selected
IReadOnlyList<ISmartProfile> SmartProfileApi.Selected()
Smart profiles currently selected in the active doc.
Returns IReadOnlyList<ISmartProfile>.
Handles and sections
What the methods above hand back. A handle’s setters regenerate the object; wrap changes in a Transaction so they land as one undo step.
ISmartProfile
Handle — extends IParametricObject.
Smart profile (the ArtisanProfiles tool): a document curve swept through N RING_PROFILE sections, each placed at a normalized position t along the curve (0 = start, 1 = end). Stays linked to the curve: editing the curve regenerates it. Sections are always sorted by t, so an index refers to the n-th section along the curve.
| Property | Type | ||
|---|---|---|---|
CurveId | Guid | get | The document curve the profile follows. |
EndCapDistance | double | get | Dome height of the end cap (open curves), mm. |
Id | Guid | get | (from IParametricObject) |
LayerName | string | get | (from IParametricObject) |
MotherGemId | Guid | get | (from IParametricObject) |
ObjectType | string | get | (from IParametricObject) |
Position | Point3d | get | (from IParametricObject) |
RebuildPoints | int | get | 0 = profiles used as drawn; else rebuilt to this many points. |
SectionCount | int | get | |
SectionHeights | IReadOnlyList<double> | get | mm, same order |
SectionMirrorOf | IReadOnlyList<int> | get | -1 for a normal section, else the index of the section it mirrors |
SectionPositions | IReadOnlyList<double> | get | t of each section, sorted |
SectionProfiles | IReadOnlyList<string> | get | RING_PROFILE asset name of each section, same order |
SectionRotations | IReadOnlyList<double> | get | degrees, same order |
SectionTypes | IReadOnlyList<string> | get | COMFORT | SOLID | THICKNESS, same order |
SectionWidths | IReadOnlyList<double> | get | mm, same order |
StartCapDistance | double | get | Dome height of the start cap (open curves), mm. |
| Method | |
|---|---|
void AddSection(double t, double width = 0, double height = 0, string profile = null) | Adds a section at t (0..1, at least 0.002 from the others). Width/height 0 = 1 mm; profile omitted = default RING_PROFILE. |
void Delete() | (from IParametricObject) |
void MirrorSection(int index) | Adds a section that mirrors index across the curve (t = 1 - t, rotation negated) and follows it from then on. |
void Move(Vector3d translation) | (from IParametricObject) |
void RemoveSection(int index) | |
void SetAllSections(double width, double height) | |
void SetElement(string element) | Applies a saved SmartProfile element (ElementsApi.List(“SmartProfile”)): its sections and settings replace the current ones; the curve and the orientation objects stay. Regenerates in place (same id). |
void SetEndCapDistance(double distance) | literal mm (0 = flat) |
void SetHeight(double height) | every section |
void SetProfile(string profile) | every section: RING_PROFILE asset name or “id: |
void SetRebuildPoints(int points) | 0 = off; else 4+ points |
void SetSection(int index, double width = 0, double height = 0) | Mutations regenerate the profile in place (same Guid) and call LicenseGate.RequireValid() first. Millimetres; 0 keeps the value. A mirrored section follows its source: edit the source instead. |
void SetSectionDisplacement(int index, double displacement) | sideways offset of the section, mm (literal: 0 = centered) |
void SetSectionPosition(int index, double t) | |
void SetSectionProfile(int index, string profile) | RING_PROFILE asset name or “id: |
void SetSectionReversed(int index, bool reversed) | true = profile drawn reversed |
void SetSectionRotation(int index, double degrees) | |
void SetSectionType(int index, string sectionType, double thickness = 0, double comfort = 0) | COMFORT | SOLID | THICKNESS; thickness/comfort mm, 0 keeps |
void SetSections(string sectionsJson) | Replaces every section from a JSON array, the same shape create_smart_profile takes: [{“t”: 0, “width”: 2, “height”: 1, “rotation”: 0, “displacement”: 0, “profile”: ”…”, “type”: “COMFORT”}, …] (only t is required; 2+ entries). Thickness and comfort carry over from the current first section; mirrors are dropped. |
void SetStartCapDistance(double distance) | literal mm (0 = flat) |
void SetWidth(double width) | every section |