Jump to content

Blender: Bone Weight Copy Script 3.0 (12-24-2013)


gerra6

Recommended Posts

Bone Weight Copy script v.3.0 (12/24/13)

 

This is a replacer for the Blender Boneweight Copy Script. It serves the same function, but is intended to be much more flexible and powerful.

 

Speed

The first advantage this script has is speed. In my tests to date, it has roughly a 400x speed advantage over the version packaged with Blender.

 

Quality

When the "Ring Search Algorithm" is enabled, it tells the tool to treat the selected regions on each mesh as similar structures. It will attempt to match up the outer edges of the selected regions. From there, it will iterate inwards in a ring like fashion, matching up vertex targets by their distance ratio from the edge to the center. In practical terms, this means that with careful selection, this tool does an extremely good job copying otherwise difficult to match weight painting, such as breasts or butts with significant size differences.

 

Flexibility

Instead of generic quality controls, this script allows you to precisely tune the number of vertices that should be averaged together to generate the copy weight. Similarly, you can set precise limits on the maximum allowed search distance.

 

Bone Group Selection

The tool allows you to specify exactly which vertex groups you want copied and which should be left untouched. This means that you can easily copy, say, tail bone weights from one mesh to another without affecting any other bones.

 

Using the tool:

 

 

Let's start with an impossible task. Transfer BB Weightpainting from an HGEC-A Cup to a Mega Manga Cup mesh.

 

Before

 

8241feb21a8909bc2d704ab81a2450da3e5f0195

 

Your first step is to select the area that you want copied. We're going to use the ring algorithm, which means that for best results we want an area selected as a series of concentric circles.

 

So, select a vertex at the center of the region of interest, in this case, the center of the nipple.

 

Select the mesh, tab into edit mode, and select vertex at the center of the right nipple.

 

b84d56d7d5e6d29c498686af91377371839a24fc

 

Next hit Control + until the entire region is selected

 

b3e6881f4800bad6d19672b31c65bb92a64c56c7

 

Hit tab, select the other mesh, hit tab again, and select the center of the right nipple on this mesh.

 

7729a0ff3da307d3b85dae9f725d945a3ac5270d

 

Once again hit control + until the entire region is selected

 

dc4f3532e090c5b68cb9abebc8315404fd92b397

 

Hit tab to return to object mode. With the destination mesh selected, hold down shift and select the source mesh.

 

Click on Object -> Scripts -> BoneWeight Copy 2.2

 

The settings in the tutorial image are pretty good settings if I am looking to exactly copy vertices. If I wanted to get averaged weights, I'd increase "Vertex Targets".

 

Note, I have selected "Mirror After Copy". This means that I will only be copying from one side of the source mesh, but that the vertex groups will be mirrored (R/L) to both sides of the destination mesh.

 

Click OK.

 

1386b6f8d209dc45f077b8b6ffb8073e0aa132ca

 

Since "Select Vertex Groups" was selected, a second menu appears. This contains a button for every single vertex group found on the mesh. Select the ones that you want to copy, leave the other alone.

 

This feature allows you to specify precisely which vertex groups should be copied. In this case, I am interested in copying BB Breast weightpainting, so I select all of the relevant OP bone groups.

 

899d216507b193abd15b60d034d074e47c86d1e6

 

And the results

 

ffc28db9f21c38200240fa0c23fef395b844771f

 

And the automatically mirrored left side

 

066bee81c5fa7805cc943123f86840dfe8264e90

 

Compared to the Original

 

acfeaeda687be8dccf9fdcf5c4c175bcd2adea19

 

Note: The weightpainting was intentionally exaggerated to better demonstrate the fidelity of the copy. Ordinarily anything other than light blue is very bad for BB weightpainting.

 

 

Explanation of Menu Options

 

 

Vertex Targets

This tells the tool how many vertices on the active mesh should influence the weight assigned to any given vertex on the context mesh.

 

A 1 here means that you're getting an exact copy of the weights of a single vertex, higher numbers means that you get a weighted average (by relative distance) of the boneweights.

 

Max Distance

How far (in Blender distance units) should the tool look for targets before giving up

 

Override Distance

Select this if you want to guarantee that every selected vertex finds a target, no matter how distant.

 

Select Vertex Groups

Specify exactly which vertex groups you want to copy

 

Use Ring Algorithm

 

This is an important one. A simple nearest distance algorithm isn't always the best way to find the most *similar* vertex targets. Selecting this tells Blender that you want it to use the Ring Search Algorithm (developed originally for the Lattice Generator) to find the best matching vertices.

 

