JeremyR
Hi Peter,

If I create a boundingObject from the SOuP menu, the mel the pops up in the script editor is...

createNode boundingObject;

But if I copy and paste this back into the script editor, i get a whole lot of errors.
Which is the best way to create a bounding object and connect it to an attributeTransfer node?

cheers


Reply 0 0
pshipkov
They are harmless, but you have to add keys to the ramp attributes by hand.
Reply 0 0
JeremyR
I tried creating a bounding Obect by selecting the ATransfer node and running this code...

string $sBoundingObj[] = `createNode boundingObject`;
connectAttr ($sBoundingObj[1] +."outData") ($sATransferNode +".boundingObjects[1]");
connectAttr ($sBoundingObj[1] +."outParentMatrix") ($sATransferNode
+".boundingObjects[1].boundParentMatrix");


but it wont create attached to the AT node. Actually Im getting syntax errors but my main question is how I can create a bounding obj that automatically attaches itself to the AT node.

Is the above code the way to do it? (once I figure out my errors)

Reply 0 0
JeremyR
Another question regarding building UI tools. Im always in the dilemma whether to incorporate code which accepts pre-existing objects in a scene or just make the user have to build new ones with the UI tool.

I guess it depends on the tool one is designing but from my POV, I would prefer to let the UI build the geometry mainly because its easier to implement but it also means the artist has to decide from the beginning that they are going to use this tool, rather than realise half way through the creation process.

What are your thoughts on this?

Reply 0 0
ourouk
in MEL : createNode `boundingObject` returns a string. So using $sBoundingObj[1] is not going to work isn't it ?
You are going to have a type mismatch :

// Error: line 1: Cannot convert data of type string to type string[]. //



I tried to use createNode 'boundingObject' in mel at the first time but another way to do is more suitable I guess, it's Python :
soup().create('boundingObject')
.
It returns a string[] ( [transform,shape] ).

Here is some code in Python to create and connect a bounding object  to an attribute Transfer :

attributeTransfer = soup().create('attributeTransfer')
boundingObject = soup().create('boundingObject')
cmds.connectAttr(boundingObject[1]+'.outData',attributeTransfer+'.boundingObjects[1]')
cmds.connectAttr(boundingObject[1]+'.outParentMatrix',attributeTransfer+'.boundingObjects[1].boundParentMatrix')


Hope it make sense. Don't know if you can do this with mel ?
Reply 0 0
ourouk
aikiman wrote:
Another question regarding building UI tools. Im always in the dilemma whether to incorporate code which accepts pre-existing objects in a scene or just make the user have to build new ones with the UI tool.

I guess it depends on the tool one is designing but from my POV, I would prefer to let the UI build the geometry mainly because its easier to implement but it also means the artist has to decide from the beginning that they are going to use this tool, rather than realise half way through the creation process.

What are your thoughts on this?



I can't understand.
What do you mean by : " incorporate code which accepts pre-existing objects in a scene or just make the user have to build new ones with the UI tool" ?
Reply 0 0
JeremyR
what I mean is when you are creating a new tool, do you design it so that the user inputs their own objects, or is it acceptable to let the tool create the geometry for you?

Knowing this in advance the user would then plan and use the UI created object without hassles.

Reply 0 0
JeremyR
ourouk wrote:
in MEL : createNode `boundingObject` returns a string. So using $sBoundingObj[1] is not going to work isn't it ?
You are going to have a type mismatch :

// Error: line 1: Cannot convert data of type string to type string[]. //



I tried to use createNode 'boundingObject' in mel at the first time but another way to do is more suitable I guess, it's Python :
soup().create('boundingObject')
.
It returns a string[] ( [transform,shape] ).

Here is some code in Python to create and connect a bounding object  to an attribute Transfer :

attributeTransfer = soup().create('attributeTransfer')
boundingObject = soup().create('boundingObject')
cmds.connectAttr(boundingObject[1]+'.outData',attributeTransfer+'.boundingObjects[1]')
cmds.connectAttr(boundingObject[1]+'.outParentMatrix',attributeTransfer+'.boundingObjects[1].boundParentMatrix')


Hope it make sense. Don't know if you can do this with mel ?


mmm maybe this is a good opportunity to finally learn Python
Reply 0 0
pshipkov
Yes, Ouruk is right. The soup.create() calls is wrapper and returns both the transform and shape node names.
createNode boundingObject is a standard maya command and returns only the name of the created node.

What you want to do looks like this in MEL (i corrected the string/stringArray issue and another small syntax error):

string $sAT = `createNode attributeTransfer`;

string $sBO = `createNode boundingObject`;

connectAttr ($sBO+".outData") ($sAT +".boundingObjects[1]");

connectAttr ($sBO+".outParentMatrix") ($sAT+".boundingObjects[1].boundParentMatrix");



Reply 0 0
JeremyR
okay thanks for that. I thought I tried that originally and then played around with the code and stuffed it up I think. I thought the createNode boundingObject in mel creates a transform as well? This is what stuffed me up.

Onwards and upwards!

Reply 0 0
ourouk
pshipkov wrote:

string $sAT = `createNode attributeTransfer`;

string $sBO = `createNode boundingObject`;

connectAttr ($sBO+".outData") ($sAT +".boundingObjects[1]");

connectAttr ($sBO+".outParentMatrix") ($sAT+".boundingObjects[1].boundParentMatrix");



The problem with creating soup nodes in mel is they have no "default values" ( ramps especially ). I like to have these "basic values" when I create a node :)
Maybe is it a way to have these values created in Mel ?

Reply 0 0
ourouk
aikiman wrote:
what I mean is when you are creating a new tool, do you design it so that the user inputs their own objects, or is it acceptable to let the tool create the geometry for you?

Knowing this in advance the user would then plan and use the UI created object without hassles.



I think it is "weird" to let a tool create geometry for me...How can I control the object created by the tool ? I would prefer to feed the tool with my own geometry.
But, maybe I can't understand all the things here ( my english is not so good ;) )
Can you give me an example of a tool creating geometry automatically ?
thx
Reply 0 0
JeremyR
Perhaps its best just to accept user input geometry.
Reply 0 0
Reply