带Python的默认立方体的搅拌器斜角选定的边缘
我想在Blender 3.0中带有Python的默认立方体的单个边缘。我需要选择边缘的两个顶点来选择边缘并倾斜。事实证明这很困难。
import bpy
import bmesh
obj = bpy.context.active_object # Get selected object
epsilon = 1e-5 # Threshold to account for floating point precision
if obj:
bpy.ops.object.mode_set(mode='EDIT') # Go into edit mode
bpy.ops.mesh.select_mode(type="EDGE") # Switch to edge select mode
bm = bmesh.from_edit_mesh(obj.data) # Create bmesh object for easy mesh evaluation
obj = bpy.context.active_object
obj.data.polygons[2].select = True
for e in bm.edges: # Check all edges
if e.index == 0:
print ("abc")
first_pos = e.verts[0].co # Get first vert position of this edge
other_pos = e.verts[1].co # Get second vert position of this edge
e.select_set(abs(first_pos.x - other_pos.x) <= epsilon and abs(first_pos.y - other_pos.y) <= epsilon)
bmesh.update_edit_mesh(obj.data) # Update the mesh in edit mode
bpy.ops.object.modifier_set_active(modifier="Bevel")
bpy.ops.object.modifier_add(type='BEVEL')
bpy.context.object.modifiers["Bevel"].segments = 10
bpy.context.object.modifiers["Bevel"].width = 0.37
我可以选择整个立方体和所有边缘,但不能选择特定的边缘。
I'd like to bevel a single edge of a default cube with Python in Blender 3.0. I need to select two vertices of an edge to select the edge and bevel it. This is proving quite difficult.
import bpy
import bmesh
obj = bpy.context.active_object # Get selected object
epsilon = 1e-5 # Threshold to account for floating point precision
if obj:
bpy.ops.object.mode_set(mode='EDIT') # Go into edit mode
bpy.ops.mesh.select_mode(type="EDGE") # Switch to edge select mode
bm = bmesh.from_edit_mesh(obj.data) # Create bmesh object for easy mesh evaluation
obj = bpy.context.active_object
obj.data.polygons[2].select = True
for e in bm.edges: # Check all edges
if e.index == 0:
print ("abc")
first_pos = e.verts[0].co # Get first vert position of this edge
other_pos = e.verts[1].co # Get second vert position of this edge
e.select_set(abs(first_pos.x - other_pos.x) <= epsilon and abs(first_pos.y - other_pos.y) <= epsilon)
bmesh.update_edit_mesh(obj.data) # Update the mesh in edit mode
bpy.ops.object.modifier_set_active(modifier="Bevel")
bpy.ops.object.modifier_add(type='BEVEL')
bpy.context.object.modifiers["Bevel"].segments = 10
bpy.context.object.modifiers["Bevel"].width = 0.37
I can select the whole cube and all the edges but not a specific edge.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您想选择一个边斜线,其余的保持不变。
您可以通过在斜角修饰符中选择“重量”极限方法来做到这一点。在这种方法中,
网格中的每个边缘都有一个“斜角重量”,用于将斜角在该边缘的大小倍增。因此,如果边缘上的斜角重量为0-边缘上没有斜角;如果斜角重量为1,那么您会得到一个完整的斜角。
新网格中所有边缘的斜角重量通常设置为0。它可以更改
(在编辑模式下)通过选择要弯曲的边缘,然后
将重量设置为1位的边缘(或边缘)。
在Python中,应通过更改代码来修改您的脚本,如下所示
“如何解决搅拌机中的斜面问题”(Erik Selin):
https://artistisrender.com/how-to-solve-bevel-bevel-problems-in-blender/#:~: text = the%20mast%20common%20common%20issue%20When, %20工具%20or%20BAD%20分。
I think you want to select one edge to bevel and leave the rest unchanged.
You can do this by selecting the “Weight” limit method in the bevel modifier. In this method,
each edge in your mesh has a “Bevel Weight” which is used to multiply the size of your bevel on that edge. So if the Bevel Weight on an edge is 0 – no bevel on that edge; if Bevel Weight is 1, then you get a full bevel.
The Bevel Weight is normally set to 0 on all edges in a new mesh. It can be changed
(in Edit mode) by selecting the edges you want to bevel, then
This sets the weight to 1 on the edge (or edges) you want to bevel.
In Python, your script should be modified by changing your code as follows
Finally, I found the following article on Blender Bevels to be very useful:
“How to solve bevel problems in Blender” (Erik Selin):
https://artisticrender.com/how-to-solve-bevel-problems-in-blender/#:~:text=The%20most%20common%20issue%20when,the%20tools%20or%20bad%20geometry.