When does this work well? Well, it is at its best when asked to compare vertices that have been selected via the "Grow Selection" option in Blender select a single vertex and hit (Control +) until the desired area is selected. It tends to do best with cones, tubes, sphereoids...essentially any shapes that have nice circular or oval cross sections.

 

For Best Results, only copy L or R vertex groups when using this method, not both.

 

Mirror After Copy

 

If you selected the Ring Algorithm, chances are you only copied vertex groups from either the left or right side. Select this option to automatically mirror those vertex groups.

 

 

A warning about the Ring Algorithm Button:

 

 

The optional Ring Algorithm (demonstrated in the instructions) is very powerful, but it was designed to be used in conjunction with very careful vertex selection.

 

This option is designed strictly to copy small, stubborn, sections of the mesh that are otherwise nearly impossible to copy. It will not function on excessively large areas or the entire mesh.

 

If you receive any errors while using this tool, double check your selected vertices on both meshes and, if necessary, disable the Ring Algorighm.

 

 

With any luck at all, this script should be bug free. Please let me know about any bugs or weirdness you encounter.

 

BoneWeight Copy 3.0 Download:

 

Combined Blender Scripts Package

 

Archived Downloads

 

 

 

2.3.a BoneWeightCopy2_3a.7z

 

 

 

Change Log

 

 

 

2.3 to 3.0:

 

1. Significant improvements in performance, quality, and reliability

 

2.3 to 2.3.a

 

1. Bug that resulted in an error message if no target vertices were found in range has been resolved.

 

2.2 to 2.3

 

1. Bug that prevented the tool from working if "Select Vertex Groups" was disabled has been resolved

 

Link to comment
  • 2 weeks later...

Sometimes this fails to start.

 

http://www.mediafire.com/?kfbs172cybyu2yy

 

This is the blend file in question.

 

