How to get(collect) data from Attribute_Holder params in array for set another similar Attribute_Holder?
Thanks in advance)
Forum topic · General Scripting
By Vugar · 2012-06-10
How to get(collect) data from Attribute_Holder params in array for set another similar Attribute_Holder?
Thanks in advance)
Comments (10)
Comment policy
It work )))
I learned a code from barigazy and maxscript help )))
And finally we got this code )))
Thanks to barigazy for participating in the subject!
Glad that help a little.
Cheers!
Try this code
(
local propsNamesArr = #()
local propsValuesArr = #()
fn getCAPropsValue obj &propsNamesArr &propsValuesArr = if obj.modifiers.count > 0 do
(
local propsValues
local objModsArr = for m in obj.modifiers collect (classof m)
local idx = finditem objModsArr EmptyModifier
if idx != 0 do
(
local CA_Mod = obj.modifiers[idx].Custom_Attributes
propsNamesArr = getPropNames (CA_Mod)
propsValuesArr = for i in propsNamesArr collect (getproperty CA_Mod i)
)
)
fn setCAPropsValue obj namesArr valsArr = if obj.modifiers.count > 0 do
(
local objModsArr = for m in obj.modifiers collect (classof m)
local idx = finditem objModsArr EmptyModifier
if idx != 0 do
(
local CA_Mod = obj.modifiers[idx].Custom_Attributes
for n in 1 to namesArr.count where isProperty CA_Mod namesArr[n] do setproperty CA_Mod namesArr[n] valsArr[n]
)
)
getCAPropsValue $Box02 &propsNamesArr &propsValuesArr
if propsNamesArr.count != 0 do setCAPropsValue $Box01 propsNamesArr propsValuesArr
)
Thank you very much )
Have some problem :(
Have some problem.
This code does not work if i make multi rollouts Attribute Holder.
I hope for your help and thanks in advance :)
Attachments
Think I'm close to a find code :)
Think I'm close to a find code after minor changes :)
propsNamesArr = getPropNames (custAttributes.get $.modifiers[1] 1)
propsValuesArr = for i in propsNamesArr collect (getproperty $.modifiers[1] i)
The script works fine, but it's not exactly what I needed because it simply prints the structure and I need an array with the current value of the selected object Attribute_Holder interface.
Perhaps the proposed script will solve my problem but I do not understand how (((
Here's my simple method that does what I need, but I'm sure that is not good script, and dont elegant method )))
I've attached a file which I tested it
Thank you again, and sorry my english
Attachments
Hope this help
This is an example by Anubis (slightly modified by me)
and represent mapped fn which will extract all parameterblock data from a custom attribute (at object level or modifier).
extract parameterblock data from a custom attribute
mapped fn custAttribute_showPBlockDefs obj modName: =
(
format "%\n" obj.name
local getDefs = if modName != unsupplied then custAttributes.getDefs obj.modifiers[modName] else custAttributes.getDefs obj
for objDef in getDefs do
(
format "\t%\n" objDef ; format "\tname: %\n" objDef.name ; format "\tattribute id: %\n" objDef.attribID
format "\tParameter Blocks:" ; pbArray = custAttributes.getPBlockDefs objdef
for a = 1 to pbArray.count do
(
itms = pbArray[a] ; format "\n\t\tname = %\n" itms[1] ; format "\t\tid = %\n" itms[2]
format "\t\towners reference number = %\n" itms[3] ; keywordParams = itms[4] ; format "\t\tparameter block keywords:\n"
for x = 1 to keywordParams.Count/2 do (format "\t\t\t% = %\n" keywordParams[x] keywordParams[x+1] ; x = x+1) ; format "\t\tparameters:"
for y = 5 to itms.Count do
(
format "\n\t\t\t#name = %\n" itms[y][1]
for z = 1 to itms[y][2].Count by 2 do (format "\t\t\t% = %\n" itms[y][2][z] itms[y][2][z+1])
)
)
)
)
--if you want to extract params from modifier just
--uncomment "modname" and set modifier name
custAttribute_showPBlockDefs $ --modName:#Attribute_Holder
Thank you. I will study and try your script :)
removed from a repeat