Hello! Please excuse my bad english … I’ve got a problem with my python script…
First I create a circle, make some changes to the location and so one and give them some materials in the node editor.
Then I append a group, make some changes to the location and try to give them some materials in the node editor too.
BUT heres my problem … every change in the node editor is given to the circle and not to the group … I can change the location of the group but after that its like the group is not the active object and so my circle get all the commands for the node editor … here you can see the part of my script:
First part … the circle:
bpy.ops.mesh.primitive_circle_add(vertices = a, fill_type = 'NGON')
i = 0
while (i < a):
y = -1*( listx[i+1])
x = listy[i+1]
context=bpy.context
for obj in context.selected_objects:
obj.location = (0,0,0)
if obj.type=='MESH':
for v in obj.data.vertices[i:(i+1)]:
v.co = x,y,z
i = i +1
for obj in context.selected_objects:
#bpy.ops.object.mode_set(mode='EDIT')
#bpy.ops.uv.smart_project()
#bpy.ops.object.mode_set(mode='OBJECT')
obj.data.materials.append(materialfloor)
obj.rotation_euler[0]=RotationUmX*0.0174533
obj.rotation_euler[2]=RotationUmZ*0.0174533
obj.location=(PositionX,PositionY,PositionZ)
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.uv.unwrap(method='ANGLE_BASED', margin=0.001)
bpy.context.area.type = 'NODE_EDITOR'
bpy.context.object.active_material.use_nodes = True
bpy.context.scene.use_nodes = True
tree = bpy.context.object.active_material.node_tree
links = tree.links
for n in tree.nodes:
tree.nodes.remove(n)
...
second part … the group:
bpy.ops.wm.link_append(link = False, instance_groups = False, filepath="...", filename="...", directory="...")
context = bpy.context
for obj in context.selected_objects:
obj.location = (x,y,z)
obj.rotation_euler[0] = RotX*0.0174533
obj.rotation_euler[1] = RotY*0.0174533
obj.rotation_euler[2] = RotZ*0.0174533
bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.uv.unwrap(method='ANGLE_BASED', margin=0.001)
bpy.context.area.type = 'NODE_EDITOR'
bpy.context.object.active_material.use_nodes = True
bpy.context.scene.use_nodes = True
tree = bpy.context.object.active_material.node_tree
links = tree.links
for n in tree.nodes:
tree.nodes.remove(n)
...
Hope anybody can help me … Thanks a lot!