I can’t find the answer to how to select an existing node through the script and apply the already added image without a GUI.  I have a ready-made script that opens a prepared blender file with saved materials, makes an import of the SVG curve and performs manipulations by adding these materials.   In one of the materials I need to change one picture. I found a code that can add a node with a new picture  import bpy bpy.data.images.load("D:/temp/1.png", check_existing=True) mat = bpy.context.view_layer.objects.active.active_material tex = bpy.data.images.get('1.png') image_node = mat.node_tree.nodes.new('ShaderNodeTexImage') image_node.image = tex   This code created a new unconnected node and it needs to be connected to three other nodes. But I need only assign an already linked picture to the already connected node.
122805
I am trying to assign an image texture to an Image Texture node in 2.80. Very simple script - I'm just starting to learn how this stuff works.  This is what I have. It creates an image and and IT node, but it doesn't assign the one to other. Can anybody help? I've searched around, but can't find it in another question.  import bpy  #create blank image bpy.ops.image.new(name="TestImg", width=1024, height=1024)  #add image texture to object, to hold baked lighting mat = bpy.context.view_layer.objects.active.active_material image_node = mat.node_tree.nodes.new('ShaderNodeTexImage')  #assign image to image texture node image_node.image = "TestImg"   Thanks in advance.
57128
The title says it all, I want to know what the simplest way to export the selected objects.  In Inkscape, there is a menu option called export selected which does just this.    The aforementioned option lets you export the selection as a composite image or as a batch of individual images.  Both would be nice, but in this scenario I want to export the selected objects as a single image.  I can already create a new document, and paste in the selected items.  I am looking for a way that is easier than this.  How can I save / output / export only the objects I currently have selected, to an image file, in Adobe Illustrator CS5?
91836
I want to know how to create a menu with previews for an add-on. Until now I know that this is related with the bpy.utils.preview. I'm making an add-on that appends objects from a .blend file, I know how to append objects but what I want to do is to create a menu with previews of the objects /(similar to the matcaps menu - see below), select them and then press an &quot;import button&quot; to append the object. Here's some documentation about the module:    Also, as this is an add-on I don't know if I should have a def register() and a def unregister() inside this .py file as well as in the __init__.py file.
115666
There's any way to change it directly by Python, or there's any way to set by Python what node image is the active to display in viewport (Textured) and bake?
109115
I am trying to create a material node group for triplanar mapping, but I am not sure how I can parameterize the image texture name.   I have 3 image texture nodes, which all use the same file with the same settings, the only difference is the vector input.  Is there a way I can make it so that I only have to select the texture name once, possibly as a input for a group?
45570
I'm working on a Unity's Project and I want to modify a prefab, more precisely I want to change the texture of a prefab. The problem is that my modification is applied also to other prefabs. I read on the documentation how each of the buttons labeled Select, Revert and Apply works, and what I understood is that the modification should update only the selected prefab.  Here is the  which I read.  What am I missing?  PS: I'm not the author of the project, I have to apply some modifications only.
1283
Is there a way to use the Blender Text Editor for adding a custom menu and not get a duplicate every time I click on "Run Script" to test the menu? For example, in the text editor, load the template like so:  Template -> Python -> UI Menu  Then notice every time you press "Run Script" you get another menu in your main menu bar. How can I update my menu without getting a duplicate?  I tried simply commenting out register() but then new updates don't show up.
73696
How can I get a Node input/output (e.g. a single Color/Value) that I can control from the one spot, but have mapped across multiple materials? For example, to control a value (say, Glass Shader IOF, or a Mix Shader Fac) across 30 different materials (that may or may not have different node setups, but all use the input I want as a driving factor somewhere inside). I've got a few ideas so far, but am not sure which will work and/or which will be the best way to go about it:  Use a Node Group I tried setting up an input inside a node group, then using the node group in various locations - however I could only seem to automate/keyframe the 'default' values of things inside the group (these changes didn't flow through into the instances of the group).  Script node I could set up a Script Node that returns the value I want - however I imagine this would be tricky to automate, and it would also lock me into OSL, which feels a bit roundabout and also rules out GPU rendering (not essential but it would be nice)  Driver I could set up a dummy object or material, set up drivers through to the things I want to control, then keyframe the dummy object and that might achieve what I want. However this again feels a bit roundabout/messy.    Background: I'm working on a model that has a non-trivial number of materials (just over 100, auto-generated from a 3D scanner), and am trying to set up effective backface culling in rendering by using the method described . This involves scripting the addition and connecting of all the extra nodes (Mix shader controlled by Geometry Backfacing, and a Transparent BSDF node to make the faces be rendered transparent from the back), because doing it manually for all 100+ materials would be a pain. It's not essential, but I was thinking it would be nice to be able to control the overall effect by automating all the Transparent BSDF Alpha amounts - I'm just not sure how I'd go about controlling that from a single point though.
9399
I make that script (Copy a piece from template UIList) Now i can draw My box with inside the active object material but i want to populate that with all material in scene, i not undertand , how to. Part of my script:  class MATERIAL_UL_extreme_matslot(bpy.types.UIList):      def draw_item(self, context, layout, data, item, icon, active_data, active_propname):         ob = data         slot = item         ma = slot.material          if self.layout_type in {'DEFAULT', 'COMPACT'}:             if ma:                                layout.prop(ma, "name", text= "", emboss=False, icon_value=icon)             else:                                layout.label(text="", translate=False, icon_value=icon)                 elif self.layout_type in {'GRID'}:                      layout.alignment = 'CENTER'                     layout.label(text="", icon_value=icon)   Then for draw in panel:  class MY_PT_Panel(bpy.types.Panel):      bl_label = "My label"     bl_idname = "MY_ID_NAME"     bl_space_type = "VIEW_3D"     bl_region_type = "UI"     bl_category = "My Category"     def draw(self, context):      def draw(self, context):          obj = context.object           layout = self.layout         row = layout.row()         row.template_list("MATERIAL_UL_extreme_matslot", "", obj, "material_slots", obj, "active_material_index")   Im not sure if that is the best solution because i want to select material slot from that UIList panel.
39547
Have problem similar to this but that workaround does not work for me.   I need to access mapping node with Python so I can change values. This code worked for several times I used script but suddenly it does not work anymore.  bpy.data.node_groups["NodeGroup"].nodes["Mapping"].rotation[2] = math.radians(180)   Also looking at python output when changing values manually and looking at tooltip path output I should use something like this.   bpy.data.node_groups["Shader NodeTree"].nodes["Mapping"].rotation[2] = math.radians(180)   But I get error that Shader Nodetree does not exist.  Can anyone explain what is going on here, am I missing something here?
106338
I want to make various copies of a graph in tikz. The graph I want has 10 vertices. But only has the edges between the vertices a_i,a_(i+1),t,b.  I would like to automatically create 8 copies of this graph. and draw them. I just don't know how to code it. Here is my current code, but it adds all of the edges to the same copy of the graph:  \begin{tikzpicture} [main_node/.style={circle,fill=blue!20,draw,minimum size=2em,inner sep=3pt]}] \node[main_node] (8) at (0:0.5) {b}; \node[main_node] (9) at (180:0.5) {t}; \foreach \x in {0,1,...,7}     \node[main_node] (\x) at (360/8*\x:2) {$a_{\x}$}; \foreach \x in {0,1,...,7}{     \pgfmathsetmacro{\y}{int(mod(\x+1,8))}     \path[draw,thick] (\x) edge node {} (8);     \path[draw,thick] (\x) edge node {} (9);     \path[draw,thick] (\x) edge node {} (\y);     \path[draw,thick] (8) edge node {} (9);     \path[draw,thick] (8) edge node {} (\y);     \path[draw,thick] (9) edge node {} (\y);    }   I want each of the edge sets to be drawn seperately.
49278
I've been looking at the python code loging of Blender. But in there things get loged as mouse clicks.  What i like to do is combine a few images into a larger one using compositor, but i need control over compositor by python script. The problem seams to me that it is a bit hard to "spawn" a few nodes, set their values and connect them.  I need an micture of:  image, scale, source image location, mix nodes, output nodes  I have no Code samples other then the log of blender python which in this case is of no big help.
115020
So I'm writing an animation import script... since animation bone names can differ from the armature's bones in question, I want to create the actions and edit their group names manually, and then manually assign them to the armature.  The problem I'm having is I can create an unrelated action with unrelated groups, but the channels of those groups seem to require linked pose bones...  Since it's safe to say these pose bones don't exist, how can I assign keyframes to raw data?
23846
I am trying to create a script that will allow me to generate a list and store it in the blend file. The list starts out blank and then strings get added to the list, resulting in: [&quot;test1&quot;,&quot;test2&quot;,&quot;test3&quot;] I create a PropertyGroup Class for the enum, define a new scene property as a CollectionProperty type with access to that enum Class, before appending a new item into the enum: import bpy  class item_set(bpy.types.PropertyGroup):     myItems = []     enums = bpy.props.EnumProperty(name=&quot;My Items&quot;, items=myItems) bpy.utils.register_class(item_set)  bpy.types.Scene.myItemSet = bpy.props.CollectionProperty(type=item_set)      newItem = bpy.context.scene.myItemSet.add() newItem.myItems.append(&quot;test&quot;)    I need to be able to add items to the list, save the blend file, re-open the file, run the script again and retrieve the list from the scene. However, the  states:  One thing to keep in mind is that after saving and reloading your blend-file, your new property will have disappeared...    ...To make the values you assigned in a previous session available again, you need to redefine the property. So after reopening the blend-file you need to rerun: bpy.types.Object.myProperty = bpy.props.StringProperty()   I can do the appending into and retrieval of the property values absolutely fine upon an initial run, but as the documentation states, the property is unavailable when trying to view it's contents on a reload of the file (after having run the script, saved and re-opened the file), but I am unsure how to redefine it without clearing all it's values. If I redefined the scene property, it would presumably also need the enum Class to be available, which would currently set myItems back to [] (empty). Do I need to change the way I am initially setting the items in the class or am I on entirely the wrong track with all of this? All I need to do is store a list in the blend file, so if there is a better way please let me know. Thanks. (I would hope, eventually, to be able to store sub lists [[&quot;a&quot;,&quot;b&quot;],[&quot;c&quot;,&quot;d&quot;],[&quot;e&quot;,&quot;f&quot;]], I'm just trying to get normal lists to work first.)
92827
I want to use python to move the UVs of the selected objects. I am having trouble with moving the UVs. When I run my script I moves the objects instead, not the UVs. All object have exactly 1 UV map.   My approach the problem:  for mesh in selection:   for UVs in mesh   select all UVs   move UVs     Here is my code.  import bpy  scene = bpy.context.scene for count, ob in enumerate(bpy.context.selected_objects):     if ob.type == 'MESH':         scene.objects.active = ob         bpy.ops.object.mode_set(mode='EDIT', toggle=False)          bpy.ops.mesh.reveal()         bpy.ops.mesh.select_all(action='SELECT')          # execute any editmode tool         move_x = count % 10         move_y = count // 10         bpy.ops.transform.translate(value=(move_x, move_y, 0), constraint_axis=(True, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=0.263331)           bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
19663
I must be missing something here.  I'm doing an extremely simple Import Image as Plane using the AddOn and the imported image has an alpha background but it renders (and even previews in the material preview) as black where the alpha background should be.  When I import, I select Emission &amp; Transparent so the material setup is automatic.  I've read similar issues but people are typically missing the transparent node and connecting the Alpha channel from the image into the Mix Node factor.  But this is all here.  I must be missing something really stupid but I've wasted so much time trying to fix this thing.  Any help would be greatly appreciated.  Not sure if it matters but I'm using 2.74 RC2.  Many thanks!  I created this dummy blend file to test outside my project but problem still exists.  Here is the simple .blend file:
59917
I'm still learning, but I'm trying to follow a tutorial to apply texture to a model. I only want to apply the texture to one object in the scene, so I selected it, unwrapped it, and painted over it. Now I selected it in the Edit Mode (I can't select it in the Object mode because all is locked together) and went into Node Editor, but the nodes are greyed out.  Why?