Colouring a polygon via script SOP

My goal: Create a polygon with P() and Cd() attributes via a script (specifically for downstream use by a laser device). This seems to be the way that the laser CHOP parses colour data out of a SOP*. However, while the python api for the script sop allows one to create points, the appendPoint() method takes no arguments. What’s more, as far as I can tell, the Point class presents a way to modify attributes but not create them (they don’t by default; if I create a point then try to access its Cd value in the script, I get an attribute error).

Any guidance or workarounds? Or am I just misreading the docs?

*Aside: how it distinguishes between multiple polygons remains a mystery to me. If I dump a SOP with multiple polygons into a script DAT, I don’t see any field (column) indicating which polygon each point corresponds to; this seems to be the main thing in the way of using a script DAT instead. In theory one could create a table with the right headers and values, but I haven’t found a way to distinguish the polygons without other OPs

Hi @groundhogstate,

have a look at the OP Snippets for the Script SOP, especially the example “triangle custom attributes” to understand how to create and modify attributes. It has a line specifying the creation of the Color (Cd) attribute.
When you say you are dumping a SOP into a Script DAT, do you mean a SOP To DAT?

You might also be interested to checking out our new POP family with many features of the SOP family but with a more attribute centric approach and running exclusively on the GPU.

cheers
Markus