Every time I try to use extensions I end up wanting to pull my hair out.
I have a text DAT named ‘printingClass’ in a base COMP with this very simple script in it:
class Printing():
def __init__(self):
print('created')
def printTest(self):
print('test')
in the extensions1 object of the base COMP i have op(‘./printingClass’).module.Printing()
name set to Printing, and promote extensions toggle on
No errors, and the init function prints ‘created’ in the text port. But if I run: op(‘base1’).printTest() I get an error saying that ‘Printing’ has no attribute called ‘printTest’
I’m attaching the base COMP that I’m using to figure this out.
ExtensionsHelp.tox (422 Bytes)
don’t give up !
to make functions able to be called from outside your comp, you need to promote them.
That’s as easy as Capitalizing their function name:
class Printing():
def __init__(self):
print('created')
def PrintTest(self):
print('test')
now call your promoted function from anywhere using
op('base1').PrintTest()
But to make it much easier & faster for yourself to create a new extension, just rightclick any COMP, select Customize, open the Extension Code dropdown, fill in the new name of your extension (usually ‘ext’ and then your name, so “extPrinting” in your case) and click add. If you choose the standard version it will create all for you with an example function and promoted function included.
cheers Idzard
Imagine the most dramatic face-palm ever lol. Thank you for this! In my frustration it was probably easy to miss the capitalization detail searching the docs. But I think I’ll remember that now that I’ve been playing with custom pars.