Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added object_collection_override list to properties #104

Merged
merged 2 commits into from
Nov 21, 2024
Merged
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
15 changes: 15 additions & 0 deletions docs/send2ue/customize/python-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,20 @@ bpy.ops.send2ue.start_rpc_servers()
bpy.ops.wm.send2ue()
```

!!! tip

Here is how you could use Python to override what objects are collected.
```python
import bpy

# override what objects are collected
bpy.context.window_manager.send2ue.object_collection_override.extend([
bpy.data.objects['Cube']
])

# run send to unreal
bpy.ops.wm.send2ue()
```

The same process can be used to dynamically set any property on the Send to Unreal tool.

2 changes: 1 addition & 1 deletion src/addons/send2ue/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
bl_info = {
"name": "Send to Unreal",
"author": "Epic Games Inc (now a community fork)",
"version": (2, 5, 0),
"version": (2, 6, 0),
"blender": (3, 6, 0),
"location": "Header > Pipeline > Send to Unreal",
"description": "Sends an asset to the first open Unreal Editor instance on your machine.",
Expand Down
2 changes: 1 addition & 1 deletion src/addons/send2ue/blender_manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ schema_version = "1.0.0"
id = "send2ue"
name = "Send to Unreal"
tagline = "Send assets directly to an open Unreal Editor on your machine"
version = "2.5.0"
version = "2.6.0"
type = "add-on"
tags = [ "Pipeline" ]
blender_version_min = "4.2.0"
Expand Down
6 changes: 4 additions & 2 deletions src/addons/send2ue/core/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,12 +542,14 @@ def send2ue(properties):
utilities.escape_local_view()

# clear the asset_data and current id
bpy.context.window_manager.send2ue.asset_id = ''
bpy.context.window_manager.send2ue.asset_data.clear()
bpy.context.window_manager.send2ue.asset_id = '' # type: ignore
bpy.context.window_manager.send2ue.asset_data.clear() # type: ignore

# if there are no failed validations continue
validation_manager = validations.ValidationManager(properties)
if validation_manager.run():
# create the asset data
create_asset_data(properties)
ingest.assets(properties)

bpy.context.window_manager.send2ue.object_collection_override.clear() # type: ignore
12 changes: 9 additions & 3 deletions src/addons/send2ue/core/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,17 @@ def get_from_collection(object_type):
"""
collection_objects = []

# first check if the collection_objects is overridden
for collection_object in bpy.context.window_manager.send2ue.object_collection_override: # type: ignore
if collection_object.type == object_type:
collection_objects.append(collection_object)

# get the collection with the given name
export_collection = bpy.data.collections.get(ToolInfo.EXPORT_COLLECTION.value)
if export_collection:
# if the collection exists and the collection_objects is not overridden
if export_collection and not collection_objects:
# get all the objects in the collection
for collection_object in export_collection.all_objects:
for collection_object in export_collection.all_objects: # type: ignore
# if the object is the correct type
if collection_object.type == object_type:
# if the object is visible
Expand Down Expand Up @@ -1107,7 +1113,7 @@ def setup_project(*args):
create_collections()

# create the header menu
if importlib.util.find_spec('unpipe') is None:
if not os.environ.get('SEND2UE_HIDE_PIPELINE_MENU'):
header_menu.add_pipeline_menu()


Expand Down
3 changes: 3 additions & 0 deletions src/addons/send2ue/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ class Send2UeWindowMangerProperties(bpy.types.PropertyGroup):
"""
This class holds the properties for a window.
"""
# This can be set programmatically to override the default collection behavior.
# This is cleared back to an empty list after the send2ue operation has completed.
object_collection_override = []
# ------------- current asset info ------------------
asset_data = {}
asset_id: bpy.props.StringProperty(
Expand Down
12 changes: 8 additions & 4 deletions src/addons/send2ue/release_notes.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
## Patch Changes
* Fixed Texture filepaths post operation
* [99](https://github.com/poly-hammer/BlenderTools/pull/99)
## Features
* Enhanced Python API by allowing other scripts to set `object_collection_override` to a list of objects to override collection behavior. Check out example in [docs](https://poly-hammer.github.io/BlenderTools/send2ue/customize/python-api/#examples)
* [101](https://github.com/poly-hammer/BlenderTools/issues/101)
* [104](https://github.com/poly-hammer/BlenderTools/issues/104)
* Made the extensions repo path a list view in addons preferences.
* [102](https://github.com/poly-hammer/BlenderTools/issues/102)
* [103](https://github.com/poly-hammer/BlenderTools/pull/103)


## Special Thanks

@jack-yao91

## Tests Passing On
* Blender `3.6`, `4.2` (installed from blender.org)
Expand Down
Loading