Fuel

v0.1

Note

This is an alpha version.

About

Fuel is a Blender library for rapid developing. All methods are designed as idiomatic minimum components to understand a Blender API system quickly. Any suggestons to make this library more pragmatic and useful are always welcomed.

How to Install Fuel

TODO

Index

Base

override_context(area_name)

Make a specific context and return it.

Parameters:area_namestr (VIEW_3D, TIMELINE, GRAPH_EDITOR, DOPESHEET_EDITOR, NLA_EDITOR, IMAGE_EDITOR, SEQUENCE_EDITOR, CLIP_EDITOR, TEXT_EDITOR, NODE_EDITOR, LOGIC_EDITOR, PROPERTIES, OUTLINER, USER_PREFERENCES, INFO, FILE_BROWSER, CONSOLE)
Return type:bpy_types.Context

Print a text to the console window.

Parameters:txtstr
get_region_window_size_context()

Get width and height of window in the context.

Return type:int, int
get_viewport_loc_context()

Get a location of viewport camera in the context.

Return type:Vector or NoneType
get_viewports_loc(screen_name)

Get locations of all viewport cameras in a screen.

Parameters:screen_namestr (ex. 3D View Full, Animation, Compositing, Default, Game Logic, Motion Tracking, Scripting, UV Editing, Video Editing)
Return type:List of Vector or NoneType
get_area_context()

Get an area in the context.

Return type:bpy.types.Area
get_areas_context()

Get all areas of screen in the context.

Return type:bpy_prop_collection of bpy.types.Area
get_screen_name_context()

Get a screen name in the context.

Return type:str
get_screen(screen_name)

Get a screen.

Parameters:screen_namestr
Return type:bpy.types.Screen
get_areas(screen_name)

Get all areas in a screen.

Parameters:screen_namestr (ex. 3D View Full, Animation, Compositing, Default, Game Logic, Motion Tracking, Scripting, UV Editing, Video Editing)
Return type:bpy_prop_collection of bpy.types.Area
get_area(screen_name, area_name)

Get an area in a screen.

Parameters:
  • screen_namestr (ex. 3D View Full, Animation, Compositing, Default, Game Logic, Motion Tracking, Scripting, UV Editing, Video Editing)
  • area_namestr (VIEW_3D, TIMELINE, GRAPH_EDITOR, DOPESHEET_EDITOR, NLA_EDITOR, IMAGE_EDITOR, SEQUENCE_EDITOR, CLIP_EDITOR, TEXT_EDITOR, NODE_EDITOR, LOGIC_EDITOR, PROPERTIES, OUTLINER, USER_PREFERENCES, INFO, FILE_BROWSER, CONSOLE)
Return type:

bpy.types.Area or NoneType

get_view3d_space_context()

Get space of VIEW_3D in the context.

Return type:bpy_prop_collection of bpy.types.SpaceView3D or NoneType
get_space(area_name, screen_name)

Get a specific area’s space in a screen.

Parameters:
  • area_namestr (VIEW_3D, TIMELINE, GRAPH_EDITOR, DOPESHEET_EDITOR, NLA_EDITOR, IMAGE_EDITOR, SEQUENCE_EDITOR, CLIP_EDITOR, TEXT_EDITOR, NODE_EDITOR, LOGIC_EDITOR, PROPERTIES, OUTLINER, USER_PREFERENCES, INFO, FILE_BROWSER, CONSOLE)
  • screen_namestr (ex. 3D View Full, Animation, Compositing, Default, Game Logic, Motion Tracking, Scripting, UV Editing, Video Editing)
get_space_context(area_name)

Get a specific area’s space in the current screen.

Parameters:area_namestr (VIEW_3D, TIMELINE, GRAPH_EDITOR, DOPESHEET_EDITOR, NLA_EDITOR, IMAGE_EDITOR, SEQUENCE_EDITOR, CLIP_EDITOR, TEXT_EDITOR, NODE_EDITOR, LOGIC_EDITOR, PROPERTIES, OUTLINER, USER_PREFERENCES, INFO, FILE_BROWSER, CONSOLE)
get_view3d_space(screen_name)

