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

Enhanced Name from Resource DB + updated README.md #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Enhanced Resource DB + README.md
- Now when you click on `BP - Name from Resource DB`, you are directly prompted to select a folder
- Updated REAMDE.md (fixed typo mistake + added the new options)
  • Loading branch information
Adriwin06 committed Nov 11, 2024
commit 26242aa9e4b342631399fd283eefe102171c4ce9
20 changes: 11 additions & 9 deletions JeBobs_BP_BlenderTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from bpy.props import StringProperty, BoolProperty, IntProperty
from bpy.types import Operator
import re
from bpy_extras.io_utils import ImportHelper

def get_object_property(property, obj):
if property in obj:
Expand Down Expand Up @@ -169,17 +170,18 @@ def execute(self, context):

return {'FINISHED'}

class BPNameFromResourceDB(bpy.types.Operator):
class BPNameFromResourceDB(Operator, ImportHelper):
"""BP - Name from Resource DB"""
bl_idname = "object.name_from_resource_db"
bl_label = "BP - Name from Resource DB"
bl_options = {'REGISTER', 'UNDO'}

filename_ext = "" # No file extension since we're selecting a directory
use_filter_folder = True # Allow folder selection

folder_path: StringProperty(
name="Folder Path",
directory: StringProperty(
name="Directory",
description="Folder containing JSON files",
default=os.path.expanduser("~"), # Set home folder as the default
maxlen=1024,
subtype='DIR_PATH'
)

Expand All @@ -203,14 +205,14 @@ def find_name_by_id(self, json_data, object_id):
return None

def execute(self, context):
if not os.path.exists(self.folder_path):
self.report({'ERROR'}, f"Path not found: {self.folder_path}")
if not os.path.exists(self.directory):
self.report({'ERROR'}, f"Path not found: {self.directory}")
return {'CANCELLED'}

json_data = {}
for filename in os.listdir(self.folder_path):
for filename in os.listdir(self.directory):
if filename.endswith(".json"):
with open(os.path.join(self.folder_path, filename), 'r') as json_file:
with open(os.path.join(self.directory, filename), 'r') as json_file:
data = json.load(json_file)
json_data.update({k.lower(): v for k, v in data.items()})

Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ Helper tools to work within the workflow of Burnout Paradise assets, in tandem w

You should now be able to see the options:
- `Add` > `BP - Create Car Empties`
- `Object` > `BP - Name from Resource DB`
- `Object` > `BP - Delete LOD Renderables`
- `Object` > `BP - Delete Shared Assets`
- `Object` > `BP - Delete Prop Parts`
- `Object` > `BP - Delete Prop Altematives`
- `Object` > `BP - Delete Backdrops`
- `Object` > `BP - Create Polygon Soup`

in their respctive context menus or in your search panel, in object mode.
in their respective context menus or in your search panel, in object mode.