New answers tagged

0

That's not that easy as you might think and there are a few concepts involved. For one, you would have to find a reliable way to store the actual object pointer or at least the name of the object and its corresponding viewport color for all selected objects. I would recommend register a CollectionProperty per scene and set its type to a prevously declared ...


0

Just pass a custom width (integer) when calling invoke_props_dialog(operator, width=300) or invoke_popup(operator, width=300). The height is determined dynamically by the size of element placed onto the props_dialog and there is no option to set it. From the docs: Parameters operator (Operator) – Operator to call width (int in [0, inf], (optional)) – Width ...


1

I think it is executing the script node every iteration so I added a float list parameter to the loop and put your script node outside of the loop. On my machine instead of about 350ms execution time I got about 50ms execution time with it outside. about 7 times improvement.


0

Try to play with the Scale facter and Octree Depth in the remesh modifier and use the measure tool on the left toolbar to get your measurements right as far as i know the remesh modifier is the only way to get what you are looking for. Voxels are a bit different in blender than what most people think of them as. They aren't cubes like Minecraft - they are a ...


2

This solution will work for any face (triangle, quad, ngon) generating points with even distribution. I think the conversion from local to other coordinate system has been explained by batFINGER, so there's no reason to deal with it here: import bpy, bmesh, random from mathutils import Vector num_points = 1000 def point_on_triangle(face): a, b, c = map(...


1

It's hardcoded in user prefs UI. Agree it is a wasted line of space and have also looked into removing it. Unfortunately the label is hardcoded in the user preferences space UI and used in the USERPREF_PT_addons panel which displays the addons in the user preferences. Snippet from scripts/startup/bl_ui/space_userprefs.py # Show addon user preferences if ...


5

Use the objects children property. A blender object already has a children collection, there is no need to reinvent the wheel. Test script, loop over the children of the context object, (optionally) if they are linked to another collection, unlink, create a new collection with object name, link child object to it, link collection to context collection. ...


2

Use the local space. The default plane in blender has local coordinates where x and y range from -1 to 1 and z is zero. >>> me = C.object.data >>> for v in me.vertices: ... v.co[:] ... (-1.0, -1.0, 0.0) (1.0, -1.0, 0.0) (-1.0, 1.0, 0.0) (1.0, 1.0, 0.0) With this arrangement can consider only the x, y coordinates effectively making ...


0

import bpy bpy.ops.transform.resize(value=(1, 2, 1), orient_type='LOCAL') obj = bpy.context.selected_pose_bones[0] mat = obj.matrix.to_3x3() print(mat) bpy.ops.transform.resize(value=(1, .5, 1), orient_type='GLOBAL', orient_matrix=mat) This works and I am going to try and explain this. I am sort of newb here so bear with me, and by all means correct me in ...


4

With one loop. Was seeking clarification on this, if the idea is to rotate the vertices of the face loop. Similar to @scurest can use the foreach_get and foreach_set methods to provide quick access to values without looping in python. This will have a significantly increased performance for a high poly count. The loop start is taken directly from the data. ...


6

I don't know how to do it with a bmesh, but it's easy with a regular mesh since mesh.loops[i].vertex_index is writable. import bpy ob = bpy.context.object assert ob.type == 'MESH' # If in edit mode, switch to object mode and switch back at the end was_in_edit_mode = False if ob.mode == 'EDIT': bpy.ops.object.mode_set(mode='OBJECT') was_in_edit_mode ...


2

Update the normals. After you "twist" face by index translation, the normals are not recalculated unless we explicitly call normal_update either on the bmesh instance, or on a per face basis. Update Edge Info when using script in Edit Mode Script with that edit, also optionally changed operator to inset individual. import bpy import bmesh from ...


1

Bmesh script. can add primitives using bmesh. The equivalent of add cylinder is bmesh.ops.create_cone(...) with both radii set to match. As with the mesh operator the default for ends is NGON fill. The top face will have a normal that is in +Z direction. https://blender.stackexchange.com/a/96121 Test script, run in OBJECT mode. import bpy import bmesh ...


0

Add a plane to your default cube (yes, keep it!) Add geometry nodes modifier to plane. Use this node setup: and you get:


0

Press F3 key, then type add cube into the search box and choose first item:


0

Actually I found the solution thanks to the help of someone else: My problem was I wasn't using relative imports, don't use sys.append instead use relative imports like this and it worked: #import classes from .save_shader_map import SHADER_PRESETS_UL_items, ShowMessageOperator #import functions from .save_shader_map import get_preferences, ...