Get space of VIEW_3D in a screen.

Parameters:screen_namestr (ex. 3D View Full, Animation, Compositing, Default, Game Logic, Motion Tracking, Scripting, UV Editing, Video Editing)
Note:if spaces have VIEW_3D, bpy_prop_collection contains CONSOLE at last.
Return type:bpy_prop_collection of bpy.types.SpaceView3D or NoneType
get_regions(area_name, screen_name)

Get regions in a specific area and screen.

Parameters:
  • area_namestr (VIEW_3D, TIMELINE, GRAPH_EDITOR, DOPESHEET_EDITOR, NLA_EDITOR, IMAGE_EDITOR, SEQUENCE_EDITOR, CLIP_EDITOR, TEXT_EDITOR, NODE_EDITOR, LOGIC_EDITOR, PROPERTIES, OUTLINER, USER_PREFERENCES, INFO, FILE_BROWSER, CONSOLE)
  • screen_namestr (ex. 3D View Full, Animation, Compositing, Default, Game Logic, Motion Tracking, Scripting, UV Editing, Video Editing)
get_regions_context(area_name)

Get regions in a specific area of the current screen.

Parameters:area_namestr (VIEW_3D, TIMELINE, GRAPH_EDITOR, DOPESHEET_EDITOR, NLA_EDITOR, IMAGE_EDITOR, SEQUENCE_EDITOR, CLIP_EDITOR, TEXT_EDITOR, NODE_EDITOR, LOGIC_EDITOR, PROPERTIES, OUTLINER, USER_PREFERENCES, INFO, FILE_BROWSER, CONSOLE)
get_view3d_regions_context()

Get regions of VIEW_3D in the context. Types of regions are HEADER, TOOLS, TOOL_PROPS, UI, WINDOW.

Return type:bpy_prop_collection of bpy.types.Region or NoneType
get_view3d_regions(screen_name)

Get regions of VIEW_3D in a screen. Types of regions are HEADER, TOOLS, TOOL_PROPS, UI, WINDOW.

Parameters:screen_namestr (ex. 3D View Full, Animation, Compositing, Default, Game Logic, Motion Tracking, Scripting, UV Editing, Video Editing)
Return type:bpy_prop_collection of bpy.types.Region or NoneType
get_rv3d_context()

Get region_3d(rv3d) of VIEW_3D in the context.

Return type:RegionView3D or NoneType
get_rv3d(screen_name)

Get region_3d(rv3d) of VIEW_3D in the context.

Parameters:screen_namestr (ex. 3D View Full, Animation, Compositing, Default, Game Logic, Motion Tracking, Scripting, UV Editing, Video Editing)
Return type:RegionView3D or NoneType
get_addon_prefs()

Get an object of Addon Preferences.

Returns:An object which contains values in AddonPreferences if it has values.
get_keymap_item(km, kmi_idname)

Get a keymap item.

Parameters:
  • kmbpy.types.KeyMap
  • kmi_idnamestr
Return type:

bpy.types.KeyMapItem or NoneType

Object

get_active_object()

Get an active object.

Return type:bpy_types.Object or NoneType
get_visible_objects()

Get visible objects.

Return type:list of bpy_types.Object or NoneType
get_objects()

Get all objects.

Return type:list of bpy_types.Object or NoneType
get_selected_objects()

Get selected objects.

Return type:list of bpy_types.Object or NoneType
move_origin(ob, new_origin)

Move a location of origin.

Parameters:
  • obbpy_types.Object
  • new_originVector
pivot_ob_around_vec(ob, v_origin, v_target, degrees)

Move an object around a vector.

Parameters:
  • obbpy_types.Object
  • v_originVector
  • v_targetVector
  • degreesfloat
class at

Pivot object at a specific center.

Method:

__init__(self, ob, center_pos)

Initialization.

self:self
ob:bpy_types.Object
center_pos:Vector
Method:

rotate(self, euler)

Rotation.

self:self
euler:Euler
Method:

move(self. dst_pos)

