16
$\begingroup$

With Skin Modifier, we can "weight" a vertex (in Edit Mode) so that the resulting Skin mesh is bigger or smaller - similar to Curve objects which has "Scale Feather" adjustable.

Manually, we can hit Tab, go to Edit Mode, select Vertices, then CtrlA and drag.

However, I would like to be able to do this using Python. Does anyone know anything about it?

$\endgroup$

1 Answer 1

15
$\begingroup$

Reading and writing these values from Python must happen in Object mode. I added a plane and deleted one vertex, added the skin modifier and decreased the radius of one vertex.

>>> obj = bpy.data.objects['Plane']
>>> for v in obj.data.skin_vertices[0].data:
...     print(v.radius[:])
...     
(0.25, 0.25)
(0.25, 0.25)
(0.08836718648672104, 0.08836718648672104)

Each element in skin_vertices[0].data has radius, use_loose, use_root to read and write. Radii can be any two element iterable (tuple, list).

import bpy

obj = bpy.data.objects['Plane']
for v in obj.data.skin_vertices[0].data:
    v.radius = 0.2, 1.2

I just realized that CtrlA lets you constrain the effect on radius per axis with ShiftX,Y.

$\endgroup$
4
  • 2
    $\begingroup$ Thanks so much for this answer @Zeffii! Right on solution. I was also surprised that we can constraint the effect either with X or Y axis. Only obvious when checking the radius value using Python, and it gives 2 values. Very interesting. I found this blog post that kind of talks a bit about the radius weight for skin vertices: michelanders.blogspot.com.au/p/… I will soon post this in my blog. $\endgroup$ Commented Jul 3, 2013 at 1:21
  • 3
    $\begingroup$ @BlenderSushiGuy to let others know that this answer satisfies your question please log in with your other account and accept it. I recommend that you stop using two usernames, it's extra work in the long run. $\endgroup$
    – zeffii
    Commented Jul 3, 2013 at 5:23
  • 1
    $\begingroup$ I first thought skin_vertices will contain data for each skin modifier (in case there are more than one), but it always has one element corresponding to first-added skin modifier! BTW great finding! $\endgroup$
    – mg007
    Commented Aug 2, 2013 at 18:36
  • $\begingroup$ note if you get an error, when trying to access or set skin weights, you need to first initialize at least one skin modifier either with code or using the UI $\endgroup$
    – Gorgious
    Commented Jun 21, 2021 at 12:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .