Isotropix Forums

Return Layer3d path on creation ?

Clarisse Scripting related topics

Return Layer3d path on creation ?

Unread postby Rapheus » Wed Apr 14, 2021 1:06 am

Hello there,

Pretty new to Clarisse 4 but enjoying it a lot so far,
I'm currently writing a script where I want to create a Layer3d under an Image, and set it's attributes.

Code: Select all
imagePath = "project://image"
layer3d = ix.cmds.AddValues([ imagePath + ".layers" ], ["Layer3d"])
print layer3d


Unfortunately, this command creates the layer but doesn't return anything,
How could I get the path or name of the newly created Layer3d ?

Thanks a lot,
R.
Rapheus
 
Posts: 4
Joined: Tue Sep 30, 2014 2:57 am

Re: Return Layer3d path on creation ?

Unread postby anemoff » Wed Apr 14, 2021 12:44 pm

Hi,

You can do as follows, using ModuleImage directly instead of using the commands:

python code

#get the ModuleImage
image = ix.get_item('project://scene/image').get_module()
# returns a ModuleLayer on success, None on failure
layer = image.add_layer('Layer3d', 'my_layer')
if layer:
layer_obj = layer.get_object()
print('New layer created: {}'.format(layer_obj))
# set layer attributes
# layer_obj.get_attribute('...')
else:
print('Error: failed to create layer')


Cheers,
Anthony Nemoff
Isotropix
R&D Engineer
User avatar
anemoff
 
Posts: 391
Joined: Wed Jan 13, 2016 10:10 am

Re: Return Layer3d path on creation ?

Unread postby Rapheus » Thu Apr 15, 2021 12:25 am

Working !

Thanks again
R.
Rapheus
 
Posts: 4
Joined: Tue Sep 30, 2014 2:57 am


Return to Scripting