[Closed] redefine CAs and Handlers inside Attribute Holder ??
i did some Custom Attributes inside PEN_Attribute_Holder 2 …
i rigged my character and made lots of connections with wire…at the end i realized that i forgot to write a event handler to one button…
as far as i know,
the only way out is removing the modifier, correct the handler and remake all the connections again and again, and again......
i want to know if is there any way to fix without break and loose things ?
search:
redefine def
http://forums.cgsociety.org/showthread.php?f=98&t=516768&highlight=redefine+custom+attribute
redefine spinner limit
[ http://forums.cgsociety.org/showthread.php?f=98&t=702557&highlight=redefine+custom+attribute ]( http://forums.cgsociety.org/showthread.php?f=98&t=702557&highlight=redefine+custom+attribute)
…i´m still lost…Help
can’t say I can think of a way… presumably if you had made it a global CA (with the classID bits), then updating it would have been as easy as adding the event, executing the code, and calling it a day. If it’s not global, then… nope, can’t say I can think of a way (other than redefining, re-applying, re-creating the wirings etc.)
actually… what am I talking about… >_< …sorry about that, I knew this at some point but 1. clearly forgot it again* and 2. didn’t encounter it in the help file.
/me mutters something about the many ‘Custom Attributes’ topics with seemingly disjointed sections
Anyway – Have you tried the methods outlined in the “Redefining Custom Attributes” section of the “Global and Private Custom Attributes Definitions” help topic?
( that same topic addresses the ‘global ‘bit )
( as always – green = comments, blue = listener output, black(err, white) = entry )
-- let's define a simple custom attribute set
myAttribs = attributes test (
rollout test "test" (
button btn_test "test"
)
parameters main rollout:test (
testval type:#float
)
)
<AttributeDef:test>
-- let's create some spheres
sphere1 = sphere()
$Sphere:Sphere01 @ [0.000000,0.000000,0.000000]
sphere2 = sphere()
$Sphere:Sphere02 @ [0.000000,0.000000,0.000000]
-- stick the custom attributes on sphere1
custattributes.add sphere1 myAttribs
true
-- and wire sphere2's radius to that custom attribute's 'testVal' parameter
paramwire.connect sphere1.test[#testval] sphere2.baseObject[#radius] "testval"
true
-- let's check if it works..
sphere1.testval = 123.45
123.45
sphere2.radius
123.45
-- looks good to me
-- now let's select sphere 1
select sphere1
OK
-- and click the button... *click*
-- *NOTHING*
-- whoops... forgot to set up an event handler for that button.
-- no worries, let's redefine:<def> it
-- get the def on sphere1
myDef = custAttributes.getDef sphere1 1
<AttributeDef:test>
-- create a new custom attribute block, and tell it that it's
-- essentially just redefining the attributes already on sphere1
-- (there's fancy parameter remapping bits that we don't need but
-- are good to know exist)
attributes test redefine:myDef (
rollout test "test" (
button btn_test "test"
on btn_test pressed do ( messageBox "Why hello there, Mr. Button Pressed Event" )
)
parameters main rollout:test (
testval type:#float
)
)
<AttributeDef:test>
-- I... guess that means it did its magic.
-- now let's click the button again *click*
-- *MESSAGEBOX*
-- hooray!
-- let's make sure that wire is still alive, too.. *crosses fingers*
sphere1.test.testval = 98.765
98.765
sphere2.radius
98.765
-- eeeeeeexcellent!
- The likely reason I forgot is that I use global custom attribute definitions that use the attribID(). Re-defining the custom attribute with that same attribID will automagically update it (replace it) on any objects, materials… anything… that uses that custom attribute set… so not much use for the replace: bits and pieces.
just a thought,
maybe if i get some help to write a script that pass through all defs in the selected object, grab all the properties of their wire connections (subanim, expression, controller, parent object, slave object) and format all guess will help...
*** EDIT
[b][i][color=Yellow]MAXSCRIPT SOURCE[/i][/b][/color] - Float_Wire interfaces:
[i]
Properties[/i]
[b].numWires [/b]: integer : Read
This property returns the number of wires out of this controller (i.e. the number of dependent params).
[b].isMaster[/b] : boolean : Read
This property will return True if the wire is a master predicate, otherwise it will return False.
[b].isSlave[/b] : boolean : Read
This property will return True if the wire is a slave predicate, otherwise it will return False.
[b]
.slaveAnimation[/b] : control : Read|Write
This property returns a pointer to the slave animation controller and allows you to set the slave animation controller.
[i]Methods[/i]
<maxObject>[b]getWireParent[/b] index
This method returns a pointer to the i-th dependent parameter parent.
<index>index: The index you wish to retrieve.
index>[b]getWireSubnum[/b] <index>index
This method returns the i-th dependent parameter subanim num in the animatable.
<index>index: The index of the subanim.
<control>[b]getCoController [/b][b]index[/b]
This method returns a pointer to the i-th CoController.
<index>index: The index of the controller.
<string>[b]getExprText [/b][b]index[/b]
This method returns the expression string of the i-th wire parameter.
<index>index: The index of the parameter.
bumping this as I’m not sure if you saw my last reply – looks like you don’t have to go through the trouble of enumerating parameters and their wirings at all if you use the redefine: thing.
hummm…i see…
since my problem still “alive”, guess i will have to do all the connections again and again, and again…
so, now i need help to implement my script to redo it faster …,…
my idea is :
-
get defs, expose all the values and their wires (master object, slave object, expression, controller, subanim)
-
format all to copy the lines, save as Help_Script_EXPOSED_WIRE.ms file
-
delete modifier, add new one
-
corret the event handler and evalute the def script
-
run Help_Script_EXPOSED_WIRE.ms (make all connections)
-
done (i´m happy)
maybe I’m mis-reading what you write, but… if you use the redefine: method, your existing parameter wirings -should- stay intact (see also the example in mypost) . Have you tried? If so – and presuming it failed, what exactly went wrong?
i tried your example script and it´s working fine.....
but i really need to expose all the values of wire connections…sorry if i not be clearly enough… here i go :
my "dumyness" was forgot to put a handler in two buttons (see atached img at 4th post) and just realized that after rig my entire character .....
so now i will delete modifier, correct the handler and evalute my defs again to make them work,
but i don´t want to redo all the wires manualy again and i wish i could print/format the defs connections and list all properties like: slave obj, master obj, subanim, expression, controller, etcs
theObj = selection[1]
-- select control obj
thePEN = theObj.modifiers[#PEN_Attribute_Holder_2]
-- the modifier
CAdef = thePEN.Arm_L
-- the def
Def_Arr = #(def_1 = CAdef[1], def_2 = CAdef[2], def_3 = CAdef[3] ,def_4 = CAdef[4] ,def_5 = CAdef[5] ,def_6 = CAdef[6], def_7 = CAdef[7])
-- array with all defs
NumDefArr = Def_Arr.count
-- array.count
format " %; Main def= %; All defs= %; N°= %
" thePEN CAdef Def_Arr NumDefArr
-- format all
---------------------------------------------- QUESTION
theWire = def_3.controller -- get controller of Def_Arr[3]
if classOf theWire == Float_Wire do -- verify the float wire
(
for i in 1 to (theWire.numWires) do
(
the_Parent = theWire.getWireParent i
Parent_Owner = (refs.dependents the_Parent)[1]
ParamWire_SubAnim = getSubAnimName the_Parent (theWire.getWireSubnum i)
format "wire %; %; %; %
" i ParamWire_SubAnim the_Parent Parent_Owner
-- Is_Master = .isMaster
-- Is_Slave = .isSlave
-- The_Exp = .getExprText
--
-- format "master Obj= %; Slave Obj= %; the_Exp= %; %
" Is_Master Is_Slave the_Exp
--------------------------------------------- QUESTIONS
)
)
it returns :
[i][color=DeepSkyBlue]PEN_Attribute_Holder 2:PEN_Attribute_Holder 2; Main def= Arm_L:Arm_L; All defs= #(SubAnim:ik_match, SubAnim:fk_match, SubAnim:ikFk_blend, SubAnim:Fk_offset, SubAnim:Strech, SubAnim:Strech_mult, SubAnim:Space_Switch); N°= 7
OK
Controller:Bezier_Float
undefined
OK
[/i][/color]
…i don´t know what to do…
I’m not following? Why do you need to delete the modifier and then re add it again? What ZBoxx has mentioned will just update the existing definition, you could completely replace it with another if you wanted but just updating it with new additions will save all the connections that have been made to it.
i will store some weak nodes, but i forgot to write a handler to my match buttons … so their empty…
…