Profile
Package: Libraries.Fabrication.Profiles · Inherits from: Libraries.Language.Object
The Profile class is a named set of slicer settings (printer, filament and print settings together), checked against ProfileSchema. A profile only stores the settings it sets itself. Anything else comes from its parent profile ("inherits" in the JSON file), and in the end from the defaults in ProfileSchema. So a filament or quality variant can be a few lines that change only what differs: "bambu-p2s-petg": { "inherits": "bambu-p2s", "filamentType": "PETG", "nozzleTemperature": 250, "bedTemperature": 70 }
Example Code
use Libraries.Fabrication.Profiles.ProfileManager
use Libraries.Fabrication.Profiles.Profile
class Main
action Main
ProfileManager manager
manager:Load("Profiles/profiles.json")
Profile profile = manager:Require("bambu-p2s-petg")
number height = profile:GetNumber("layerHeight")
profile:SetNumber("layerHeight", 0.16) // this run only
output profile:Describe()
end
end
Actions
Clear(text key)
Removes this profile's own value, so the inherited or default one applies again.
Parameters
keytext: The setting's key, as listed in ProfileSchema.
Example
use Libraries.Fabrication.Profiles.ProfileManager
use Libraries.Fabrication.Profiles.Profile
ProfileManager profiles
profiles:Load("Profiles/profiles.json")
Profile fine = profiles:Derive("ender3-v2", "ender3-v2-test")
fine:SetNumber("layerHeight", 0.12)
fine:Clear("layerHeight")
output fine:GetSource("layerHeight") // ender3-v2 again
Describe()
A short summary for printing.
Returns
text: One line: the name, bed size, nozzle, filament, nozzle temperature and layer height.
Example
use Libraries.Fabrication.Profiles.ProfileManager
use Libraries.Fabrication.Profiles.Profile
ProfileManager profiles
profiles:Load("Profiles/profiles.json")
Profile profile = profiles:Require("ender3-v2")
output profile:Describe()
GetBambuSettingsFile()
The Bambu settings template to package the print with (a project_settings JSON, or a .gcode.3mf exported by Bambu Studio), or undefined if there is none. By default it is the file the bambuSettingsTemplate setting names, relative to the folder the program runs in; a profile that doesn't set it returns its parent's. BambuPrinter overrides this with the file given to SetBambuFiles.
Returns
Libraries.System.File: The settings template, or undefined.
Example
use Libraries.System.File
use Libraries.Fabrication.Profiles.ProfileManager
use Libraries.Fabrication.Profiles.Profile
ProfileManager profiles
profiles:Load("Profiles/profiles.json")
Profile profile = profiles:Require("bambu-p2s")
File template = profile:GetBambuSettingsFile()
GetBoolean(text key)
The value of a true / false setting (see GetText for where it comes from).
Parameters
keytext: The setting's key, as listed in ProfileSchema.
Returns
boolean: The value.
Example
use Libraries.Fabrication.Profiles.ProfileManager
use Libraries.Fabrication.Profiles.Profile
ProfileManager profiles
profiles:Load("Profiles/profiles.json")
Profile profile = profiles:Require("ender3-v2")
if profile:GetBoolean("supportsEnabled")
output "Tree supports are on."
end
GetEndGcode()
The printer's own end G-code, as text, run after the last layer. An empty text (the default) means the endGcodeFile setting is used instead. A profile with a parent returns its parent's.
Returns
text: The end G-code, or "" to use endGcodeFile.
Example
use Libraries.Fabrication.Printers.CrealityEnder3
CrealityEnder3 printer
output printer:GetEndGcode()
GetInherits()
The name of the parent profile, or "" for none.
Returns
text: The name of the parent profile, or "" for none.
Example
use Libraries.Fabrication.Profiles.ProfileManager
use Libraries.Fabrication.Profiles.Profile
ProfileManager profiles
profiles:Load("Profiles/profiles.json")
Profile profile = profiles:Require("ender3-v2-fine")
output profile:GetInherits() // ender3-v2
GetInteger(text key)
The value of a whole-number setting (see GetText for where it comes from).
Parameters
keytext: The setting's key, as listed in ProfileSchema.
Returns
integer: The value.
Example
use Libraries.Fabrication.Profiles.ProfileManager
use Libraries.Fabrication.Profiles.Profile
ProfileManager profiles
profiles:Load("Profiles/profiles.json")
Profile profile = profiles:Require("ender3-v2")
integer nozzle = profile:GetInteger("nozzleTemperature")
GetName()
The profile's name, as profiles.json lists it.
Returns
text: The name.
Example
use Libraries.Fabrication.Profiles.ProfileManager
use Libraries.Fabrication.Profiles.Profile
ProfileManager profiles
profiles:Load("Profiles/profiles.json")
Profile profile = profiles:Require("ender3-v2")
output profile:GetName() // ender3-v2
GetNumber(text key)
The value of a number setting (see GetText for where it comes from).
Parameters
keytext: The setting's key, as listed in ProfileSchema.
Returns
number: The value.
Example
use Libraries.Fabrication.Profiles.ProfileManager
use Libraries.Fabrication.Profiles.Profile
ProfileManager profiles
profiles:Load("Profiles/profiles.json")
Profile profile = profiles:Require("ender3-v2")
number layerHeight = profile:GetNumber("layerHeight")
GetOwnKeys()
The keys this profile sets itself, in the order they were set.
Returns
Libraries.Containers.Array<text>: The keys this profile sets itself, in the order they were set.
Example
use Libraries.Containers.Array
use Libraries.Fabrication.Profiles.ProfileManager
use Libraries.Fabrication.Profiles.Profile
ProfileManager profiles
profiles:Load("Profiles/profiles.json")
Profile fine = profiles:Derive("ender3-v2", "ender3-v2-test")
fine:SetNumber("layerHeight", 0.12)
Array<text> own = fine:GetOwnKeys()
output own:Get(0) // layerHeight
GetParent()
The parent profile settings are inherited from.
Returns
Libraries.Fabrication.Profiles.Profile: The parent, or undefined for none.
Example
use Libraries.Fabrication.Profiles.ProfileManager
use Libraries.Fabrication.Profiles.Profile
ProfileManager profiles
profiles:Load("Profiles/profiles.json")
Profile fine = profiles:Derive("ender3-v2", "ender3-v2-test")
Profile parent = fine:GetParent()
output parent:GetName() // ender3-v2
GetSchema()
The list of every setting with its type, default and range.
Returns
Libraries.Fabrication.Profiles.ProfileSchema: The schema.
Example
use Libraries.Fabrication.Profiles.ProfileSchema
use Libraries.Fabrication.Profiles.ProfileManager
use Libraries.Fabrication.Profiles.Profile
ProfileManager profiles
profiles:Load("Profiles/profiles.json")
Profile profile = profiles:Require("ender3-v2")
ProfileSchema schema = profile:GetSchema()
output schema:GetSize() + " settings"
GetSource(text key)
Where a value comes from: this profile's name, a parent's name, or "default".
Parameters
keytext: The setting's key, as listed in ProfileSchema.
Returns
text: Where a value comes from: this profile's name, a parent's name, or "default".
Example
use Libraries.Fabrication.Profiles.ProfileManager
use Libraries.Fabrication.Profiles.Profile
ProfileManager profiles
profiles:Load("Profiles/profiles.json")
Profile fine = profiles:Derive("ender3-v2", "ender3-v2-test")
output fine:GetSource("bedWidth") // ender3-v2
output fine:GetSource("zHop") // default, unless a profile sets it
GetStartGcode()
The printer's own start G-code, as text, run before the first layer. Placeholders such as {BED_TEMP} and {NOZZLE_TEMP} are filled in when the G-code is written. An empty text (the default) means the startGcodeFile setting is used instead. A profile with a parent returns its parent's. Printer classes override this.
Returns
text: The start G-code, or "" to use startGcodeFile.
Example
use Libraries.Fabrication.Printers.CrealityEnder3
CrealityEnder3 printer
output printer:GetStartGcode()
GetText(text key)
The value as text: own value, else the parent's, else the schema default.
Parameters
keytext: The setting's key, as listed in ProfileSchema.
Returns
text: The value as text: own value, else the parent's, else the schema default.
Example
use Libraries.Fabrication.Profiles.ProfileManager
use Libraries.Fabrication.Profiles.Profile
ProfileManager profiles
profiles:Load("Profiles/profiles.json")
Profile profile = profiles:Require("ender3-v2")
output profile:GetText("adhesionType")
Set(text key, text value)
Sets a value written as text. Stops with an alert if the key is unknown or the value doesn't fit the setting.
Parameters
keytext: The setting's key, as listed in ProfileSchema.valuetext: The value, written as profiles.json would hold it.
Example
use Libraries.Fabrication.Profiles.ProfileManager
use Libraries.Fabrication.Profiles.Profile
ProfileManager profiles
profiles:Load("Profiles/profiles.json")
Profile fine = profiles:Derive("ender3-v2", "ender3-v2-test")
fine:Set("adhesionType", "brim")
SetBoolean(text key, boolean value)
Sets a true / false setting (see Set).
Parameters
keytext: The setting's key, as listed in ProfileSchema.valueboolean: The value.
Example
use Libraries.Fabrication.Profiles.ProfileManager
use Libraries.Fabrication.Profiles.Profile
ProfileManager profiles
profiles:Load("Profiles/profiles.json")
Profile fine = profiles:Derive("ender3-v2", "ender3-v2-test")
fine:SetBoolean("supportsEnabled", true)
SetInherits(text parentName)
Names the parent profile without linking it; ProfileManager links it with SetParent when the profile is added.
Parameters
parentNametext: The parent's name, or "" for none.
Example
use Libraries.Fabrication.Profiles.Profile
use Libraries.Fabrication.Profiles.ProfileManager
ProfileManager profiles
profiles:Load("Profiles/profiles.json")
Profile petg
petg:SetName("ender3-v2-petg")
petg:SetInherits("ender3-v2")
profiles:Add(petg)
SetInteger(text key, integer value)
Sets a whole-number setting (see Set).
Parameters
keytext: The setting's key, as listed in ProfileSchema.valueinteger: The value.
Example
use Libraries.Fabrication.Profiles.ProfileManager
use Libraries.Fabrication.Profiles.Profile
ProfileManager profiles
profiles:Load("Profiles/profiles.json")
Profile fine = profiles:Derive("ender3-v2", "ender3-v2-test")
fine:SetInteger("wallCount", 4)
SetName(text value)
Renames the profile. ProfileManager:Derive names new profiles itself.
Parameters
valuetext: The new name.
Example
use Libraries.Fabrication.Profiles.Profile
Profile profile
profile:SetName("my-printer")
SetNumber(text key, number value)
Sets a number setting (see Set).
Parameters
keytext: The setting's key, as listed in ProfileSchema.valuenumber: The value.
Example
use Libraries.Fabrication.Profiles.ProfileManager
use Libraries.Fabrication.Profiles.Profile
ProfileManager profiles
profiles:Load("Profiles/profiles.json")
Profile fine = profiles:Derive("ender3-v2", "ender3-v2-test")
fine:SetNumber("layerHeight", 0.12)
SetParent(Libraries.Fabrication.Profiles.Profile value)
Links the parent profile. ProfileManager does this after loading.
Parameters
valueLibraries.Fabrication.Profiles.Profile: The parent, or undefined for none.
Example
use Libraries.Fabrication.Profiles.Profile
Profile base
base:SetName("base")
Profile child
child:SetName("child")
child:SetParent(base)
output child:GetInherits() // base
SetsOwn(text key)
True if this profile sets the key itself (not inherited or default).
Parameters
keytext: The setting's key, as listed in ProfileSchema.
Returns
boolean: True if this profile sets the key itself (not inherited or default).
Example
use Libraries.Fabrication.Profiles.ProfileManager
use Libraries.Fabrication.Profiles.Profile
ProfileManager profiles
profiles:Load("Profiles/profiles.json")
Profile fine = profiles:Derive("ender3-v2", "ender3-v2-test")
fine:SetNumber("layerHeight", 0.12)
output fine:SetsOwn("layerHeight") // true
output fine:SetsOwn("bedWidth") // false: inherited
TrySet(text key, text value)
Like Set, but returns what is wrong ("" when it worked) instead of stopping.
Parameters
keytext: The setting's key, as listed in ProfileSchema.valuetext: The value, written as profiles.json would hold it.
Returns
text: "" if the value was set, otherwise a sentence saying what is wrong.
Example
use Libraries.Fabrication.Profiles.ProfileManager
use Libraries.Fabrication.Profiles.Profile
ProfileManager profiles
profiles:Load("Profiles/profiles.json")
Profile fine = profiles:Derive("ender3-v2", "ender3-v2-test")
text problem = fine:TrySet("layerHeight", "2")
if problem not= ""
output problem // the value is above the allowed range
end
Validate()
Checks that the settings make sense together. Returns one sentence per problem; an empty array means the profile is fine.
Returns
Libraries.Containers.Array<text>: One sentence per problem; empty if the profile is fine.
Example
use Libraries.Containers.Array
use Libraries.Fabrication.Profiles.ProfileManager
use Libraries.Fabrication.Profiles.Profile
ProfileManager profiles
profiles:Load("Profiles/profiles.json")
Profile profile = profiles:Require("ender3-v2")
Array<text> problems = profile:Validate()
output problems:GetSize() + " problems"