I'm quite new in scripting and in scripting in clarisse too.
I started to work on a tool and it will be great to have your help on it!
The idea is to bake a pointcloud (from multiple scatterer in a context) with custom properties (name and matrices store in the properties).
I manage (by checking at your scripts post in the forum) to create the point cloud, init the properties, get the name and the matrices of each points but I'm stuck when it come to set the property (name and matrices).
python code
#selection/list context
contScan = ix.selection[0]
context = ix.get_item(str(contScan)) # Get your contexdt item from the path
items = ix.api.OfObjectArray() # This object will contain the items in the context
context.get_objects(items) # Fill the items variable
#create PTC and Context with right name
nameSplit = str(contScan).split("/")
nameCont = nameSplit[-1]
ctx = ix.cmds.CreateContext(str(nameCont)+"_bake", "project:/")
ptc = ix.cmds.CreateObject(str(nameCont)+"_ptc", "GeometryParticleContainer", str(ctx))
#position INIT
pos = ix.api.GMathVec3f()
t = ix.api.GMathVec3d()
positions = ix.api.GMathVec3fVector()
#properties to inject in ptc
xform = ix.api.ResourceProperty("xform")
name = ix.api.ResourceProperty("assetName")
#count ptc
nbInstance = 0
for i in range(items.get_count()):
cc = items[i]
if cc.is_kindof('SceneObjectScatterer'): #check if scatterer
scat = cc.get_module()
instance_count = scat.get_instances().get_count()
nbInstance = nbInstance + instance_count
for i in range(instance_count):
nameAs = str(scat.get_base_objects()[scat.get_instances()[i]].get_object().get_full_name()).split("/")
assetName = nameAs[-1]
#name.set_string(i , assetName) PART WHERE I WANT TOO FEED THE NAME IN THE POINT CLOUD
mat = scat.get_instance_matrix(i)
#for j in range(16): PART WHERE I WANT TOO FEED THE MATRIX IN THE POINT CLOUD
#xform.set_float(i, mat[j], j)
#get position for each point
ix.api.GMathMatrix4x4d.extract_translation(mat, t)
for j in range(3):
pos[j] = t[j]
positions.add(pos)
# init the properties
xform.init(ix.api.ResourceProperty.TYPE_FLOAT_32, 16, nbInstance)
name.init(ix.api.ResourceProperty.TYPE_CHAR, 1, nbInstance)
ix.api.IOHelpers.set_particles(ptc, positions)
properties = ix.api.ResourcePropertyArray(2)
properties[0] = xform
properties[1] = name
ix.api.IOHelpers.set_particles_properties(ptc, properties)