I was pretty happy when I got the object to move from one side to another. The purpose is to create an action that mimics the offset filter in Photoshop to help in the creation of seamless textures with 3d objects. I'm trying to automate some things I do manually. Anyways when I try to add the code to a menu it doesn't like my function. In the python console if I were to type my function name, the code works so I'm not sure what to do. Any help would be great. I'm probably using the wrong syntax. The menu works. If I execute it the menu appears with the cube. When I add my function to the menu I get an error. Any help would be great. I posted this already in the blender forums, but not sure if I'll get a response. If anyone here can help that be great. Thanks.
Alex
here is the code:
import bpy
import mathutils
import bpy.utils
#functions moves and object from it's current position to the opposite side...
def offsetPosX():
bpy.context.object.location[0] = bpy.context.object.location[0]*-1
def offsetPosZ():
bpy.context.object.location[1] = bpy.context.object.location[1]*-1
def offsetPosY():
bpy.context.object.location[2] = bpy.context.object.location[2]*-1
ob_offX = offsetPosX()
class customMenu(bpy.types.Menu):
bl_label = "My Game Tools"
bl_idname = "view3D.custom_menu"
def draw(self, context):
layout = self.layout
layout.operator("mesh.primitive_cube_add")
layout.operator(ob_offX, text = "offsetx")
def register():
bpy.utils.register_class(customMenu)
bpy.ops.wm.call_menu(name=customMenu.bl_idname)
def unregister():
bpy.utils.unregister_class(customMenu)
if __name__ == "__main__":
register()
Replies
Alex
If you take this any further, I'm sure there are a few people who'd be interested in this!
things I want to add.
xray mode with a slider that controls the opacity of the object. Basically have all the controls in one spot and a way to tint the color.
set the grid to a specific size. I was going to hard code it to a power of 2. I did this in max and was rather easy. so the values would be 2, 4, 16, etc and then have a plus minus that multiplies or divides the value so it's a power of 2.
have some modifiers there... that trivial to add though... Modifiers I use often are Solidify, subd, mirror...
there is a B_max script for blender that adds a bunch of cool tools from 3ds max there...
Good point, and lesson learned.
new code: