Here’s a little Python snippet that shows how to write to the DataArray of an ICE attribute.
from siutils import si si = si() # win32com.client.Dispatch('XSI.Application') from siutils import log # LogMessage from siutils import disp # win32com.client.Dispatch from siutils import C # win32com.client.constants pc = si.GetPrim("PointCloud", "", "", "") a = pc.ActivePrimitive.AddICEAttribute("MyScalarArray", C.siICENodeDataFloat, C.siICENodeStructureArray, C.siICENodeContextSingleton ) a.DataArray = [[ 0.03, 3.33, 2.22, 3.333 ]] a = pc.ActivePrimitive.AddICEAttribute("MyLong", C.siICENodeDataLong, C.siICENodeStructureSingle, C.siICENodeContextSingleton ) a.DataArray = [3.1416*1000] a = pc.ActivePrimitive.AddICEAttribute("MyScalar", C.siICENodeDataFloat, C.siICENodeStructureSingle, C.siICENodeContextSingleton ) a.DataArray = [3.1416] # # Add some Attribute Display properties # to show the attribute values # p = pc.AddProperty( "AttributeDisplay", False, "" ) p.Parameters( "attrname" ).Value = "MyScalar" p = pc.AddProperty( "AttributeDisplay", False, "" ) p.Parameters( "attrname" ).Value = "MyLong" p.Parameters( "offsety" ).Value = 16 p = pc.AddProperty( "AttributeDisplay", False, "" ) p.Parameters( "attrname" ).Value = "MyScalarArray" p.Parameters( "offsety" ).Value = 32
I tried to do the same thing in JScript, but I couldn’t get it to work for arrays. Very frustrating.
pc = GetPrim("PointCloud", "", "", ""); a = pc.ActivePrimitive.AddICEAttribute("MyScalarArray", siICENodeDataFloat, siICENodeStructureArray, siICENodeContextSingleton ) a.DataArray = [[ 0.03, 3.33, 2.22, 3.333 ]] // WARNING : 3390 - This ICEAttribute doesn't refer to a 2D array: <Attribute: MyScalarArray> // a.DataArray = [ 0.03, 3.33, 2.22, 3.333 ] // WARNING : 3392 - Invalid offset specified while extracting data from this attribute: <Attribute: MyScalarArray> // <Offset: 108384008> // // But this does works a = pc.ActivePrimitive.AddICEAttribute("MyLong", siICENodeDataLong, siICENodeStructureSingle, siICENodeContextSingleton ) a.DataArray = [3000]
PS You can find some usage of DataArray in the CrowdFX plugin (in the Softimage install dir).
You might want to take a look at your listing: The “"” as stand-in for each and every quotation mark doesn’t help its readability. 😉
aargh. thx, I don’t know how those entities got in there. Somekind of user error no doubt.
thanks, i needed this and was to lazy to figure out myself yet.
I will do a attempt to get the jscript to work.
Anyway for your python script, why does the myScalarArray show up so strange:
ignore post above! I made a stupid mistake!
I tried half a hour to get the jscript to work.
I had problems with arrays before since jscript is a bit different from javascript.
Anyway, do you think this is a bug in softimage?
related to this topic http://www.si-community.com/community/viewtopic.php?f=13&t=2983&start=0
i’m so interested in this.
i never used python but i heard it’s great for reading csv files. Also i got sick of the small differences between jscript and javascript. Whenever you google it assumes jscript is javascript.
I did some searches for creating a array in python but i can’t find anthing related to something that looks like:
a.DataArray = [[ 122, 123, 124, 125]]
why the [[ instead of a single [ ?
And if somone could help me with creating the nodes or a ppg mentioned in the topic above then that would be really great.
Python doesn’t have arrays. It has lists, that’s what the square brackets are. So basically [1,2,3] is a list of three elements and [[1,2,3]] is a list of lists.
there is DataArray and DataArray2D, in the example above you use DataArray instead of DataArray2D.
But if you create a list of lists, isn’t that supposed to be a 2d array?
DataArray2D would be for per-point attributes (or per-sample or per-polygon or …)
There is no reply button under:
“DataArray2D would be for per-point attributes (or per-sample or per-polygon or …)”
So this might end a bit to high.
Anyway.
DataArray2D can also be per-object so i still don’t get it.