View Full Version : Copying ncloth per-vertex attributes

06-16-2008, 08:17 PM

I want to know if there is a way to copy the weight map of a per-vertex ncloth attributes from a scene to another scene (on the same object in a different scene).

I want to write a simple script to simulate the cloth on a character in many different scenes.
the cloth is skinned. So I select the cloth geometry, turn it to nCloth, set the Input mesh attract to 1.5 and input attract damp to 0. And I then use in the menu "edit ncloth: Paint vertex properties: input attract" and I paint a weight map for the parts I want to be fully dynamic.

My question is: how can I then copy this weight map and paste it in another scene on the same cloth but with its own deformation (by the skin) as a starting point. (I mean if I just copy the whole cloth, I will not have the skin animation as a strating point). And I would like to do this within a melscript.

06-17-2008, 02:22 AM
Ok I found it.

While in paint mode, in the Paint NCloth Attributes Tool (right panel) in the Attribute Maps section , there is a sub-section called import. There is no export though. To export I create the map in "paint texture properties" instead of "paint vertex properties" mode. And then I can import the created map in "paint vertex" mode. And I can grab the melscript created in the script editor!

artImportAttrMapCB artAttrCtx "D:/vol/scripts/FX/cloth/hairWeight.tga" "image";

06-19-2008, 06:56 PM
Note that you can also convert between texture and vertex maps automatically (nCloth->convertVertexToTextureMap)


06-19-2008, 07:53 PM
Ok tanks a lot Duncan! Could be useful.

08-14-2008, 01:45 PM
what if I dont got UVs for the objects I'm using as nCloth?
How do I transfer vertex input attraction weights from one to another?


08-14-2008, 02:29 PM
ok, so I found this attribute nClothShape1.inputAttractPerVertex which seem to contain the vertices input Attract Weight so I wrote this code:

float $hi[] = `getAttr nClothShape1.inputAttractPerVertex`;
print $hi;
setAttr "nClothShape2.inputAttractPerVertex" -type "doubleArray" $hi;

but its give me an ERROR

// Error: line 3: Error reading data element number 3: //

for now I have no Idea what is the Problem, I suppose it means the content of index 3 in the Array, I checked it and its got a float value in it.


08-14-2008, 10:45 PM
you need to tell it the number in the array...
and you need to be built the command and eval it.
try this.

float $hi[] = `getAttr nClothShape1.inputAttractPerVertex`;
string $CMD = ("setAttr -type doubleArray nClothShape2.inputAttractPerVertex " + size($hi));
for ($aVal in $hi){
$CMD+= (" " + $aVal);
eval $CMD;


08-17-2008, 07:35 AM
It works.
Thanks john.


CGTalk Moderation
08-17-2008, 07:35 AM
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.