Move to dst_pos from center_pos.

self:self
dst_pos:Vector
apply_all_modifiers()

Apply all modifiers to selected objects.

force_edit_mode()

Change to Edit Mode.

force_object_mode()

Change to Object Mode.

force_sculpt_mode()

Change to Sculpt Mode.

force_vertex_paint_mode()

Change to Vertex Paint Mode.

force_weight_paint_mode()

Change to Weight Paint Mode.

force_texture_paint_mode()

Change to Texture Paint Mode.

toggle_object()

Toggle a current mode.

get_modifier_items(ob)

Get all modifier items of an object.

Parameters:obbpy_types.Object

Mesh

setup_bvh(bmesh)

Set up a bvh tree.

Parameters:bmeshBMesh
Return type:BVHTree
make_bmesh(ob)

Make bmesh.

Parameters:obbpy_types.Object
Return type:BMesh
make_bmesh_from_objects(obs_list)

Make bmeshs from objects with matrixes.

Parameters:obs_listlist of bpy_types.Object
Return type:BMesh, (Matrix, (int(num of verts), int(num of edges) int(num of faces), int(num of loops)))
apply_bmesh(bm, ob)

Apply a bmesh to an object. Then delete the bmesh.

Parameters:
  • bmBMesh
  • obbpy_types.Object
make_edit_bmesh()

Make a bmesh from an object in Edit Mode.

Return type:BMesh
update_edit_bmesh()

Apply a bmesh to an object in Edit Mode.

get_selected_verts(ob)

Get selected vertices.

Note:If you need to get selected vertices in Edit Mode which means realtime selection, use bmesh.
Parameters:obbpy_types.Object
Return type:bpy_prop_collection of bpy.types.MeshVertex or NoneType
get_verts_from_object(ob)

Get all vertices from an object.

Parameters:obbpy_types.Object
Return type:list of bpy_types.MeshVertex or NoneType
get_edges_from_object(ob)

Get all edges from an object.

Parameters:obbpy_types.Object
Return type:list of bpy_types.MeshEdge or NoneType
get_faces_from_object(ob)

Get all faces from an object.

Parameters:obbpy_types.Object
Return type:list of bpy_types.MeshPolygon or NoneType
get_all_edges_lco_from_object(ob)

Get all edges local coordinates from object.

Parameters:obbpy_types.Object
Return type:list of 2 length tuple of Vector or NoneType
get_edge_keys_from_face(face)

Get all edge keys from a face.

Parameters:facebpy_types.MeshPolygon
Return type:2 length tuple of int
get_edge_from_edge_key(ob, edge_key)

Get an edge from an edge key.

Parameters:
  • obbpy_types.Object
  • edge_key2 length tuple of int
Return type:

bpy_types.MeshEdge or NoneType

get_verts_from_edge_key(ob, edge_key)

Get vertices from an edge key.

Parameters:
  • obbpy_types.Object
  • edge_key2 length tuple of int
Return type:

2 length tuple of bpy_types.MeshVertex or NoneType

get_verts_from_face(ob, face)

Get all vertices from a face.

Parameters:
  • obbpy_types.Object
  • facebpy_types.MeshPolygon
Return type:

list of bpy_types.MeshVertex

get_verts_from_edge(ob, edge)

Get all vertices from an edge.

Parameters:
  • obbpy_types.Object
  • edgebpy_types.MeshEdge
Return type:

list of bpy_types.MeshVertex

get_normal_from_face(face)

Get a normal from a face.

Parameters:facebpy_types.MeshPolygon
Return type:Vector
get_bound_edge_keys_from_faces(faces)

Get bound edges.

Parameters:faceslist of bpy_types.MeshPolygon
Return type:list of bpy_types.MeshEdge or NoneType
get_bedges_from_bvert(bvert)

Get edges link to a vertex in a bmesh.

Parameters:bvertBMVert
Return type:BMElemSeq of BMEdge
get_bfaces_from_bvert(bvert)

Get faces link to a vertex in a bmesh.

Parameters:bvertBMVert
Return type:BMElemSeq of BMFace
get_bfaces_from_bedge(bedge)

