How to access printSetting properties?

dan689
Explorer

How to access printSetting properties?

dan689
Explorer
Explorer

Hi,

I am trying to access the layer height property in print settings.
To see what settings are available, I ran this (`futil` is part of the vanilla add-in the Fusion creates for you):

 

futil.log(f"printsettings: {list(map(lambda p: p.name, additive_setup.printSetting.getDefaultPrintSettingItem().parameters))}")
# prints a list of empty strings

 

but it prints a list of empty strings.
And when I try accessing other fields on the CAMParameter class, I get an exception:

 

futil.log(f"printsettings: {list(map(lambda p: p.isEnabled, additive_setup.printSetting.getDefaultPrintSettingItem().parameters))}")
# throws exception   .../AppData/Local/Autodesk/webdeploy/production/
# 35a60349b112668a59dd7bbcc68b2622875103f4/Api/Python/packages\adsk\cam.py", 
# line 3811, in _get_isEnabled
#    return _cam.CAMParameter__get_isEnabled(self)
#           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# RuntimeError: 1 : Catastrophic error occurred in API function call

 

If someone could point me to an example accessing print settings, I would greatly appreciate it!

Thanks!

0 Likes
Reply
Accepted solutions (1)
264 Views
1 Reply
Reply (1)

dan689
Explorer
Explorer
Accepted solution

After some further investigation, I found the solution: You need to assign the PrintSetting object to a variable before you can read it.

print_setting = additive_setup.printSetting
futil.log(f"printsettings: {list(map(lambda p: p.name, print_setting.getDefaultPrintSettingItem().parameters))}")
# printsettings: ['prm_body_options', 'prm_body_preset_name', 'prm_body_preset_description'...



0 Likes