PDA

View Full Version : redefine CAs and Handlers inside Attribute Holder ??


Polimeno
01-23-2009, 09:08 AM
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 ?

Polimeno
01-23-2009, 09:28 PM
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




....iīm still lost....Help

ZeBoxx2
01-23-2009, 10:13 PM
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.)

Polimeno
01-23-2009, 10:25 PM
hummm....

what do you mean by global CA (classID bit) ?

ZeBoxx2
01-24-2009, 04:34 AM
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.

Polimeno
01-24-2009, 07:35 AM
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



MAXSCRIPT SOURCE - Float_Wire interfaces:

Properties

.numWires : integer : Read
This property returns the number of wires out of this controller (i.e. the number of dependent params).

.isMaster : boolean : Read
This property will return True if the wire is a master predicate, otherwise it will return False.

.isSlave : boolean : Read
This property will return True if the wire is a slave predicate, otherwise it will return False.

.slaveAnimation : control : Read|Write
This property returns a pointer to the slave animation controller and allows you to set the slave animation controller.


Methods

<maxObject>getWireParent index
This method returns a pointer to the i-th dependent parameter parent.
<index>index: The index you wish to retrieve.

index>getWireSubnum <index>index
This method returns the i-th dependent parameter subanim num in the animatable.
<index>index: The index of the subanim.

<control>getCoController index
This method returns a pointer to the i-th CoController.
<index>index: The index of the controller.

<string>getExprText index
This method returns the expression string of the i-th wire parameter.
<index>index: The index of the parameter.

ZeBoxx2
01-24-2009, 11:16 AM
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.

Polimeno
01-24-2009, 07:55 PM
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 :

1. get defs, expose all the values and their wires (master object, slave object, expression, controller, subanim)

2. format all to copy the lines, save as Help_Script_EXPOSED_WIRE.ms file

3. delete modifier, add new one

4. corret the event handler and evalute the def script

5. run Help_Script_EXPOSED_WIRE.ms (make all connections)

6. done (iīm happy)

ZeBoxx2
01-25-2009, 12:55 AM
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?

Polimeno
01-25-2009, 01:33 AM
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

Polimeno
01-26-2009, 11:07 AM
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°= %\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 %; %; %; %\n" i ParamWire_SubAnim the_Parent Parent_Owner

-- Is_Master = .isMaster
-- Is_Slave = .isSlave
-- The_Exp = .getExprText
--
-- format "master Obj= %; Slave Obj= %; the_Exp= %; %\n" Is_Master Is_Slave the_Exp
--------------------------------------------- QUESTIONS
)
)



it returns :

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 donīt know what to do........

PEN
01-26-2009, 12:05 PM
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.

Polimeno
01-26-2009, 12:13 PM
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....


.....

Polimeno
01-29-2009, 09:50 PM
i still wondering if anyone can help me to implement my script to extract the connections and expressions between defs......

at now,
only work if i specify the slave node connection, eg:

obj.pos.controller[2].controller (child wire of CA.test.fk)

i wish i could do the oposite...
picking the main def inside modifier CA, force my script to search who is the child connection, what is it sub anim and track controller, the string of expression....


thanks for any help

CGTalk Moderation
01-29-2009, 09:50 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.