ProfileField
Package: Libraries.Fabrication.Profiles · Inherits from: Libraries.Language.Object
The ProfileField class describes one setting a profile can hold: its JSON key, its kind, the value used when no profile in the inheritance chain sets it, and the allowed range. kind is one of "number", "integer", "boolean" or "text". For "text" settings with a fixed set of choices, choices holds them separated by "|" (for example "none|skirt|brim").
Actions
Check(text value)
Checks a value written as text against this field. Returns "" if it is fine, otherwise a sentence saying what is wrong.
Parameters
valuetext: The value, written as text.
Returns
text: "" if the value is fine, otherwise what is wrong.
Example
use Libraries.Fabrication.Profiles.ProfileSchema
use Libraries.Fabrication.Profiles.ProfileField
ProfileSchema schema
ProfileField field = schema:Find("layerHeight")
output field:Check("0.2") // nothing: fine
output field:Check("2") // above the allowed range
GetChoices()
The allowed values of a text setting with fixed choices, separated by "|".
Returns
text: The choices, or "" if any text is allowed.
Example
use Libraries.Fabrication.Profiles.ProfileSchema
use Libraries.Fabrication.Profiles.ProfileField
ProfileSchema schema
ProfileField adhesion = schema:Find("adhesionType")
output adhesion:GetChoices() // none|skirt|brim
GetDefault()
The value used when no profile sets it.
Returns
text: The default, written as text.
Example
use Libraries.Fabrication.Profiles.ProfileSchema
use Libraries.Fabrication.Profiles.ProfileField
ProfileSchema schema
ProfileField field = schema:Find("layerHeight")
output field:GetDefault() // 0.2
GetDescription()
A short description of the setting, with its unit.
Returns
text: The description.
Example
use Libraries.Fabrication.Profiles.ProfileSchema
use Libraries.Fabrication.Profiles.ProfileField
ProfileSchema schema
ProfileField field = schema:Find("layerHeight")
output field:GetDescription() // Layer height (mm)
GetKey()
The key used in profiles.json.
Returns
text: The key.
Example
use Libraries.Fabrication.Profiles.ProfileSchema
use Libraries.Fabrication.Profiles.ProfileField
ProfileSchema schema
ProfileField field = schema:Find("layerHeight")
output field:GetKey() // layerHeight
GetKind()
What kind of value the setting holds.
Returns
text: "number", "integer", "boolean" or "text".
Example
use Libraries.Fabrication.Profiles.ProfileSchema
use Libraries.Fabrication.Profiles.ProfileField
ProfileSchema schema
ProfileField field = schema:Find("layerHeight")
output field:GetKind() // number
GetMaximum()
The largest allowed value (see HasRange).
Returns
number: The maximum.
Example
use Libraries.Fabrication.Profiles.ProfileSchema
use Libraries.Fabrication.Profiles.ProfileField
ProfileSchema schema
ProfileField field = schema:Find("layerHeight")
output field:GetMaximum() // 1.0
GetMinimum()
The smallest allowed value (see HasRange).
Returns
number: The minimum.
Example
use Libraries.Fabrication.Profiles.ProfileSchema
use Libraries.Fabrication.Profiles.ProfileField
ProfileSchema schema
ProfileField field = schema:Find("layerHeight")
output field:GetMinimum() // 0.04
GetSection()
The section the setting is listed under.
Returns
text: The section, such as "machine" or "slicing".
Example
use Libraries.Fabrication.Profiles.ProfileSchema
use Libraries.Fabrication.Profiles.ProfileField
ProfileSchema schema
ProfileField field = schema:Find("layerHeight")
output field:GetSection() // slicing
HasRange()
Whether the setting has a smallest and largest allowed value.
Returns
boolean: True for number and integer settings with a range.
Example
use Libraries.Fabrication.Profiles.ProfileSchema
use Libraries.Fabrication.Profiles.ProfileField
ProfileSchema schema
ProfileField field = schema:Find("layerHeight")
if field:HasRange()
output field:GetMinimum() + " to " + field:GetMaximum()
end
SetChoices(text allowed)
Text settings with fixed choices, separated by "|" (for example "none|skirt|brim").
Parameters
allowedtext: The choices, separated by "|".
Example
use Libraries.Fabrication.Profiles.ProfileField
ProfileField field
field:Setup("adhesion", "adhesionType", "text", "none", "Skirt, brim or neither")
field:SetChoices("none|skirt|brim")
SetRange(number low, number high)
Number and integer settings: the smallest and largest allowed value.
Parameters
lownumber: The smallest allowed value.highnumber: The largest allowed value.
Example
use Libraries.Fabrication.Profiles.ProfileField
ProfileField field
field:Setup("filament", "nozzleTemperature", "integer", "210", "Nozzle temperature (C)")
field:SetRange(0, 500)
Setup(text fieldSection, text fieldKey, text fieldKind, text fieldDefault, text fieldDescription)
Fills in the field. ProfileSchema calls this when it builds the list.
Parameters
fieldSectiontext: The section the setting is listed under, such as "machine".fieldKeytext: The key used in profiles.json.fieldKindtext: "number", "integer", "boolean" or "text".fieldDefaulttext: The default value, written as text.fieldDescriptiontext: A short description, with the unit.
Example
use Libraries.Fabrication.Profiles.ProfileField
ProfileField field
field:Setup("slicing", "layerHeight", "number", "0.2", "Layer height (mm)")
field:SetRange(0.04, 1.0)