This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
vgroup_A_name = "Group" | |
vgroup_B_name = "Group.001" | |
ob = bpy.context.active_object | |
if vgroup_A_name and vgroup_B_name in ob.vertex_groups: | |
vgroup = ob.vertex_groups.new(name=vgroup_A_name+"+"+vgroup_B_name) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
group_input = {"Group", "Group.001", "Group.002"} | |
ob = bpy.context.active_object | |
group_lookup = {g.index: g.name for g in ob.vertex_groups} | |
group_candidates = {n for n in group_lookup.values() if n in group_input} | |
# test whether all candidates components of group_lookup | |
if all(n in group_lookup.values() for n in group_candidates): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -> For a Blender 2.8+ version, go to https://gist.github.com/p2or/2947b1aa89141caae182526a8fc2bc5a | |
# https://blender.stackexchange.com/q/57306/3710, https://blender.stackexchange.com/q/79779/3710 | |
# ##### BEGIN GPL LICENSE BLOCK ##### | |
# | |
# This program is free software; you can redistribute it and/or | |
# modify it under the terms of the GNU General Public License | |
# as published by the Free Software Foundation; either version 2 | |
# of the License, or (at your option) any later version. | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addLeadingZeros (n, length){ | |
var str = (n > 0 ? n : -n) + ""; | |
var zeros = ""; | |
for (var i = length - str.length; i > 0; i--) | |
zeros += "0"; | |
zeros += str; | |
return n >= 0 ? zeros : "-" + zeros; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://blender.stackexchange.com/q/76655/31447 | |
import bpy | |
import subprocess | |
import os | |
bpy.ops.mesh.primitive_cube_add(radius=1) | |
bashfile = '/home/.../hello-world.sh' | |
os.chmod(bashfile, 0o777) # http://stackoverflow.com/a/1837896 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://blender.stackexchange.com/q/75310/3710 | |
import bpy | |
# select all mesh objects | |
for o in bpy.data.objects: | |
if o.type == 'MESH': | |
o.select = True | |
else: | |
o.select = False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for http://blender.stackexchange.com/q/74766/3710 | |
import bpy | |
def opengl_lamp_display(column, lamp): | |
split = column.split(percentage=0.1) | |
split.prop(lamp, "use", text="", icon='OUTLINER_OB_LAMP' if lamp.use else 'LAMP_DATA') | |
col = split.column() | |
col.active = lamp.use |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
ctx = bpy.context | |
active_obj = ctx.active_object | |
selection = [o for o in ctx.selected_objects if o != active_obj] | |
for o in selection: | |
if o.type == active_obj.type: | |
active_obj.data = o.data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
# --------------------------------------------------- | |
# Collection | |
# --------------------------------------------------- | |
class MyCollectionProperty(bpy.types.PropertyGroup): | |
id = bpy.props.IntProperty() | |
name = bpy.props.StringProperty(name="Test Prop", default="Unknown") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ##### BEGIN GPL LICENSE BLOCK ##### | |
# | |
# This program is free software; you can redistribute it and/or | |
# modify it under the terms of the GNU General Public License | |
# as published by the Free Software Foundation; either version 2 | |
# of the License, or (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |