def create_blueprint_asset( asset_name, package_path, asset_parent_class, force=False, save=True ): create_unreal_asset( asset_name, package_path, unreal.BlueprintFactory(), asset_parent_class, force, save, )
def create_blueprint(asset_fullpath): asset = get_asset_from_path(asset_fullpath) if asset is not None: return asset else: package_path, asset_name = split_path(asset_fullpath) factory = unreal.BlueprintFactory() factory.set_editor_property("ParentClass", unreal.Actor) asset_tools = unreal.AssetToolsHelpers.get_asset_tools() my_new_asset = asset_tools.create_asset(asset_name, package_path, None, factory) unreal.EditorAssetLibrary.save_loaded_asset(my_new_asset) return my_new_asset
def create_blueprint(bp_name, package_path="/Game/Blueprints", parent_class=ue.Actor): factory = ue.BlueprintFactory() factory.set_editor_property("ParentClass", parent_class) asset_tools = ue.AssetToolsHelpers.get_asset_tools() new_blueprint = asset_tools.create_asset(bp_name, package_path, None, factory) ue.EditorAssetLibrary.save_loaded_asset(new_blueprint) return new_blueprint
def createBlueprintScene(self): # New Asset Name try: newname = self.fbxName.partition('.')[0] if newname[0:3] == "SM_": #todo if there are any other prefixes in the future, test for them asset_name = "ASB_"+ newname[3:] h_name = "ASH_"+ newname[3:] elif newname[0:4] == "CAM_": #todo if there are any other prefixes in the future, test for them asset_name = "ASB_"+ newname[4:] h_name = "ASH_"+ newname[4:] elif newname[0:4] == "LGT_": #todo if there are any other prefixes in the future, test for them asset_name = "ASB_"+ newname[4:] h_name = "ASH_"+ newname[4:] else: asset_name = "ASB_"+ newname h_name = "ASH_"+ newname # Save Path package_path = self.UEMeshDirectory unreal.log_warning(package_path) # Derive a Class from a string path root_class = '/OVFPPlugin/generalResources/blenderToUnrealAdgBridge/B2UAdgBridge_ImportedSceneObject.B2UAdgBridge_ImportedSceneObject' root_class_generated = root_class + "_C" root_class_loaded = unreal.EditorAssetLibrary.load_asset(root_class) # Derive a BlueprintGeneratedClass from a UBlueprint # If you have a C++ class, you can replace all this with just ue.CPPCLASSNAMEHERE parent_class = unreal.get_default_object(unreal.load_object(None, root_class_generated)).get_class() # Factory Setup factory = unreal.BlueprintFactory() factory.set_editor_property("ParentClass", parent_class) # Get Asset Tools asset_tools = unreal.AssetToolsHelpers.get_asset_tools() #todo test if asset already exists. If so, do not try to create a new one? # Create Asset childBP = asset_tools.create_asset(asset_name, package_path, root_class_loaded.static_class(), factory) #bp_gc = unreal.EditorAssetLibrary.load_blueprint_class(childBP.get_path_name()) #bp_cdo = unreal.get_default_object(bp_gc) bploc = package_path + "/" + asset_name + "." + asset_name + "_C" bp_cdo = unreal.get_default_object(unreal.load_object(None, bploc)) unreal.log_warning(h_name) bp_cdo.set_editor_property('Hierarchy', unreal.load_object(None, package_path + "/" + h_name + "." + h_name)) sceneactor = unreal.EditorLevelLibrary.spawn_actor_from_class(bp_cdo.get_class(),unreal.Vector(x=0.0, y=0.0, z=0.0)) #spawn the imported geo out into the world. TODO decide if I want to test to see if there is already a scene out in the world unreal.EditorAssetLibrary.save_directory(self.UEMeshDirectory) #save directory we imported into unreal.EditorAssetLibrary.sync_browser_to_objects([bploc]) except Exception: unreal.log_warning("Issue creating ASM blueprint")
import unreal asset_name = "MyAwesomeBPActorClass" package_path = "/Game/MyContentFolder" factory = unreal.BlueprintFactory() factory.set_editor_property("ParentClass", unreal.Actor) asset_tools = unreal.AssetToolsHelpers.get_asset_tools() my_new_asset = asset_tools.create_asset(asset_name, package_path, None, factory) unreal.EditorAssetLibrary.save_loaded_asset(my_new_asset)