feat: add disolve face by target vertex group, add transform object node
This commit is contained in:
@@ -5,6 +5,10 @@ class DissolveFaces():
|
||||
return {
|
||||
"required": {
|
||||
"bpy_objs_target": ("BPY_OBJS",),
|
||||
"target_vertex_group": ("STRING", {
|
||||
"multiline": False,
|
||||
"default": ""
|
||||
}),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -15,7 +19,7 @@ class DissolveFaces():
|
||||
|
||||
CATEGORY = "mesh"
|
||||
|
||||
def process(self, bpy_objs_target):
|
||||
def process(self, bpy_objs_target, target_vertex_group):
|
||||
import global_bpy
|
||||
bpy = global_bpy.get_bpy()
|
||||
|
||||
@@ -27,7 +31,17 @@ class DissolveFaces():
|
||||
bpy.context.view_layer.objects.active = target_object
|
||||
# enter enter edit mode and select all faces of the object to fill
|
||||
bpy.ops.object.mode_set(mode='EDIT')
|
||||
bpy.ops.mesh.select_all(action='SELECT')
|
||||
|
||||
bpy.ops.mesh.select_all(action='DESELECT')
|
||||
|
||||
# if we have vertex group, select that instead
|
||||
if target_vertex_group and target_vertex_group.strip() != "":
|
||||
group = target_object.vertex_groups.get(target_vertex_group)
|
||||
if group:
|
||||
bpy.ops.object.vertex_group_set_active(group=group.name)
|
||||
bpy.ops.object.vertex_group_select()
|
||||
else:
|
||||
bpy.ops.mesh.select_all(action='SELECT')
|
||||
|
||||
# dissolve the faces
|
||||
# bpy.ops.mesh.dissolve_faces()
|
||||
@@ -35,7 +49,6 @@ class DissolveFaces():
|
||||
# bpy.ops.mesh.delete(type='FACE')
|
||||
bpy.ops.object.mode_set(mode='OBJECT')
|
||||
|
||||
|
||||
return ([target_object],)
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
class TransfromObject():
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
|
||||
return {
|
||||
"required": {
|
||||
"bpy_objs_target": ("BPY_OBJS",),
|
||||
"x": ("FLOAT", {"default": 0.0, "min": -10.0, "max": 10.0, "step": 0.01, "display": "number"}),
|
||||
"y": ("FLOAT", {"default": 0.0, "min": -10.0, "max": 10.0, "step": 0.01, "display": "number"}),
|
||||
"z": ("FLOAT", {"default": 0.0, "min": -10.0, "max": 10.0, "step": 0.01, "display": "number"}),
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("BPY_OBJS",)
|
||||
RETURN_NAMES = ("bpy_objs",)
|
||||
|
||||
FUNCTION = "process"
|
||||
|
||||
CATEGORY = "mesh"
|
||||
|
||||
def process(self, bpy_objs_target, x, y, z):
|
||||
import global_bpy
|
||||
bpy = global_bpy.get_bpy()
|
||||
|
||||
target_object = bpy_objs_target[0]
|
||||
|
||||
bpy.ops.object.select_all(action='DESELECT')
|
||||
bpy.context.view_layer.objects.active = target_object
|
||||
|
||||
# move the object in level transformation
|
||||
target_object.location.x += x
|
||||
target_object.location.y += y
|
||||
target_object.location.z += z
|
||||
|
||||
return ([target_object],)
|
||||
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"TransfromObject": TransfromObject
|
||||
}
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"TransfromObject": "Transfrom Object"
|
||||
}
|
||||
Reference in New Issue
Block a user