Hot answers tagged

4

str and repr What you see in a print statement is the classes __str__ method, or how to represent the instance as a string, which as mentioned prints to 4 decimal places. >>> str(C.object.location) '<Vector (0.0000, 1.6400, 0.0000)>' The representation, defined on class as def __repr__(self) result >>> repr(C.object.location) '...


2

Make a "UV" bmesh Given the mesh object above with UV, make a bmesh from the uv's loop faces loop face loops add a vert to new bmesh at uv.x, uv.y, 0 create a face from verts remove doubles (optionally) dissolve non boundary edges (optionally) remove faces. added an integer layer to both verts and faces with the index of the orignal verts and faces. Test ...


2

A proposal script for this question. The script is commented below and the main function get_boundary_uv_coords will get an array of instances of EdgeUV that have the following fields: The concerned edge index edge_index The corresponding vertices: v1_index and v2_index The first face index: face1_index The uv coords the each vertex of this face: uv11 and ...


2

You can discover nearly all data paths from Blender GUI itself. Set your mouse cursor over a field and a tooltip will appear: You can also copy (part of) the path directly here: Then you can use it (and test it) from the Python console, and also discover all the properties you need using autocompletion with the Tab key: So concretely you can for instance:...


2

TRANSLATION is Not a subtype of an int property when the code is run you will be getting messages to the system console that TypeError: IntProperty(subtype='TRANSLATION'): subtype not found in ('PIXEL', 'UNSIGNED', 'PERCENTAGE', 'FACTOR', 'ANGLE', 'TIME', 'DISTANCE', 'NONE') ValueError: bpy_struct "MESH_OT_add_object" registration error: step could not ...


1

Elaborate From brockmann comment and Blender API: bpy.props.FloatVectorProperty( min=sys.float_info.min, max=sys.float_info.max, soft_min=sys.float_info.min, soft_max=sys.float_info.max) min (float) – Hard minimum, trying to assign a value below will silently assign this minimum instead. max (float) – Hard maximum, trying to assign a value above ...


1

You will have to unregister your timer function in the cancel method. To do so I had to bring printFunction out of the operator class, because otherwise it needs self argument, and I haven't found how to bring it with the function to the timer register operator. So now the idea is to set returnValue not as class's instance's variable (using self.returnValue)...


1

You have to create custom Operator class and register it. Inside the operator you have to check if the object has the modifier or not. If it is not then add or else remove it. Then replace the YourOperator.bl_idname with "object.modifier_add". Added shade smooth and flat toggle. For shortcut you can click on the button and "add shortcut". Note: Your ...


1

Use a pointer property Can set up a pointer to any blender ID type objects, in this case bpy.types.Object instances of which can be found in bpy.data.objects collection. Assign the property to class import bpy from bpy.types import Object, Scene from bpy.props import PointerProperty Scene.target_obj = PointerProperty(type=Object) Test. >>> C....


1

What you are trying to do is change the current context. Instead, you should just be overriding the context. First step for that would be finding the context that you want to use, that would be our VIEW3D REGION for this case, so we can just cycle through all the context screens available till we find VIEW_3D for area in bpy.context.screen.areas: if ...


1

A little late but maybe someone needs the solution: To render images and export also their denoising information, create a group of compositor nodes, link them and just render the image as usual. Example of what worked for me: def use_compositor_extra_information(noisy=True, albedo=False, normal=False, dir="D:/Renderings/"): bpy.context.scene....


Only top voted, non community-wiki answers of a minimum length are eligible