Get faces link to an edge in a bmesh.

Parameters:bedgeBMEdge
Return type:BMElemSeq of BMFace
edge_intersect(ob, edge_ob, edge)

Check an edge intersects a face of an object.

Parameters:
  • obbpy_types.Object
  • edge_obbpy_types.Object
  • edgebpy_types.MeshEdge
Return type:

Vector``(location), ``Vector``(normal), ``int``(face_index) or` ``NoneType, NoneType, NoneType

get_center_wco(ob)

Get a center location of an object in the world space.

Parameters:obbpy_types.Object
Return type:Vector

Math

Note

If you want to use radian based trigonometric function, use defalut math module.

vec_distance(org, dst)

Get a distance of two points.

Parameters:
  • orgVector
  • dstVector
Return type:

float

make_quat(axis_vec, degrees)

Make a quaternion to rotate around an axis vector.

Parameters:
  • axis_vecVector
  • degreesint or float
Return type:

Quaternion

dot(vec1, vec2)

Dot function.

Parameters:
  • vec1Vector
  • vec2Vector
Return type:

Vector

cross(vec1, vec2)

Cross function. The order is vec1 X vec2.

Parameters:
  • vec1Vector
  • vec2Vector
Return type:

Vector

sin(degrees)

sine function.

Parameters:degreesint or float
Return type:float
cos(degrees)

cosine function.

Parameters:degreesint or float
Return type:float
tan(degrees)

tangent function.

Parameters:degreesint or float
Return type:float
asin(ratio)

arc sine function.

Parameters:ratioint or float
Return type:float
acos(ratio)

arc cosine function.

Parameters:ratioint or float
Return type:float
atan(ratio)

arc tangent function.

Parameters:ratioint or float
Return type:float
pivotx(vec, degrees)

pivot a vector around x axis.

Parameters:
  • vecVector
  • degreesint or float
Return type:

Vector

pivoty(vec, degrees)

pivot a vector around y axis.

Parameters:
  • vecVector
  • degreesint or float
Return type:

Vector

pivotz(vec, degrees)

pivot a vector around z axis.

Parameters:
  • vecVector
  • degreesint or float
Return type:

Vector

pivot_around_vec(vec, axis_vec_origin, axis_vec_target, degrees)

pivot around a given axis vector.

Parameters:
  • vecVector
  • axis_vec_originVector
  • axis_vec_targetVector
  • degreesint or float
Return type:

Vector

get_lookat_matrix(direction_vec, origin_vec, up_vec = (0, 0, 1))

Get a lookat matrix.

Parameters:
  • direction_vecVector
  • origin_vecVector
  • up_vecVector
Return type:

Matrix

OpenGL

Draw Primitive

draw_line(start, end, cl = (0, 0, 0, 1) width = 1.0)

Draw a line.

Parameters:
  • start3 length tuple of int or float, or Vector
  • end3 length tuple of int or float, or Vector
  • cl4 length tuple. The range is (0, 0, 0, 0) to (255, 255, 255, 1)
  • widthint or float
draw_line_strip(verts, cl = (0, 0, 0, 1), width = 1.0)

Draw a line strip.

Parameters:
  • vertslist of 3 length tuple of int or float, or Vector
  • cl4 length tuple. The range is (0, 0, 0, 0) to (255, 255, 255, 1)
  • widthint or float
draw_line_loop(verts, cl = (0, 0, 0, 1), width = 1.0)

Draw a line loop.

Parameters:
  • vertslist of 3 length tuple of int or float, or list of Vector
  • cl4 length tuple. The range is (0, 0, 0, 0) to (255, 255, 255, 1)
  • widthint or float
draw_triangle(triangle, cl = (0, 0, 0, 1), width = 1.0)

Draw a triangle.

Parameters:
  • triangle3 length list of 3 length tuple of int or float, or 3 length list of Vector
  • cl4 length tuple. The range is (0, 0, 0, 0) to (255, 255, 255, 1)
  • widthint or float
draw_triangles(triangle, cl = (0, 0, 0, 1), width = 1.0)

Draw a triangle.

Parameters:
  • trianglelist of 3 length list of 3 length tuple of int or float, or list of 3 length list of Vector
  • cl4 length tuple. The range is (0, 0, 0, 0) to (255, 255, 255, 1)
  • widthint or float
draw_triangle_strip(triangle_strip, cl = (0, 0, 0, 1), width = 1.0)

Draw a triangle strip.

Parameters:
  • triangle_striplist of 3 length tuple of int or float, or list of Vector
  • cl4 length tuple. The range is (0, 0, 0, 0) to (255, 255, 255, 1)
  • widthint or float
draw_triangle_fan(start_vert, other_verts, cl = (0, 0, 0, 1), width = 1.0)

Draw a triangle fan.

Parameters:
  • start_vert3 length list of int or float, or Vector.
  • other_vertslist of 3 length tuple of int or float, or list of Vector
  • cl4 length tuple. The range is (0, 0, 0, 0) to (255, 255, 255, 1)
  • widthint or float
draw_quad(quad, cl = (0, 0, 0, 1), width = 1.0)

Draw a quad.

Parameters:
  • quad4 length list of 3 length tuple of int or float, or 4 length list of Vector
  • cl4 length tuple. The range is (0, 0, 0, 0) to (255, 255, 255, 1)
  • widthint or float
draw_quads(quads, cl = (0, 0, 0, 1), width = 1.0)

Draw quads.

Parameters:
  • quadslist of 4 length list of 3 length tuple of int or float, or list of 4 length list of Vector
  • cl4 length tuple. The range is (0, 0, 0, 0) to (255, 255, 255, 1)
  • widthint or float
draw_quad_strip(vertical_edges, cl = (0, 0, 0, 1), width = 1.0)

Draw a quad strip.

Parameters:
  • vertical_edgeslist of 2 length list of 3 length list of int or float, or list of 2 length list of Vector
  • cl4 length tuple. The range is (0, 0, 0, 0) to (255, 255, 255, 1)
  • widthint or float
draw_polygon(polygon, cl = (0, 0, 0, 1), width = 1.0)

Draw a polygon.

Parameters:
  • polygonlist of 3 length tuple of int or float, or list of Vector
  • cl4 length tuple. The range is (0, 0, 0, 0) to (255, 255, 255, 1)
  • widthint or float
draw_circle_2d(origin, radius, points, cl = (0, 9, 0, 1))

Draw a 2D circle.

Parameters:
  • origin2 length list of int or float
  • radiusint or float
  • pointsint
  • cl4 length tuple. The range is (0, 0, 0, 0) to (255, 255, 255, 1)
  • widthint or float
draw_quad_2d(quad2d, cl = (0, 0, 0, 1), width = 1.0)

Draw a 2D quad.

Parameters:
  • quad2d4 length list of 2 length tuple of int or float
  • cl4 length tuple. The range is (0, 0, 0, 0) to (255, 255, 255, 1)
  • widthint or float
draw_rect_2d_1(top_left, bottom_right, cl = (0, 0, 0, 1), width = 1.0)

Draw a rectangle.

Parameters:
  • top_left2 length tuple of int or float
  • bottom_right2 length tuple of int or float
  • cl4 length tuple. The range is (0, 0, 0, 0) to (255, 255, 255, 1)
  • widthint or float
draw_rect_2d_2(center, rect_width, rect_height, cl = (0, 0, 0, 1), width = 1.0)

Draw a rectangle.

Parameters:
  • center2 length tuple of int or float
  • rect_widthint or float
  • rect_heightint or float
  • cl4 length tuple. The range is (0, 0, 0, 0) to (255, 255, 255, 1)
  • widthint or float

Base Utility

rect_range_check_2d(args)

Check a cursor in a rectangle.

Parameters:
  • args2 length tuple (cursor location), 2 length tuple (top left), 2 length tuple (bottom right)
  • args2 length tuple (cursor location), 2 length tuple (center location), int (width), int (height)
Return type:

bool

Developers

kozmof