mirror of
https://github.com/kaosat-dev/Blender_bevy_components_workflow.git
synced 2024-11-30 07:07:01 +00:00
cfbda24da7
* adds a new crate: ```bevy_registry_export``` to be able to create a json import of the registered component/type definitions * adds a new Blender addon: ```bevy_components``` that takes that json data to generate custom UIs for components , to be to add & edit components easily in Blender * also adds component metadata per object for more advanced features * etc * updates to bevy_gltf_components & bevy_gltf_blueprints to add legacy_mode to support the "old"/current style component definitions * same with gltf_auto_export Blender add_on * closes #60
42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
|
|
import json
|
|
import bpy
|
|
from bpy_types import Operator
|
|
from bpy.props import (StringProperty)
|
|
|
|
from .helpers import make_empty
|
|
|
|
class CreateBlueprintOperator(Operator):
|
|
"""Creates blueprint"""
|
|
bl_idname = "object.simple_operator"
|
|
bl_label = "Simple Object Operator"
|
|
|
|
blueprint_name: StringProperty(
|
|
name="blueprint name",
|
|
description="blueprint name to add",
|
|
default="NewBlueprint"
|
|
)
|
|
|
|
|
|
def execute(self, context):
|
|
blueprint_name = self.blueprint_name
|
|
if blueprint_name == '':
|
|
blueprint_name = "NewBlueprint"
|
|
collection = bpy.data.collections.new(blueprint_name)
|
|
bpy.context.scene.collection.children.link(collection)
|
|
collection['AutoExport'] = True
|
|
|
|
# this is in order to deal with automatic naming
|
|
blueprint_name = collection.name
|
|
|
|
components_empty = make_empty(blueprint_name + "_components", [0,0,0], [0,0,0], [0,0,0], bpy.context.scene.collection)
|
|
bpy.ops.collection.objects_remove_all()
|
|
|
|
collection.objects.link(components_empty)
|
|
|
|
components_empty.select_set(True)
|
|
bpy.context.view_layer.objects.active = components_empty
|
|
|
|
return {'FINISHED'}
|
|
|