Maniphest T101401

Setting edge crease via PyAPI doesn't work
Closed, Archived

Assigned To
None
Authored By
Demeter Dzadik (Mets)
Sep 27 2022, 12:31 PM
Tags
  • BF Blender
Subscribers
Demeter Dzadik (Mets)
Philipp Oeser (lichtwerk)

Description

System Information
Operating system: Linux-5.18.10-76051810-generic-x86_64-with-glibc2.34 64 Bits
Graphics card: NVIDIA GeForce RTX 2080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 470.129.06

Blender Version
Broken: version: 3.4.0 Alpha, branch: master, commit date: 2022-09-26 11:52, hash: rB2356afc7af9a
Worked: Sept 19 at least, possibly broken by rBa8a454287a27 ?

Exact steps for others to reproduce the error

  • Add default cube
  • Add subsurf modifier
  • bpy.context.object.data.edges[0].crease = 1

The code runs without error, but does not set the crease value; Checking bpy.context.object.data.edges[0].crease will return 0 still.

This might be the same or at least related to T101393.

Related Objects

Mentioned Here
T101393: Regression: Vertex Crease operator does not create vertex crease layer
rBa8a454287a27: Mesh: Move edge crease out of MEdge

Event Timeline

Demeter Dzadik (Mets) created this task.Sep 27 2022, 12:31 PM
Philipp Oeser (lichtwerk) changed the task status from Needs Triage to Needs Information from User.Sep 27 2022, 12:51 PM
Philipp Oeser (lichtwerk) added a subscriber: Philipp Oeser (lichtwerk).

Seems to work fine in objectmode in current master.
In editmode, this was failing even prior to rBa8a454287a27.

@Demeter Dzadik (Mets) : can you confirm?

Demeter Dzadik (Mets) added a comment.Sep 28 2022, 2:57 PM

Yep, you're right, I just need to be in object mode... Confusing, but ohwell, as long as it works! 😅

Philipp Oeser (lichtwerk) closed this task as Archived.Sep 29 2022, 10:12 AM

Use bmesh to manipulate customdata layers in editmode:

import bpy
import bmesh

# Get the active mesh
me = bpy.context.object.data

# Get a BMesh representation
bm = bmesh.from_edit_mesh(me)

crease_layer = bm.edges.layers.crease.verify()
bm.edges[0][crease_layer] = 1.0

# Finish up, write the bmesh back to the mesh
bmesh.update_edit_mesh(me)

(code coud also be made to work via bmesh in objectmode as well, just use bm.from_mesh(me) / bm.to_mesh(me) / bm.free() then)
Think we can close this though, the documentation could be better on this, but it is still working as intended afaics

Philipp Oeser (lichtwerk) added a comment.Sep 29 2022, 10:16 AM

Sorry, you need bm.free() in editmode as well I think