Get data from Attribute_Holder params in array

How to get(collect) data from Attribute_Holder params in array for set another similar Attribute_Holder?

Thanks in advance)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
3D_Animator's picture

It work )))

I learned a code from barigazy and maxscript help )))
And finally we got this code )))

obj_A = $
obj_B = $
for i = 1 to 2 do -- Rollouts count
(
	CA_GMod = (custAttributes.get obj_A.modifiers[1] i) -- Attrib Rollout For Get
	propsNamesArr = getPropNames (CA_GMod) -- Get Attrib Rollout Name To Array
	propsValuesArr = for n in propsNamesArr collect (getproperty CA_GMod n) -- Get Attrib Rollout Val To Array
 
	-- Set Param Roll To Roll custAttributes A To custAttributes B 
	CA_SMod = (custAttributes.get obj_B.modifiers[1] i) -- Attrib Rollout For Set
	for n = 1 to propsNamesArr.count do
	(
		setproperty CA_SMod propsNamesArr[n] propsValuesArr[n] 
	)
)

Thanks to barigazy for participating in the subject!

barigazy's picture

Glad that help a

Glad that help a little.
Cheers!

barigazy

barigazy's picture

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
)

barigazy

3D_Animator's picture

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)

3D_Animator's picture

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 :)

AttachmentSize
for_getsetcustattribdata_test.rar 14.57 KB
3D_Animator's picture

Thank you very much )

Thank you very much )

3D_Animator's picture

The script works fine, but...

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 )))

-- Creates an array of current values of an object with Attribute_Holder modifier
CAV = #($.modifiers[#Attribute_Holder].Custom_Attributes[1].value,$.modifiers[#Attribute_Holder].Custom_Attributes[2].value)
#(63.4061, 31.703)
 
-- Apply the resulting array of data to another object with  similar Attribute_Holder modifier
for i = 1 to 2 do
(
    $.modifiers[#Attribute_Holder].Custom_Attributes[i].value = CAV[i]
)

I've attached a file which I tested it

Thank you again, and sorry my english

AttachmentSize
for_getcustattributdata_test.rar 12.82 KB
barigazy's picture

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

barigazy

3D_Animator's picture

removed from a repeat

removed from a repeat

3D_Animator's picture

Thank you.

Thank you. I will study and try your script :)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.