PDA

View Full Version : Instancing costom attributes to penn attribute holder


bloggs
04-17-2006, 11:44 PM
Hi all and Penn if your out there. i have made a bone face rigg based on Pauls DVD and also adding several deformer muscels and bone objects. things are coming along well and i have got to the point where i am going to add all my ctrl objects to the Penn attribute holder so adding 61 ctrls with all xyz rotation and positions is going to be a big lot of copying and pasteing that i dont want to have to do. so script time. the only problem here is that i have very little scripting experenace so i thought this would be a good one to get more experance on and have somthing others to use. at the moment i'm stuck on the small things so here goes.

here is a QT of what it looks like so far dowload 3.5 meg (http://www.kaffeineproductions.com/downloads/face%20muscle%20skin%20test2.mov)

http://www.kaffeineproductions.com/downloads/muscle%20image2.jpg

http://www.straiusmusic.com/johno/muscle%20image2ctrls.jpg

here is the what i have scripted so far witch is mainly what i have lernt of the face rigg DVD however i'm using some of the strings in differnt ways witch could be the completly worng way of approcing this. i'm not really sure how i should be setting this out any comments would be apreciated.

--fn instanCTRLpennAttribute --i'll call it somthing better later

getobj=selection[1] --oject with the attributes
setobj=selection[2] --oject with penn attribute holder

objn=getobj.name

def=attributes myface

(
parameters faceP
(
objn_posX type:#float --name each attribute according to the frist selected object + the track
--objn_posY type:#float
--objn_posz type:#float
--objn_rotx type:#float
--objn_rotY type:#float
--objn_rotz type:#float

)
)
--this next block of code will need instance the first obj tracks to the second obj track
--this is what i have so far which works but not from posX to the addid attribute"objn_posX"

getobj=selection[1] --first select object copying from
setobj=selection[2] --second select object paste to

getobj.position.x_position.controller=setobj.position.x_position.controller






i was thinkin of having a function that i could call on and have a interface for it later.

I am trying to create and name the attributes based on the first selected object and apply it to the second with the pen attribute holder. Does anyone knows how to append names?. which i have no idea how to do and cant seem to find anything in the maxscript help. so any help with appending names would be great also how do i instance controllers.

any pointers on the way i should layout the script would also be greatly apreciated.


cheers


john

bloggs
04-18-2006, 02:16 AM
just to make things esier to understand these are the thing i need to get going before i can even make it work.

i am tring to instance the one controller from on to the other.

this expression works

getobj=selection[1] --first select object copying from
setobj=selection[2] --second select object paste to

getobj.position.x_position.controller=setobj.position.x_position.controller

which works nice but when i try it for my costome attributte on my penn atributholder it errors out.

this is the expression i'm trying to get to work

getobj=selection[1]
setobj=selection[2]

getobj.position.x_position.controller=setobj.modifiers[1].myface.objn_posX.controller


where myface is the attribute and Objn_posX is the float that i'm trying to paste the instance to.

the error i'm getting is

$Sphere:Sphere01 @ [-40.431576,-7.321520,0.000000]
$Editable_Mesh:Sphere02 @ [-15.382270,-8.209094,0.000000]
-- Type error: Assign needs controller, got: undefined

i can't understand what i am doing worng any answers would be apreciated

Martin Andersen
04-18-2006, 02:23 AM
there is a spell error:

getobj.position.x_position.controller=setobj.posit ion.x_position.controller


think you allready know.. :thumbsup:

bloggs
04-18-2006, 02:47 AM
werid its in the post itself but when i go to edit it its fine. weird

PEN
04-18-2006, 01:15 PM
Wow, very cool, I realy want to see this deforming a face.

Well one thing that I see right off the bat is that you need to do the instance the other way around.

setobj.modifiers[1].myface.objn_posX.controller= getobj.position.x_position.controller

the reason is that the custom atttrbute parameter will not have a controller on it until it is animated. This way you are making the CA params controller = to the one that is already on the control.

The next error that I see is in the way that you are getting the position controller it self. You should be using this instead.

getobj.pos.controller.x_position.controller

The next problem if you are following my DVD's to the letter is I use list controllers on just about every thing so that will still not get you the controller that you need. If the controller that you are after is the second controller in a list controller you will have to do this.

getobj.pos.controller[2].x_position.controller

So your final code should look more like this.

setobj.modifiers[1].myface.objn_posX.controller= getobj.pos.controller[2].x_position.controller

Let me know if that helps. I would also like to know what you think if the DVD, where it went well and where it didn't. It looks as though you have picked up alot from it and tried your hand at making your own and not just copying every thing that I have done. Great job.

bloggs
04-18-2006, 06:18 PM
Hi Paul,

thanks so much for the reply now you metion this problem it seams so obvious and simple. it even explains the error message i'm getting. cheers for that.good to know that i wasnt completely off the mark.

here is the link to the skin deformer working skin test (http://www.kaffeineproductions.com/downloads/face%20muscle%20skin%20test2.mov)
Not all the muscle are workin in this version and the neck i hadent started to get working yet but it shows the potetial of the rigg. i allso used some sqaush and stretch bones in bettween the face bones to get abit of bulging in some of the skin folds. although it would be good if i could very the scale factor for those bones so i could exagerate the squash and stretch. i see another script here!!hehe new doors are opening:thumbsup:

the next thing i can't get to work is the attribute nameing so i want the getobj name plus posX posY posZ tacked on the end of the name. i understand i can do something like this to rename just objects.

for obj in selection do
(
obj.name = (obj.name + "posX" )

however i can't get it to work on the costom attribute. i cant find out how to do it in script help iether.

i'll work on this today so i'll post agian probably later.


feedback on the Facial rigging DVD.
Paul this dvd was very well layed out and even went beyond my expection. The fact that you showed 2 methods of approching face riggs was awsome. i personally was mainly interested in the bone based rigg as i had atempted this a while back with no great resalts.the wiring pearamiters was a really good flexable aproach. Most of you demonstation are extremely easy to follow and you allways metion why this is the best approch. The maxscipts are i think the most important part for me as you show applied maxscripting and step by step explained all the fuctions you are using. Even for a maxscipt novice like me i suddenly felt that this was not beyond anyones reach. i would personlly be happy with just a dvd full of wrighting rigging scripts and pipline tools. i have yet to check out bobos dvd's

if i had to find somthing critical about the dvd the only thing i could say that might have inproved it would have been a chapter of theory behind facial structure and how a face works and the veriations between real and comical. apart from that it would have been interesting to see abit of a show and tell on some of the riggs you have done in the past. all in all these thing really would be icing on the cake.

I look farward to the next DVD if there are plans for a next one. any plans for what it might be?

thanks again for the help

cheers

john

PEN
04-18-2006, 06:38 PM
Adjusting the amount of scale that affects the skin of the character can be achieved in the Skin modifier itself. Have a look at the Squash value, every one misses this one completely and I use it all the time.

As for changing the names of a parameter you can't do that. You have to build the parameter with the name that you need. So if you want to dynamicaly set up the CA def based on the tracks that you are going to be adding you would have to build the whole CA def as a string formatting the parameters based on what you have selected. Then you add the def by executing the string into an def and apply it. From there you just wire to it as you have been.

Thanks for the feed back on the DVD. I was looking to add a whole section on facial animation but the DVD got so long I figured I would drop it as there is great information out there already. The book Stop Stairing is a great resource, it is all based on Maya but the areas that he covers facial animation is universal. There are also lots of great books for cartoon animation and facial studies done on humans that are great resources.

As for what is comming next... well I'm going to keep that to my self as it will be very cool and I I hope well recieved.

bloggs
04-18-2006, 07:36 PM
hi paul,

yeah i understand about the dvd, its was jam packet anyway! no disapointmants for me:thumbsup:.] well i look farward to the next one no matter what it is i'm sure it will be good.


hehe i just work out that i cant do it when you post came through i just rewrote the script on edzactly what you just sayed. i think i'mfinally getting it. YAY

here is what i have


getobj=selection[1]
setobj=selection[2]



def=attributes (getobj.name)-- myface --


(
parameters faceP

(
posX type:#float
posY type:#float
posZ type:#float
rotX type:#float
rotY type:#float
rotZ type:#float

)
)

custAttributes.add setobj.modifiers[1] def



getobj=selection[1]
setobj=selection[2]

setobj.modifiers[1].myface.posX.controller= getobj.pos.controller.x_position.controller
setobj.modifiers[1].myface.posY.controller= getobj.pos.controller.x_position.controller
setobj.modifiers[1].myface.posZ.controller= getobj.pos.controller.x_position.controller
setobj.modifiers[1].myface.rotX.controller= getobj.pos.controller.x_position.controller
setobj.modifiers[1].myface.rotY.controller= getobj.pos.controller.x_position.controller
setobj.modifiers[1].myface.rotZ.controller= getobj.pos.controller.x_position.controller



of cousre i need to set it out so it all works together but i'm close i think.

just can't get the def=attributes (getobj.name) to work but if i can get that then i will be really close to making this the work. whhhooooohooo

cheers

john

PEN
04-18-2006, 08:24 PM
b=box name:"theObjectBeingControlled"
c=circle name:"theControlObject"

aParam=($theObjectBeingControlled.name+"_height")

str="def=attributes test \n(\n"
str+=" parameters testP rollout:testR \n\t(\n"
str+=" "+aParam +" type:#float UI:"+aParam +" \n\t)\n"
str+=" rollout testR \"Test\" \n\t(\n"
str+=" spinner " +aParam + " \""+aParam +"\"\n\t)\n"
str+=")\n"

caDef=execute str
custAttributes.add c caDef

aParamName=(aParam as name)
paramWire.connect c.test[aParamName] b.baseObject[#height] aParam

select c


Try that, just run the code.

bloggs
04-19-2006, 06:21 AM
Hi paul,

thanks for that little example on strings took me awhile to undersatnd what you had done but after a dose of the maxscript Help i worked it out:thumbsup:now i'm a pro. strings are awsome if you hadn't shown me i would have been flailing around on that one. i gather you have to use strings alot if there are verables that have no direct maxscipt fuction. really nice way of getting around this problem.

anyway here is what i have. i made it so evey object creates a new attribute name so that the paramiters will be easire to find if need be. just make two object the second need a modifier of some kind like the penn attribute holder just ctrl select in order you need to make the connection, althought i'm sure you know the drill. i must say i have never thought a costom attribute looked so go when its wired. hehe


getobj=selection[1]
setobj=selection[2]


dParam=(getobj.name)

aParam=(getobj.name+"_x")
bParam=(getobj.name+"_y")
cParam=(getobj.name+"_z")

--on botton press do
(
(
str="def=attributes "+dParam +" \n(\n"
str+="\t parameters faceP \n\t(\n"
str+=" "+aParam +" type:#float \n\t"
str+="\t"+bParam +" type:#float \n\t"
str+="\t"+cParam +" type:#float \n\t)\n"
str+=")\n"
)
caDef=execute str
custAttributes.add setobj.modifiers[1] caDef
)

--on button press do

(
(
str="\n(\n setobj.modifiers[1]."+dParam +"."+aParam +".controller= getobj.pos.controller.x_position.controller \n"
str+=" setobj.modifiers[1]."+dParam +"."+bParam +".controller= getobj.pos.controller.y_position.controller \n"
str+=" setobj.modifiers[1]."+dParam +"."+cParam +".controller= getobj.pos.controller.Z_position.controller \n)\n"
)
execute str
)



now i just need to create a verable for the animation track i want to instance eg the top controller

i am thinking of making a button so you can manually plug with an integer number or somthing. i'll tackle that one tomorrow.

just wondering is there any real reason you wired the controller as aposed to instance them in your example.

thanks for the tip on the squash and stretch i completely missed it. but i cant say i ever used squash and stretch until now. i need to do some more comical chacarters i think.

thanks agian paul for you time

cheers

john

PEN
04-19-2006, 12:01 PM
You can instance them there as well, works great and is probably faster then wires. It was just a habit to write it that way.

Glad that you have it working, I can't wait to see the final results.

bloggs
04-19-2006, 09:59 PM
ok script is working fine but now i have a verable that wont run.

i am using a basic toolbar to feed it values but when i run it it errors out.

here is where the problem lyes when i'm trying to feed a spinner to a string

--zParam=(spn1.value)
--xParam=(spn2.value)--this is what i want to work

when i try to use this and it calutales the string i get a message saying "unable to convert: 1 to Type: string" where 1 is the value on the interface spinner and is suposed to repersent the contoller number.

of course if i do this it works fine

xParam="1"
zParam="1"

all i can work out is that it doesnt like beening feed numbers into a string surly there is a way around this like "print spn1.value" or somthing. i have evne tried
xParam= execute "spn2.value"



here is the code

macroscript instance_controller
category:"john Scripts"
(



rollout johnboy "Face j rigg tools"
(
button btn1 "eggs-e-cute" pos:[50,160] width:91 height:32
GroupBox grp1 "Selections" pos:[5,45] width:190 height:100
spinner spn1 "controller number " pos:[80,60] width:106 height:16 range:[0,10000,1] type:#integer
spinner spn2 "modifier number " pos:[82,85] width:104 height:16 range:[0,10000,1] type:#integer
checkbox rotCheckBox "Rotation" pos:[10,100]
checkbox posCheckBox "Postion" pos:[10,120]
label lbl3 "Select objects you want to paste from and to " pos:[9,10] width:182 height:27


on btn1 pressed do
(
getobj=selection[1]
setobj=selection[2]



dParam=(getobj.name+"_Pos")
hParam=(getobj.name+"_Rot")

aParam=(getobj.name+"_xPos")
bParam=(getobj.name+"_yPos")
cParam=(getobj.name+"_zPos")
eParam=(getobj.name+"_xRot")
fParam=(getobj.name+"_yRot")
gParam=(getobj.name+"_zRot")
--xParam=(spn2.value)
--zParam=(spn1.value)
xParam="1"
zParam="1"

(--position start--on posCheckBox yes do
(
str="def=attributes "+dParam +" \n(\n"
str+="\t parameters faceP \n\t(\n"
str+=" "+aParam +" type:#float \n\t"
str+="\t"+bParam +" type:#float \n\t"
str+="\t"+cParam +" type:#float \n\t)\n"
str+=")\n"
)
caDef=execute str
custAttributes.add setobj.modifiers[1] caDef
)


(
(
getobj=selection[1]
setobj=selection[2]

str="\n(\n setobj.modifiers[1]."+dParam +"."+aParam +".controller= getobj.pos.controller["+zParam +"].x_position.controller \n"
str+=" setobj.modifiers[1]."+dParam +"."+bParam +".controller= getobj.pos.controller["+zParam +"].y_position.controller \n"
str+=" setobj.modifiers[1]."+dParam +"."+cParam +".controller= getobj.pos.controller["+zParam +"].Z_position.controller \n)\n"
)
execute str
)
(--rotation start-on rotCheckBox yes do

(
str="def=attributes "+hParam +" \n(\n"
str+="\t parameters faceP \n\t(\n"
str+=" "+eParam +" type:#float \n\t"
str+="\t"+fParam +" type:#float \n\t"
str+="\t"+gParam +" type:#float \n\t)\n"
str+=")\n"
)
caDef=execute str
custAttributes.add setobj.modifiers[1] caDef
)


(
(
getobj=selection[1]
setobj=selection[2]

str="\n(\n setobj.modifiers[1]."+hParam +"."+eParam +".controller= getobj.rotation.controller["+xParam +"].x_rotation.controller \n"
str+=" setobj.modifiers[1]."+hParam +"."+fParam +".controller= getobj.rotation.controller["+xParam +"].y_rotation.controller \n"
str+=" setobj.modifiers[1]."+hParam +"."+gParam +".controller= getobj.rotation.controller["+xParam +"].Z_rotation.controller \n)\n"
)
execute str
)

)

)



CreateDialog johnboy width:200 height:200


)-- end of rollout



any help would be great


cheers

john

bloggs
04-19-2006, 10:04 PM
Ok well i missed that one in the maxscript help! tipical though as soon as i'm about crack and i post a question i worked it out for myself.:scream:


i just worked it out that for all numbers or integers i needed to have "as string" after them

so finally got

xParam= spn2.value as string
zParam= spn1.value as string


work a treat:thumbsup:


its getting there

if anyone has any other feature requests i'm willing to see how far i can take this script

maybe make it so it can auto ad spiners and sliders for you characters

cheers

john

bloggs
04-20-2006, 03:28 AM
ok just posting to show you how things are coming along.

the only thing left to do is to get my checkboxes working. the only problem i'm hving is how to set it out. i think i'm approuching it the wrong way. what i want is for it to excucute bit of script depending on if the attribute is checked.

this is what i have but it won't evaluate at this stage i havent worked out why yet so any clues would be great.

macroscript instance_controller
category:"john Scripts"
(



rollout johnboy "Face j rigg tools"
(
button btn1 "eggs-e-cute" pos:[50,160] width:91 height:32
GroupBox grp1 "Selections" pos:[5,45] width:190 height:100
spinner spn1 "controller number " pos:[80,60] width:106 height:16 range:[0,10000,1] type:#integer
spinner spn2 "modifier number " pos:[82,85] width:104 height:16 range:[0,10000,1] type:#integer
checkbox rotCheckBox "Rotation" pos:[10,100]
checkbox posCheckBox "Postion" pos:[10,120]
label lbl3 "Select objects you want to paste from and to " pos:[9,10] width:182 height:27


on btn1 pressed do
(
getobj=selection[1]
setobj=selection[2]



dParam=(getobj.name+"_Pos")
hParam=(getobj.name+"_Rot")

aParam=(getobj.name+"_xPos")
bParam=(getobj.name+"_yPos")
cParam=(getobj.name+"_zPos")
eParam=(getobj.name+"_xRot")
fParam=(getobj.name+"_yRot")
gParam=(getobj.name+"_zRot")
xParam= spn2.value as string
zParam= spn1.value as string
yParam= spn2.value


(
on posCheckBox changed state do
(

(
str="def=attributes "+dParam +" \n(\n"
str+="\t parameters faceP \n\t(\n"
str+=" "+aParam +" type:#float \n\t"
str+="\t"+bParam +" type:#float \n\t"
str+="\t"+cParam +" type:#float \n\t)\n"
str+=")\n"

caDef=execute str
custAttributes.add setobj.modifiers[yParam] caDef


getobj=selection[1]
setobj=selection[2]

str="\n(\n setobj.modifiers["+xParam +"]."+dParam +"."+aParam +".controller= getobj.pos.controller["+zParam +"].x_position.controller \n"
str+=" setobj.modifiers["+xParam +"]."+dParam +"."+bParam +".controller= getobj.pos.controller["+zParam +"].y_position.controller \n"
str+=" setobj.modifiers["+xParam +"]."+dParam +"."+cParam +".controller= getobj.pos.controller["+zParam +"].Z_position.controller \n)\n"
)
execute str


(
on rotCheckBox changed state do
(

(
str="def=attributes "+hParam +" \n(\n"
str+="\t parameters faceP \n\t(\n"
str+=" "+eParam +" type:#float \n\t"
str+="\t"+fParam +" type:#float \n\t"
str+="\t"+gParam +" type:#float \n\t)\n"
str+=")\n"

caDef=execute str
custAttributes.add setobj.modifiers[yParam] caDef


getobj=selection[1]
setobj=selection[2]

str="\n(\n setobj.modifiers["+xParam +"]."+hParam +"."+eParam +".controller= getobj.rotation.controller["+zParam +"].x_rotation.controller \n"
str+=" setobj.modifiers["+xParam +"]."+hParam +"."+fParam +".controller= getobj.rotation.controller["+zParam +"].y_rotation.controller \n"
str+=" setobj.modifiers["+xParam +"]."+hParam +"."+gParam +".controller= getobj.rotation.controller["+zParam +"].Z_rotation.controller \n)\n"
)
execute str
)

)
CreateDialog johnboy width:200 height:200

)

)
)

)-- end of rollout



i'm so close now. without the check boxes in the script everything works well you can choose what controller and what modifier you want it to instance to.

anyway

cheers


john

bloggs
04-24-2006, 04:50 PM
Ok yes i got it working.

the problem i was having was not the checkboxs at all i just needed to decler a few global varables. its allways somthing simple

here it the final script. download (http://www.kaffeineproductions.com/downloads/instance%20contoller%20v0.1.ms)

and a test file download (http://www.kaffeineproductions.com/downloads/instance%20controller%20test.max)


install instructions are in the script

any coments would be great

anyway thanks again paul for your help.

cheers


john

CGTalk Moderation
04-24-2006, 04: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.