New answers tagged

0

you can do it with this node setup: Basically it works like this: In state1 it waits for tapping w, if it is tapped, it changes to state2. In state2 it jumps and sets it back to state1.


0

Does this answer your question? 'File'-> "external data">pack all into blend then save your blend file and upload again in Ursina Engine.


0

Blender can repeat arguments that can be passed to operator as key word arguments. Those arguments must be defined in operator. Non default arguments will be seen in Info editor. This happens probably due to the way blender handles operator context overrides but it requires deep dive into source code to confirm. See example: import bpy class ...


3

Make the render operator and the output path assignment part of the actual for-loop. Demo code using a regular dictionary for the camera locations based on this answer. import bpy import os.path camera_locations = { 0: (2.576395273208618, -4.465750694274902, 1.094475507736206), 1: (-0.573695343202619, -1.863753624223357, 1.094235453632562) } # ...


3

Just paste this into your driver's field: bpy.context.scene.frame_end - bpy.context.scene.frame_start i put it in my x-scale: Note: works only if your animation is playing.


0

I don't think you're going to get a complete script for this, and no the function doesn't exist in Blender by default. The basic function is easy to design and here it is in pseudocode: examined = set() to_examine = [bpy.context.active_object] while to_examine: object = to_examine[0] to_examine.remove(object) for new_object in ...


0

bl_info = { "name": "PivotToggle", "author": "MikeMS", "version": (1,0), "blender": (2,93,0), "category": "Object", "location": "Add to QuickFavorites from Search Operator or to a Hotkey for object.pivottoggle", "description&...


2

As far as I know (and from looking at the docs), I don't see any smoothing options for gpu module. Also note that bgl is likely to be deprecated eventually. I know you said you'd rather not, but as my answer, I'd suggest loading an image. Ideally there would be a way to tint the image within Blender (not sure if that's the case), but if not you can create ...


0

After spending some time in the source code, I found that it assumes color to be stored in sRGB already. But it doesn't change anything if I apply linear_to_srgb before export, precious precision will be lost. So it seems like I have only one option left - change blender glTF export/import add-on. Add-on is located in : "/Applications/Blender.app/...


0

import bpy #I have a series of very redundand properties to define in my propgroup #i'd like to procedurally generate the properties before registration print("\n\nScript is running...") def generate_props(name): """will add the properties to annotation""" d = {} d[f"{name}_str"] = bpy.props....


2

foreach_get fills the provided array with the values. It doesn't return anything. The array you pass needs to be the right length too. vals = [0.0] * len(sks.key_blocks) sks.key_blocks.foreach_get("value", vals) print(vals)


0

In sequence-view: click View menu item click Sequence Render animation This will correctly export an animation with frame_handler


0

In sequence-view: click View menu item click Sequence Render animation This will correctly export an animation with frame_handler


0

I solved the problem myself. I used the following as a reference. Thanks! https://blender.stackexchange.com/a/166390/134117 ### Python Code import bpy meshName: str = 'Cube' # vars obj = bpy.data.objects[meshName] depsgraph = bpy.context.eva luated_depsgraph_get() object_eval = obj.evaluated_get(depsgraph) def handler(Scene): # count vertices ...


1

After you have selected the mesh and the armature: bpy.ops.object.parent_set(type='ARMATURE_AUTO') Here's how to find this out: If you enable Python tooltips in your preferences and hover over 'With Automatic Weights', it will show you: If you type CTRL–C it will copy that string to clipboard. You can then go to the Python console ad type CTRL–V to past ...


0

If you are using the gyroscope output of the MPU6050 be aware that the value it produces is a rate and not an absolute change in rotation. That means that you need an accurate time delta between samples to convert the rate / second into the total rotation over that time. The problem with using a redraw timer is that it doesn't guarantee fixed interval ...


0

Assuming you mean the visual studio Blender Development, the author of that add-on has stated that This extension is not actively developed anymore. However, I was able to get it to work by following this tutorial that gives a step-by-step explanation of how to set it up. Here are my notes from the tutorial, they are specific to 2.93, but should work for ...


1

If you'd like to assign material(s) to certain faces in Edit Mode, just assign the index of the material slot to BMFace.material_index on a Bmesh representation of your mesh: import bpy, bmesh def create_material(mat_name, diffuse_color=(1,1,1,1)): mat = bpy.data.materials.new(name=mat_name) mat.diffuse_color = diffuse_color return mat # ...


1

For the time being there is not way to access data from Spreadsheet editor, but keep an eye on patch D12546 which implements support for exporting to CSV. Unfortunately I do not know a way to access geometry nodes output


