# Change nodes position through scripts [duplicate]

I'm Creating some nodes through python script. The problem is that all the nodes are overlapping each over. I just wanna programatically re position those nodes. How to do this?

 imgtx1 = nodes.new('ShaderNodeTexImage')


Just consider these 2 nodes as of now. Thanks in advance!

Every node has it's own size/location properties that are accessible in the node itself.

import bpy
from mathutils import Vector

#location
imgtx1.location = Vector((200.0, 400.0))

#or
imgtx2.location.x = 100
imgtx2.location.y = 200

#size
# only width changes are allowed within the values of
# node.bl_width_min and node.bl_width_max
imgtx2.width = 200
imgtx2.width_hidden = 100

• This is really helpful! Thanks a lot! @Secrop – youhsia May 18 '19 at 11:21
• If I use newmat.location = Vector(500,100) I get NameError: name 'Vector' is not defined. newmat.location.x = -200 works though. – edna Jun 18 '19 at 5:11
• @edna, you need to import mathutils... I'll correct the answer. – Secrop Jun 20 '19 at 7:58
• Thanks for updating. In 2.80 I found that I don't need it actually. imgtx2.location = -300, 150 works fine. – edna Jun 21 '19 at 4:50