Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,12 @@ def selection_type_to_string(sel_type):
out.append("Face")

return " + ".join(out)

def world_center(obj):
if (obj):
if (obj.name in bpy.context.view_layer.objects):
bpy.context.view_layer.objects.active = obj
obj.select_set(True)
bpy.ops.object.location_clear(clear_delta=False)
bpy.context.object.location

8 changes: 6 additions & 2 deletions nodes/_base/node_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

from bpy.props import PointerProperty, StringProperty, BoolProperty
from .._base.node_base import ScNode
from ...helper import focus_on_object, remove_object
from ...helper import focus_on_object, remove_object, world_center

class ScInputNode(ScNode):
in_name: StringProperty(default="Object", update=ScNode.update_value)
in_world_origin: BoolProperty(default=False, update=ScNode.update_value)
out_mesh: PointerProperty(type=bpy.types.Object)

def init(self, context):
self.node_executable = True
super().init(context)
self.inputs.new("ScNodeSocketString", "Name").init("in_name")
self.inputs.new("ScNodeSocketBool", "World Origin").init("in_world_origin",False)
self.outputs.new("ScNodeSocketObject", "Object")

def error_condition(self):
Expand All @@ -30,4 +32,6 @@ def post_execute(self):
if (self.out_mesh.data):
self.out_mesh.data.name = self.out_mesh.name
out["Object"] = self.out_mesh
return out
if (self.inputs["World Origin"].default_value):
world_center(self.out_mesh)
return out