2

Consider a pointer property. Prior to being able to set a property to point to another object, would have used names, and some naming convention, or custom property on the object to "mark it". However since the ability to assign pointers would consider instead creating a pointer property, that when updated adds and sets the modifiers to the object ...


2

The method from_pydata appears to be surprisingly brittle for something in Python. Something as simple as using a vertex index number that is out of bounds (number higher or equal to the number of vertices) will result in odd results followed by a segfault shortly after (for example by going from object mode to vertex mode). Calling validate should at least ...


0

Use the bpy.data.objects[“Obj Name”].rigid_body.dynamic or …rigid_body.enabled property


0

I hope it is OK if I post a complete code that answers the question. I could not have figured it out without the previous answer and comments, but having a working code to experiment with is very helpful when trying to learn something new. import bpy from bpy.props import FloatProperty,BoolProperty, IntVectorProperty last_selection = [] bpy.types.Scene....


2

IMO would join the dots. I want to select and then move each point to a desired location. If the idea is to take a set of points and "join the dots" it is quite possibly a lot simpler to to create the spline. Here is an example using NURBS answser from Create curve from Numpy Array using Python Result displayed in EDIT mode, after running ...


4

You can use the function np.frombuffer. However you first have to convert the bgl Buffer to a bytes list. buffer_list = bytes(buffer.to_list()) imageDataNp = np.frombuffer(buffer_list, dtype=np.float32) With your example file this method took 1.69s in contrast to 1.8s for your workaround.


1

import bpy for p in bpy.context.object.data.splines.active.points: p.co.z = p.co.z + 1 bpy.ops.object.mode_set(mode='EDIT') This works. UPDATE: (only change selected points) bpy.ops.object.mode_set(mode='OBJECT') counter = 0 for p in bpy.context.object.data.splines.active.points: print("counter = ",counter) if p.select == True:...


1

The solution to this was to transform bone2 by the inverse of bone1's pose mode matrix, then transform bone2 again by bone1's matrix in edit mode: for b in bpy.context.selected_bones: b.transform(hand_pose_mat.inverted()) b.transform(hand_edit_mat)


1

To answer comments under question, In addition to using the tooltips, as demonstrated in accepted answer. Python console. Use the python console to directly input python code and get instant feedback. In example below, typing the variable mat into console, echos the representation of its value. IMO this is one of the strengths of a scripting language like ...


1

Make constraints to visualize, then convert. Not at all sure how the code in question is going to even be close to what you wish to achieve. Would look at doing something akin to answer here. PoseBone local rotation values to global with axis changed The last example of which shows how to run thru pose bones, convert space, change the alignment and convert ...


1

I think I made progress which fits to your question. With a modal operator I have achieved streaming a live camera view from the active Viewport to a v4l device with about 11 fps. Not that smooth, but a good start. Of course I did not come up with this totally on my own, but i was guided by related threads or answers: Question from bluejayke on realtime ...


3

It's ShaderNodeValToRGB. Turn on Python Tooltips under Edit > Preferences > Interface. Then go to the Shader Editor and hover over a node in the Add menu to see a tooltip with the name.


3

Make 1 material and copy it. In as much as I agree with the comment of @MarkusvonBroady in that investigating making a single material and passing an argument re which image to use, especially if texture image is the only difference per material. eg akin to Is possible play video in reverse mode into Texture Image node? with a static input like Object....


1

Object linked materials. If you wish to have one material per object, suggest using object linked materials. Have explained this somewhat in https://blender.stackexchange.com/a/185428/15543 Albeit @ZargultheWizard's simple script will work in the question example case, where there are two distinct meshes the cube and the cone, if they were not then would end ...


1

Thankfully it’s very easy. The material datatype has a method copy() which returns a new duplicate material. Something like this: for o in bpy.context.selected_objects: o.data.materials[0]=o.data.materials[0].copy() This code assumes the material is linked to the mesh data block.


2

