Adding new body measures
This page explains how to modify and add measurments definitions for bodies.
The code behind measurements is in costumy/measurer
Currently the measures are based on Freesewing measurements.
There is just enough for the Aaron Freesewing Design.
Adding measurements definitions
To add measurement definitions, follow the steps below.
- Open or create a json file from
costumy/data/measurements_definitions
-
Add a new key (name of the measurment) in the measure dict
"measures":{ "MyNewMeasure":{} }
-
Choose a measurment method and fill in the keys/values.
"measures":{ "MyNewMeasure":{ "method":"length", "vertices":[0,10,22] } }
-
Save your modification.
Fancy JSON schema
The JSON schemas costumy/data/schemas/measurements_definitions.json
defines the values you can use in the measurement definitions jsons.
If your IDE supports it (Visual Studio Code does), you should have some auto completion and definitions when hovering. see VSCode JSON schema
Finding vertices index
Measurements relies on the model vertices index. To find them you can use blender (the software) :
- Add the body in blender (you can use
costumy.body.as_obj
) - Enable Edit mode while having the mesh selected
- Enable the Indice overlay
- Switch to vertice selection
- You can now see the vertices index
Selecting vertex by index
You can use this small snippet within blender to select specific indices:
import bpy
index = [] #list of vertices index
obj = bpy.context.object
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')
bpy.ops.object.mode_set(mode='OBJECT')
for i in index :
obj.data.vertices[i].select = True
bpy.ops.object.mode_set(mode='EDIT')