[QUOTE=Claudio A;30652]
I’ve not yet tried pymxs in a production environment, but my real concern is trading values between pymxs and MaxPlus; I’m hoping they match but my fear is that other than base types they don’t.[/QUOTE]
They are definitely NOT the same types. You may be able to get them to be but I’ve found no info on how to accomplish that.
In the mean time, I’ve had to resort to pymxs to add custom attributes and parsing the attribute def and injecting new data to update it.
# Python Add Custom Attribute Def
import MaxPlus
import pymxs
rt = pymxs.runtime
node = MaxPlus.SelectionManager.GetNodes()[0]
# Find Modifier Programmatically
mod = None
for i in xrange(node.NumModifiers):
currMod = node.GetModifier(i)
if currMod.GetName() == 'myAttrHolder':
mod = currMod
break
attrDef = """
custAttrDef=attributes testAttrib
(
parameters main rollout:{0}Rollout
(
-- Param Def Begin
-- Param Def End
)
rollout {0}Rollout "{0}"
(
-- Rollout Def Begin
-- Rollout Def End
)
)
"""
rt.execute('myMod=$.modifiers[#myAttrHolder]')
count = rt.CustAttributes.count(rt.myMod)
rt.execute(attrDef)
rt.CustAttributes.add(rt.myMod, rt.custAttrDef)
rt.CustAttributes.makeUnique(rt.myMod, count + 1)
Here is also a snippet for redefining the Custom Attr Def after the fact. I’ve left some bread crumbs to easily parse / insert new data
# Python Get / Set Custom Attr Def
import MaxPlus
import pymxs
rt = pymxs.runtime
rt.execute('targetObj=$')
count = rt.CustAttributes.count(rt.targetObj)
res = MaxPlus.FPValue()
dataDef = rt.CustAttributes.getDef(rt.targetObj.DisplayInfo_ArmSettings)
defSource = dataDef.source
defLines = defSource.splitlines()
for each in defLines:
print each
endParamIndex = defLines.index(' -- Param Def End')
defLines.insert(endParamIndex, ' param1 type: #float ui:param1 default:10')
endRolloutIndex = defLines.index(' -- Rollout Def End')
defLines.insert(endRolloutIndex, ' \st spinner param1 \"floatparam\" type: #float')
newDef = '
'.join(defLines)
rt.CustAttributes.redefine(dataDef, newDef)