1

This is accessed through the ever intuitive bpy.context.preferences.system.viewport_aa You should be able to write directly to this variable: bpy.context.preferences.system.viewport_aa = 'OFF' for example.


1

replace # Scaling one face bm = bmesh.new() bm.from_mesh(new_mesh) with bm = bmesh.from_edit_mesh(new_mesh) bm.verts.ensure_lookup_table() bm.edges.ensure_lookup_table() bm.faces.ensure_lookup_table() to rid yourself of the first error. You only need the 3rd ensure_lookup_table for your specific problem. I've just put the other two in for completeness. ...


0

In a comment, I asked if your props have custom update, get or set functions, I'm referring to the update=<function>,get=..., or set=... set in the prop declaration, for example this one I found in the repo's root init: bpy.types.Scene.m3_animation_index = bpy.props.IntProperty(update=handleAnimationSequenceIndexChange,...) And there's many props like ...


2

There is a bit of a trick necessary for this, because bpy.ops.import_curve.svg does not return any information about what objects it added to the scene. The trick is to create a set of all of the collections in the scene before calling it and then take the difference of that set with the set of all of the collections in the scene after calling it. The ...


2

It is possible for sure, I'm working on such script myself atm. You can batch import your SVG's with a code like this: import bpy import os import_path=os.path.join('C:\\temp\\') file_list = sorted(os.listdir(import_path)) svg_list = [item for item in file_list if item.endswith('.svg')] for svg_file in svg_list: svg_path=os.path.join(import_path,...


0

This code seems to work. Still thinking through this, there still might be flaws. One issue was the curser, which seems to confuse the bezier curves if not set to the origin. An other was the left/right-handedness of the rotation (the minus sign on the sin() functions). I am still not sure about the vector projection, but it produces reasonable results for ...


0

Have the armature object of which you want to reset the pose bones selected, then run one of these two script.(work in object, edit and pose mode) Reset all pose bones: import bpy for n in bpy.context.object.pose.bones: n.location = (0, 0, 0) n.rotation_quaternion = (1, 0, 0, 0) n.rotation_axis_angle = (0, 0, 1, 0) n.rotation_euler = (0, 0, ...


3

You can assign the materials using MeshPolygon.material_index in Object Mode without Bmesh. import bpy def create_material(mat_name, diffuse_color=(1,1,1,1)): mat = bpy.data.materials.new(name=mat_name) mat.diffuse_color = diffuse_color return mat # Generate 2 demo materials mat_red = create_material("Red", (1,0,0,1)) mat_green = ...


1

As of Blender version 2.81, bpy.ops.ui.reports_to_textblock was removed, (see D5510) because the functionality to read Info was already available through the bpy.ops.info operators. While copying to and from the clipboard is perhaps less straightforward, the developers recommended that something like the following pseudocode be used bpy.ops.info.select_all() ...


2

Try this import bpy # Name of your vertex color layer, change it if you need to VERTEX_COLOR_NAME = "bakedVertexColor" def get_texture_node(principled): if principled.inputs["Base Color"].is_linked: soc = principled.inputs["Base Color"].links[0].from_socket if soc.node.type == 'TEX_IMAGE' and soc.name == &...


2

Similar to How to load an image from disc and assign it to a newly created image texture node? you can use BlendDataImages.load() to load and assign the image (sequence) to the texture node in one go. Just make sure Image.source is set to 'SEQUENCE' and ImageUser.use_auto_refresh is enabled (as mentioned by @scurest in the comments): import bpy # Get the ...


1

What you are missing is that bpy.context.window_manager.windows is an iterable: >>> type(bpy.context.window_manager.windows) <class 'bpy_prop_collection'> In order to see a window, you must choose a member: >>> type(bpy.context.window_manager.windows[0]) <class 'bpy.types.Window'> Or you can chain together something like this ...


2

The code from your last question was closer. All you needed was to calc_normal_split and to use the loop.normal instead of the vertex.normal. import bpy ob = bpy.context.object ob.data.calc_normals_split() for loop in ob.data.loops: normal = loop.normal ob.data.uv_layers["XY"].data[loop.index].uv = (normal.x, normal.y) ob.data....


2

You mentioned doing it with multiple renders. This can be optimized beyond what you imagined (but still requires 3 images, in 2 separate renders, for every frame). The first thing we'll do is set up an AOV. For our video monitor, we'll output UV in this AOV. For everything else, we'll output RGB 0,0,1.0. This will let us distinguish between the screen ...


0

The questions all have to do with eachother here, but you haven’t researched it any. Knowing about the software a little breaks it down to four questions: 1) How to automate randomized but realistic furniture placement in a room? This is not really about blender, since Mojang employees probably ask the same question at some point. If you want help for how to ...


1

Ok so apparently I got this working right after I posted this if anyone is interested: # In script1 import bpy import os import sys dir = os.path.dirname(bpy.data.filepath) #Get directory of the .blend file sys.path.append(dir) #Setting it as the python directory in the Blender Text editor import script2 import importlib importlib.reload(conFig) from ...


1

In cycles you can enable UV pass in view layer settings: Using this layer, you can get a UV coords position of each point on render. Red color corresponds to U and Green - to V. So if you want to find a specific point on source image, get X and Y coordinates and get the color from formula: RGB(X\width, Y\height, 100%), then find the closest color in UV ...


3

XY Problem The desired result and the question title IMO make this a bit of an XY Problem In that, as I see it, to get the result requires neither vertex indices, nor edit mode. Firstly as mentioned (early) in @MartyFouts answer could call the bridge edge loops operator, while in mesh edit mode with all verts (edges) selected. The verts have a creation ...


2

It's up to you but from what you say anything that relates to viewport probably fits in as VIEW3D panel. note you can append to existing panels to reduce clutter.


3

MeshLoop.normal As commented by @scurest After using ob.data.calc_normals_split() you access the normals with loop.normal. What error message are you getting? Make sure you are in object mode and not edit mode when you run the script. Look at the loop normal, rather than the vertex normal to get the custom split normal values. Test script, using foreach ...


0

And then how could the layer be renamed in python after selecting it? This create a new layer and names the layer. (This code works) rename_layer = bpy.context.object.data.layers.new (name = "new name") # new creates a new layer but what if you want to name the layer after you have selected it. (the following code doesn't work) rename_layer = ...


1

After you set the mode back to "OBJECT" change the shape key to relative mode if you want to adjust the key with its .value property: obj.data.shape_keys.use_relative = True If you're not in relative mode you must adjust the key with bpy.data.shape_keys["Key"].eval_time Edit: This version of your script builds a working shapekey: import ...


1

You are creating your curves using this script that you mentioned in the comments on your question: for obj in bpy.data.objects: bpy.data.objects.remove(obj) r = 16 bpy.ops.curve.primitive_bezier_curve_add(location=(1.0, 0.0, 0.0), enter_editmode = 1, align = 'WORLD') bpy.ops.curve.primitive_bezier_curve_add(location=(1.0, 1.0, 0.0), radius=1.0) bpy....


0

It is possible to run the original operator in an override by temporarily unregistering the overriding class during invoke() and execute() and that way avoiding infinite recursion (at least in Blender 2.93). Combining that with a technique for forwarding properties from this forum post https://blenderartists.org/t/extending-built-in-operator/1257955/4 allows ...


2

To see the error message, you should open the system console, not the Blender's one. In Windows, you can open it from menu (Window → Toggle System Console): then run the script again


2

You can get the location in world space through obj.matrix_world. for obj in bpy.data.objects: if obj.type == 'CAMERA': loc = obj.matrix_world.to_translation() print(obj.name, loc)


0

Both Python and Blender best practices have changed since the original answer to this question. Rather than edit the answer, I thought I would update it to reflect Blender 2.9+ and Python 3.6+ best practices. The three major changes are pathlib is preferred to os if the only reason to include os, which is a huge namespace, is to access path functions. See ...


0

There seem to be two parts to your question, why isn't the image file showing up where you expect it? and why is the image a screenshot rather than a render. The reason it is a screenshot is that you are rendering to opengl, and that produces screenshots. To render with a render engine, use bpy.ops.render.render(write_still=True) rather than bpy.ops.render....


1

You can directly edit a vertex of the active object like this: bpy.context.active_object.data.vertices[0].co=Vector( (2,2,2) ) This requires you to be in OBJECT mode. import bpy from mathutils import Vector # Make sure we have a mesh object if bpy.context.active_object.type != 'MESH': raise ValueError('Active object not a mesh') # save a handy pointer ...


-1

Turns out that you don't really need msgbus for this. I don't know exactly how this would integrate into your code, so I'm just going to post the necessary code fragments and let you figure out where to put them. First, you need two custom color properties, attached to anything, but I've attached them to bpy.types.Scene because that means you can use them ...


1

You can use pythons built-in len() function on the Object.material_slots collection to determine whether there are any material slots assigned to the objects material already. Suggest use the python console to figure out: >>> C.object.material_slots bpy.data.objects['Cube'].material_slots >>> len(C.object.material_slots) 4 Following demo ...


Top 50 recent answers are included