Ok, I confirmed what I commented above. You need to get the selected object(s), not the active objects. So context.selected_objects is a list - you either need to always operate on just the first selected object, or all of them. If you just want to assume the first selected one, just replace this: obj = context.active_object with: obj = None if len(...


1

As ZargulTheWizard mentioned, the only way to receive the body text/values at run-time is with Python API. However, you could use a different setup, that being to send a simple "buy.100" message as you showed above, than, on the object(s) that are meant to be receiving the messages vie message sensors, have them use a property actuator with type &...


2

With a setter and getter. Instead of writing an operator, here is a suggestion re using a boolean property to toggle between the two, and set the path accordingly. IIRC, (and I didn't) had asked a similar question re globbing string properties with a file or folder subtype, in particular to glob a file. Have asked a new question. For the case shown in ...


1

Change render properties -> view transform -> to "Standard"


1

ok, here is a python solution: result looks like this: https://youtu.be/HsVNCyuWyDY what you have to do: Create a collection with the name "Automatic_frame_visibility" and put all your objects in there. After running the script and starting your animation, each object will be visible in the order of the collection with one frame visibility. python ...


2

When Blender creates a new object, if one of that name already exists then it adds the suffix to make it unique. You can pickup that name immediately after creation via the 'name' property. In your case you simply need to use o.name in place of empty_name : import bpy empty_name = 'MyOwnEmpty' o = bpy.data.objects.new( empty_name, None ) bpy.context.scene....


0

import bpy data = bpy.data.meshes['Плоскость']; # 'Плоскость' - name of manually selected mesh, for example # VERTICES vertices = []; for _ in data.vertices: vertices.append(list(_.co)); print(vertices); # EDGES edges = []; for _ in data.edges: edges.append(list(_.vertices)); print(edges); # POLYGONS polygons=[]; for _ in data.polygons: polygons.append(...


0

A person going by the nick @Random helped me with this on blender.chat. The solution was to pass translation matrix to create_cube op. bmesh.ops.create_cube(bm, size=0.5, matrix=mathutils.Matrix.Translation(current_point))


2

NURBS curves are a set of weighted control points. Control Point, Vertex In case of a NURBS curve, there is a fourth component available (W), which defines the weight of the selected control point or the median weight. For further technical details see https://en.wikipedia.org/wiki/Non-uniform_rational_B-spline#Technical_specifications A NURBS curve is ...


0

The only solution I found is to create an extra camera and lock it to the view. Then you'll have to make the camera active in each workspace to be able to switch between the workspaces, preserving the angle of view. A bit annoying workflow, but it helps to solve the problem


3

You would have to declare a CollectionProperty and assign its type to a previously declared PropertyGroup to hold multiple generic entries. Demo based on the code provided in the docs: bl_info = { "name": "Example Add-on Preferences", "author": "Your Name Here", "version": (1, 0), "...


2

The following uses hard coded windows paths for the ip_path, op_path but as the intention was to specify your own path and file this should be no issue. Open a new blender file (the script will be removing all content from collections in the current file while running). Copy the code into a text editor. Modify the ip_path, ip_fname, op_path for your ...


0

After some messing about, I deleted my user preferences to find that it solved the issue. Unsatisfied with this catch-all fix, I endeavored to find out why, and went through each setting, enabling and disabling it to see its effect. It turns out that my keymap, being the same keymap I've been using for, perhaps years, still being retained through to 2.92, ...


0

I ended up duplicating the meshes with bpy.ops.object.duplicate(). Requires the mesh to be selected and visible, for some reason, so I unhide it with o.hide_set(False). I didn't delete the duplicates for testing, which resulted in an infinite loop when iterating over for o in context.scene.objects. So I collected all meshes first in a list, then iterated ...


1

Add cube, resize, subdivide, move edge. Image showing 3 test runs as in listed in code below There are many ways to skin this cat, thought I would add a method to Add a unit cube, scale to desired width x depth x height, and translate such that origin is as in question. (Could IMO use COG as origin and translate later) The 4 vertical edges of cube are ...


0

an initial velocity in a rigid body simulation is very easy to do: check animated checkbox and keyframe a location keyframe another location on another later frame (distance + keyframe distance will "make" the speed one keyframe later: disable animated checkbox and keyframe it


1

Edits. Please never post code as image. Using context.object in the properties can be dodgy as (speculating) it is also used to pin an object. Printing will show it is often None, this was causing the polling error with remove material slot operator. To remove all the materials from selected objects can override the operator to pass the non (or) context ...


1

The simplest solution to being able to create a model via maths is to install the "Add Mesh: Extra Objects" add-on that somes shipped with Blender. Simply go into Preferences, Add-ons and search for 'Extra'. Enable "Add Mesh: Extra Objects" and you should have additional options within the 'Add/Mesh' menu for "Math Function". ...


1

Yes, you can create geometry using python. However, you would have to learn python in the first place (if you don't know it yet) as well as understanding the API (if you don't know it yet). I'd suggest have a look into the docomentation and read about Bmesh which is the recommended way of creating meshes via python: https://docs.blender.org/api/current/bmesh....


Top 50 recent answers are included