how do you specified to move an object to a specific layer
do you have to specify all the layers like
[FONT=ArialMT][SIZE=2]layer=[True]+[False]*31
or is there another shorter way to say like moe it to layer 2?
Thanks
[/SIZE][/FONT]
how do you specified to move an object to a specific layer
do you have to specify all the layers like
[FONT=ArialMT][SIZE=2]layer=[True]+[False]*31
or is there another shorter way to say like moe it to layer 2?
Thanks
[/SIZE][/FONT]
wouldnt it be easy to just write a small function ? something like:
def layer_move(obj, target):
[layer = False for layer in obj.layers] #remove object from all layers
obj.layers[target] = True #set the layer
i think i found it but not tested yet
layers = 32*[False]
layers[0] = True
so just change layer number and uit should be come true i guess
########################################################
sorry did not mention i’m using a primitive plane and cube
there must be an easier way to spec the layer where we want it to be
instead of all the layers except one!
but could also be applied to object in general
but there is a bpy.ops command to move and object to first or may be the active layer in viewport layer
bpy.ops.object.add_named( linked=False, name=“lamptypic1”
Thanks
thats not working either because the object has to be on at least one layer.
it should be:
bpy.context.object = (i-1)*[False]+[True]+(20-i)*[False]
The last UV is added on first layer = 1
so the method is working
but your might also be another way to spec it
import mathutils
from math import *
from bpy.props import *
import bpy
###############
# Add a Plane at each face
origin=(2,3,0)
ob1=bpy.ops.mesh.primitive_plane_add(location=origin )
bpy.context.active_object.scale=(0.5,0.5,0)
#bpy.context.active_object.location=(locx,locy,0)
xrnd1=0
yrnd1=0
zrnd1=0
layers =20*[False]
layers[1] = True
#myCubeMesh =bpy.ops.mesh.primitive_cube_add(view_align=False, enter_editmode=False, location=(xrnd1, yrnd1, zrnd1), layers=layers)
myCubeMesh =bpy.ops.mesh.primitive_cube_add(view_align=False, enter_editmode=False, location=(xrnd1, yrnd1, zrnd1))
#myCubeMesh =bpy.ops.mesh.primitive_cube_add(view_align=False, enter_editmode=False, location=(xrnd1, yrnd1, zrnd1), layers=[True]+[False]*19)
# Mesh opertors
# http://www.blender.org/documentation/250PythonDoc/bpy.ops.mesh.html#bpy.ops.mesh.primitive_cube_add
seg1=48 # Segments
ring1=36 # Rings
xloc=2.0
yloc=1.2
zloc=3.0
cvf=pi/180
rotx=45*cvf # Angle given in degrees around global X axis
# and converted to Radians
roty=0*cvf
rotz=0*cvf
bpy.ops.mesh.primitive_uv_sphere_add(segments=seg1, ring_count=ring1, size=1, view_align=False, enter_editmode=False, location=(xloc, yloc, zloc), rotation=(rotx, roty, rotz), layers=[True]+[False]*19)
bpy.ops.mesh.primitive_uv_sphere_add(segments=seg1, ring_count=ring1, size=1, view_align=False, enter_editmode=False, location=(xloc+2, yloc+2, zloc), rotation=(rotx, roty, rotz),layers=layers)
There is also a specific object command to change layer and even one to move to another layer
but not really used theses before !
THanks and happy 2.5