I have just started to teach myself Python in Blender 2.5
So hopefully this is an easy question to answer
I am using the Pantin Rig and trying to Hide different body parts with the “restrict_view”
and add this to a button that lives on the Properties Tab in the 3D view (n)
I have got this working but I can only make one object disappear with one button
this is fine for some sections of the rig but other parts are made up of more than one mesh object (eg. the Head, Neck, eyes, eylids etc)
The Way I have done it is by creating a varibale
HeadMesh = bpy.context.scene.objects['Head']
this grabs the object called “Head” and then I call it later and add it to a column button
This works, as I said, but I cannot figure out how to get the variable HeadMesh to include more that one object
This also may be a silly way of doing it - but hey, I’ve only been learning Python for a day
Can somebody help me out with calling multiple objects and changing a value on all of them?
#This class draws the Panel in the 3D view (the n properties)
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_label = "Visibility"
def poll(self, context):
ob = context.active_object
return (ob.name == "the_name_of_your_Object")
#this draws the layout and puts the operator in it
def draw(self, context):
layout = self.layout
col = layout.column()
row = col.row(align=True)
def is_selected(context, names):
for name in names:
if context.active_pose_bone.name == name:
for bone in context.selected_pose_bones:
for name in names:
if bone.name == name:
#This operator toggles the visibility property of all the Meshes in the list of objects
bl_label = "Parts"
bl_idname = "vsb_Parts"
def invoke(self, context, event):
for mesh in ['obj_1', 'obj_2','obj_3']:
bpy.data.objects[mesh].restrict_view = not(bpy.data.objects[mesh].restrict_view)
bpy.data.objects[mesh].restrict_render = not(bpy.data.objects[mesh].restrict_render)
What is it good for you ask?
well if you have a character rig that you want the hide different body parts you can
(just as long as the body parts are separate objects you can easily toggle them on and off out of the way
It could also be adapted to toggle/change or display other properties in the side panel