I tried to use this script ( I don't need this for this file but anyway, I just wanted to run the script)

 

It fails when I try to copy from upperbody.001 (layer 6) to upperbody.004(layer 1). It's the chest piece of the armor. cmd window reads something is wrong with line 1, 936, 1020.

Link to comment

Sometimes this fails to start.

 

http://www.mediafire.com/?kfbs172cybyu2yy

 

This is the blend file in question.

 

I tried to use this script ( I don't need this for this file but anyway' date=' I just wanted to run the script)

 

It fails when I try to copy from upperbody.001 (layer 6) to upperbody.004(layer 1). It's the chest piece of the armor. cmd window reads something is wrong with line 1, 936, 1020.

[/quote']

 

I took a look at the Blender Setup. The problem is actually fairly straightforward.

 

Boneweight Copy 2.3a will only attempt to copy boneweights for selected vertices on selected meshes. Unfortunately, if a mesh is selected that has no vertices selected, the script gets a bit angry and spits out an error message.

 

But yeah, don't attempt to copy boneweights to a mesh that has no vertices selected or from a mesh that has no vertices selected. Even without the error message it wouldn't work. This is by design.

 

I'll probably add a handler with a pop-up message for this type of situation in the next version.

 

So to copy weights to all of the armor pieces at once, do the following. One by one, select each piece of armor that you want to copy weights painting to, tab into edit mode, hit 'a' until all of the vertices are selected.

 

Once that is done, select the meshes that you want to copy from. Join them into a single mesh object (this is important, but optional...the tool will only copy from a single mesh object at a time.). Hit tab and make sure that all of the vertices are selected, once again.

 

Then just run the tool.

Link to comment

Ok, I "think" I am trying to do the same thing that Movomo was talking about but I am getting errors so I am probably doing something wrong. What I am trying to do is make the dress I converted from DMRA to HGEC-GMR not clip when the breasts start bouncing. I am trying to copy the breast weighting to the dress chest area so they both bounce the same. After importing the outfit (it already has the body) I then delete the skelly and:

 

1. I select the upperbody in object mode.

2. I tab to edit mode and hit A to get all of the upperbody selected.

3. I tab back to object mod and select the dress.

4. I tab to edit mode and hit A to select all of the dress.

5. I tab back to object mode.

6. With the dress selected I then shift+select the upperbody.

7. I run the tool (version 2.3a).

8. I disable the mirror button since I am doing the whole upperbody at once.

9. I click ok, and..........

 

Bang! Error:

 

File "", line 1, in

File "F:\Crap Apps\Blender\X-Blender_2.49b_rev8\Bin\Blender\.blender\scripts\

oneWeightCopy2_3a.py", line 1020, in

main()

File "F:\Crap Apps\Blender\X-Blender_2.49b_rev8\Bin\Blender\.blender\scripts\

oneWeightCopy2_3a.py", line 1003, in main

BoneWeightCopy(selectedVertexGroups,BW_VNumber.val,BW_Distance.val,BW_Verte

Override.val,BW_Rings.val)

File "F:\Crap Apps\Blender\X-Blender_2.49b_rev8\Bin\Blender\.blender\scripts\

oneWeightCopy2_3a.py", line 843, in BoneWeightCopy

newVectorList = GetRingVectors(ob_ctx, ob_act, meCtx.verts.selected(), meAc

.verts.selected(),3,"General",0)

File "F:\Crap Apps\Blender\X-Blender_2.49b_rev8\Bin\Blender\.blender\scripts\

oneWeightCopy2_3a.py", line 482, in GetRingVectors

RingGroup1 = GetRings(me1, vertlist1, iterations, UncatNMV1, ringname)

File "F:\Crap Apps\Blender\X-Blender_2.49b_rev8\Bin\Blender\.blender\scripts\

oneWeightCopy2_3a.py", line 165, in GetRings

RingDictionary[0] = tempDictionary[0]

KeyError: 0

Link to comment

File "F:\Crap Apps\Blender\X-Blender_2.49b_rev8\Bin\Blender\.blender\scripts\

oneWeightCopy2_3a.py"' date=' line 165, in GetRings

RingDictionary[0'] = tempDictionary[0]

KeyError: 0

 

Looking over the error message and your description of your process, was "Use Ring Algorithm" selected? I clearly need to improve the instructions with that option. I should probably add a back-end error handler with a popup message as well.

 

The issue is that the Ring Algorithm only works if the vertices are iterable as a single group from the outside to the inside. If they aren't, things get ugly fast.

 

For transferring weightpainting from a body to the dress, try disabling the Ring Algorithm altogether. Instead, enable "Select Vertex Groups" and "Override Distance" only.

 

For the rest of the settings, the number of vertices should generally be between 3 and 10. Distance is a bit trickier...for the most part you can set this as high as you want, but sometimes a mesh will require careful tuning.

Link to comment
  • 2 weeks later...

Sigh I so want to use this tools but the issue I have is that the two scripts are not showing up (This one and the other one to copy bone for bb to body :()

 

I put it in Blender folder/ Scripts

and even tried Blender/Scrips/Object but nothing shows up on my blender. I will restart now and hope it works. But if I may be missing something please let me know. Thanks :).

Link to comment

Sigh I so want to use this tools but the issue I have is that the two scripts are not showing up (This one and the other one to copy bone for bb to body :()

 

I put it in Blender folder/ Scripts

and even tried Blender/Scrips/Object but nothing shows up on my blender. I will restart now and hope it works. But if I may be missing something please let me know. Thanks :).

 

Are you using the portable version of Blender from Room207?

 

That one has an extra scripts folder for some reason.

 

Make sure that you are putting the scripts in the Blender/.blender/scripts folder, not the Blender/scripts folder.

Link to comment

Sigh I so want to use this tools but the issue I have is that the two scripts are not showing up (This one and the other one to copy bone for bb to body :()

 

I put it in Blender folder/ Scripts

and even tried Blender/Scrips/Object but nothing shows up on my blender. I will restart now and hope it works. But if I may be missing something please let me know. Thanks :).

 

Are you using the portable version of Blender from Room207?

 

That one has an extra scripts folder for some reason.

 

Make sure that you are putting the scripts in the Blender/.blender/scripts folder' date=' not the Blender/scripts folder.

[/quote']

 

Thank you so so very much, it worked and it kicks butt. I reduces the bunching I always get in the middle though I still have it (I still never know why it always happens to me Q_Q) but It looks great none the less. BTW I wanted to ask a general question on this.

 

How to stop that weird Vertexy thing from happening in the middle

(This has nothing to do with the boneweight form here btw just any where)

 

 

 

d3acdb19fe6a9de4df300c19057b775102375a63fcf6436295cd9c7c0f586f9f6g.jpg

 

 

(Ignore the not so good dress look and etc, this is totally quick model that is still work in progress (Thanks)

 

 

 

Here is a quick look at it how it looks not so bad (this is just using this without using the other boneweight to touch it up), It is a very rough and early version of a mod I am working on, enjoy :)

 

 

 

a7717e4096c21c809b273af7924342121995147918b6cb3ea0327e13d9c0c7426g.jpg

 

6cabbe766af90e04f10666d1294ba70ef1bf6e9511843e937dd90461fbc529a16g.jpg

 

 

 

 

Sorry if my question is nooby btw. I am still trying to master blender and still sometimes find myself in a confused loop X_X.

 

Thanks

HS

PS: Keep up the great work Gerra6!

Link to comment

Well, the answer depends on what is causing the problem.

 

If it is due to bad boneweights, then you should be able to leverage careful selection of vertices to get you the results you need.

 

Assuming that your source mesh is the nude body and your target mesh is the skirt, then the first thing to do is delete all existing vertex groups from the target mesh (the skirt).

 

Select the skirt in the 3D view, move the mouse to the button window and hit f9. Now look for the vertex groups under "Links and Materials" and delete them.

 

Next step is to tab into edit mode and hit 'a' until all vertices are selected. Select the source mesh and do the same.

 

Run the boneweight copy script and see if that fixes the problem.

Link to comment

Well' date=' the answer depends on what is causing the problem.

 

If it is due to bad boneweights, then you should be able to leverage careful selection of vertices to get you the results you need.

 

Assuming that your source mesh is the nude body and your target mesh is the skirt, then the first thing to do is delete all existing vertex groups from the target mesh (the skirt).

 

Select the skirt in the 3D view, move the mouse to the button window and hit f9. Now look for the vertex groups under "Links and Materials" and delete them.

 

Next step is to tab into edit mode and hit 'a' until all vertices are selected. Select the source mesh and do the same.

 

Run the boneweight copy script and see if that fixes the problem.

[/quote']

Thank you thank you,

 

Thank you soo much.

 

Works like a charm and it moves more realistically in the front too.

 

 

 

 

accefb2da0df2672584ab7aa1c1c81e30b40f065ff290272bc71d4423001ac1b6g.jpg

 

 

 

Sumiko likes the fit now :D

 

 

 

92c6b1dcdb636ac0abd9d8cda73ca6d13356ea025957b786237fc07361a98bec6g.jpg

 

 

 

Can't wait to see your next magic tool Gerra6!!!!

Link to comment

This script should also work on Skyrim meshes' date=' right?

Should I copy then part by part or can I just copy from the whole body?

[/quote']

 

Yep. It should work fine for Skyrim meshes.

 

You can copy the entire body at once, just make sure to disable the "ring search".

Link to comment

I'm trying to BWC from wigmachine2 & ponytail machine to the hair.

 

ponytail(wide one) was successful but when I do it with wigmachine2 (narrow one) Blender freezes, no response.

 

 

 

dkpb913q53h9t19bg.jpg

510shlhbu48o7l4bg.jpg

cxyiin6kus4f7a8bg.jpg

0uqu0rwsl2d0iz7bg.jpg

 

 

 

Basically what I want to do is copying Bip01 Head from wigmachine2, and Spine/Spine1/Spine2 from ponytailmachine.

 

console window says nothing but a *begin* message.

Link to comment

I'm trying to BWC from wigmachine2 & ponytail machine to the hair.

 

ponytail(wide one) was successful but when I do it with wigmachine2 (narrow one) Blender freezes' date=' no response.

 

Basically what I want to do is copying Bip01 Head from wigmachine2, and Spine/Spine1/Spine2 from ponytailmachine.

 

console window says nothing but a *begin* message.

[/quote']

 

Hmm...I'll see what I can figure out.

 

In the meantime, see if you can get the results you want using a body mesh. The tool should be able to provide some decent result off of a base body and head.

 

***Edit***

 

Yep, there's some weird interaction between that wig, the rigging machine, and the tool.

 

I've narrowed it down to a specific group of problem vertices and they are all clustered at the tip of the bottom of the ponytail. For some reason the vertices at the lowest point of the ponytail are unable to find targets. I haven't figured out why yet, but I have a couple of ideas.

 

Anyways, there are two easy solutions for now. Easiest is just to just do a z-axis scale on the rigging machine so that the bottom is roughly and then slide it back down until the top matches the prior position.

 

The other is just to use a base body for the bone weight copier. The rigging machines are handy, but were designed to compensate for the limitations of the vanilla blender boneweight copy script. They *shouldn't* be necessary with this script, but there are probably situations where they will be needed.

 

I've attached my modification to the rigging machine and ran the script.

 

I'll see about updating the script shortly. There are a couple of changes I've been meaning to make to it.

evylongponytail.7z

Link to comment

but there are probably situations where they will be needed.

 

Thanks, I'll try it shortly. (Just doing some experiments now)

 

The reason why I wanted to use the ponytail machine was because its weighted power is weaker than the normal. 'sub' weightpaint brush does no good on this clustered hairs.. Is there any way to substract the weight like when I assign the vertex weights in edit mode?

Link to comment

but there are probably situations where they will be needed.

 

Thanks' date=' I'll try it shortly. (Just doing some experiments now)

 

The reason why I wanted to use the ponytail machine was because its weighted power is weaker than the normal. 'sub' weightpaint brush does no good on this clustered hairs.. Is there any way to substract the weight like when I assign the vertex weights in edit mode?

[/quote']

 

Well, the modified ponytail machine in my attachment does the job.

 

As far as modifying existing weights, I *think* that there is already a Blender script in the default install that will do that. If not, I could throw one together, that would be fairly simple to do.

 

What sort of settings would you like it to have?

Link to comment

As far as modifying existing weights' date=' I *think* that there is already a Blender script in the default install that will do that. If not, I could throw one together, that would be fairly simple to do.

 

What sort of settings would you like it to have?

[/quote']

 

On second thought- I guess Normalize Vertex Weights script will do the job I want. I thought it's purpose is deleting all weights under the peak weight before, but have to do some experiment. Thanks for the heads up.

Link to comment

As far as modifying existing weights' date=' I *think* that there is already a Blender script in the default install that will do that. If not, I could throw one together, that would be fairly simple to do.

 

What sort of settings would you like it to have?

[/quote']

 

On second thought- I guess Normalize Vertex Weights script will do the job I want. I thought it's purpose is deleting all weights under the peak weight before, but have to do some experiment. Thanks for the heads up.

 

Let me know if it works.

 

Now, another possibility is to add a magnify weight setting to the bone weight copier that increases or decreases the copied weights by a specified percentage.

Link to comment

No luck with the body. It's too stiff for wigs, they need to be more gradual.

(Riggin machine is still better than the body especially for between neck1/spine2)

 

As to the Normalize script, it literally normalized the weight. :[

e.g. if I set the peak weight to .5 then almost all the weight value in the active group turn to 0.5. It does its job, but seems somewhat tricky to use.

Perhaps I better stick with the old way for now, that selecting the region and applying gradient script.

Link to comment

No luck with the body. It's too stiff for wigs' date=' they need to be more gradual.

(Riggin machine is still better than the body especially for between neck1/spine2)

 

As to the Normalize script, it literally normalized the weight. :[

e.g. if I set the peak weight to .5 then almost all the weight value in the active group turn to 0.5. It does its job, but seems somewhat tricky to use.

Perhaps I better stick with the old way for now, that selecting the region and applying gradient script.

[/quote']

 

Did you try the rigging machine in the blend file I uploaded? I was able to get a good copy onto the wig using the stretched machine.

 

I'll update the boneweight copy script once I figure out why those particular vertices failed.

Link to comment

Did you try the rigging machine in the blend file I uploaded? I was able to get a good copy onto the wig using the stretched machine.

 

I'll update the boneweight copy script once I figure out why those particular vertices failed.

 

Sure I did. For some reason it works now. That object scaling trick looks similar to what I've done for so long with the old bone weight copy script. The huge better thing now is that I can manipulate which vertex groups will be copied. Well, I still need to do some manual edits to get a nice natural movement. (and reallly, is not the script's fault nor rigging machine's fault.)

Link to comment

Sure I did. For some reason it works now. That object scaling trick looks similar to what I've done for so long with the old bone weight copy script. The huge better thing now is that I can manipulate which vertex groups will be copied. Well' date=' I still need to do some manual edits to get a nice natural movement. (and reallly, is not the script's fault nor rigging machine's fault.)

[/quote']

 

I was able to write a bit of code that selected all of the problem vertices. Basically, the entire tip of the pony tail that was more than a certain distance below the plane of the rigging machine couldn't find targets and would lock up the search.

 

I'm trying to figure out why, although there is a weak point in the algorithm that I've been a bit worried about for some time that *might* be causing it. I've got some debugging to do to see if that is indeed the cause.

 

I'll have that fixed one way or another in the 2.4 release, which should include some weight magnification options.

Link to comment

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use