Skip to content

Commit 363900e

Browse files
committed
1_6_5
Updated to lastest 2.8.0 Beta and added detection of OcclusionRoughnessMetallic for Unreal Engine Textures.
1 parent 45f4266 commit 363900e

3 files changed

Lines changed: 181 additions & 132 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Pipeline/Workflow import/export for Substance Painter.
1313
- Creates Nodes using the Principled BSDF shader.
1414
- Autosave before export option.
1515
- Use Relative Paths option.
16+
- Creates nodes for Unreal Engine Textures. * (On detection of OcclusionRoughnessMetallic texture)
1617

1718
## Selected Mesh
1819

__init__.py

Lines changed: 112 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
"name": "Substance Painter",
2121
"description": "Substance Painter Tools",
2222
"author": "Digiography.Studio",
23-
"version": (1, 5, 0),
23+
"version": (1, 6, 5),
2424
"blender": (2, 80, 0),
25-
"location": "Info Toolbar, File -> Import, File -> Export",
25+
"location": "Info Toolbar, File -> Import, File -> Export, Menu",
2626
"wiki_url": "https://github.com/Digiography/blender_addon_substance_painter/wiki",
2727
"tracker_url": "https://github.com/Digiography/blender_addon_substance_painter/issues",
2828
"category": "Import-Export",
@@ -54,7 +54,7 @@ class ds_sp_addon_prefs(bpy.types.AddonPreferences):
5454
default=True,
5555
)
5656
option_display_type : bpy.props.EnumProperty(
57-
items=[('Buttons', "Buttons", "Buttons"),('Menu', "Menu", "Menu"),('Hide', "Hide", "Hide"),],
57+
items=[('Buttons', "Buttons", "Use Buttons"),('Menu', "Menu", "Append a Menu to Main Menu"),('Hide', "Import/Export", "Use only Import/Export Menu's"),],
5858
name="Display Type",
5959
default='Buttons',
6060
)
@@ -69,7 +69,7 @@ class ds_sp_addon_prefs(bpy.types.AddonPreferences):
6969
default='png',
7070
)
7171
option_show_sp_toggle : bpy.props.BoolProperty(
72-
name="SP Toggle",
72+
name="SP Buttons Toggle",
7373
default=True,
7474
)
7575
option_show_sp_toggle_state : bpy.props.BoolProperty(
@@ -82,7 +82,7 @@ class ds_sp_addon_prefs(bpy.types.AddonPreferences):
8282
default = True
8383
)
8484
option_no_new : bpy.props.BoolProperty(
85-
name="2018.0.1+ Project File Fix",
85+
name="2018.0.1-2018.3.0 Project File Fix",
8686
description="Exclude from path for SP 2018.0.1-2018.3.0 to avoid it being added to the textures path.",
8787
default = False
8888
)
@@ -99,40 +99,134 @@ def draw(self, context):
9999
box.prop(self, 'option_export_folder')
100100
box.prop(self, 'option_textures_folder')
101101
box.label(text='Automatically created as a sub folder relative to the saved .blend file. * Do NOT include any "\\".',icon='INFO')
102+
box=layout.box()
103+
box.prop(self, 'option_show_sp_toggle')
102104
box.prop(self, 'option_relative')
103105
box.prop(self, 'option_no_new')
104106
box.prop(self, 'option_save_before_export')
105107

106-
class ds_sp_prefs_open(bpy.types.Operator):
108+
class ds_sp_menu(bpy.types.Menu):
109+
110+
bl_label = " Substance Painter"
111+
bl_idname = "ds_sp.menu"
112+
113+
def draw(self, context):
114+
115+
layout = self.layout
116+
117+
self.layout.operator(ds_sp.ds_sp_export_scene.bl_idname,icon="EXPORT")
118+
self.layout.operator(ds_sp.ds_sp_pbr_nodes.bl_idname, text='Substance Painter (Scene)', icon="IMPORT").import_setting = 'scene'
119+
120+
self.layout.operator(ds_sp.ds_sp_export_sel.bl_idname,icon="EXPORT")
121+
self.layout.operator(ds_sp.ds_sp_pbr_nodes.bl_idname, text='Substance Painter (Selected)', icon="IMPORT").import_setting = 'selected'
122+
123+
def ds_sp_draw_menu(self, context):
124+
125+
self.layout.menu(ds_sp_menu.bl_idname)
126+
127+
def ds_sp_menu_func_export_scene(self, context):
128+
129+
self.layout.operator(ds_sp.ds_sp_export_scene.bl_idname)
130+
131+
def ds_sp_menu_func_export_sel(self, context):
132+
133+
self.layout.operator(ds_sp.ds_sp_export_sel.bl_idname)
134+
135+
def ds_sp_menu_func_import_scene(self, context):
136+
137+
self.layout.operator(ds_sp.ds_sp_pbr_nodes.bl_idname, text='Substance Painter (Scene)').import_setting = 'scene'
138+
139+
def ds_sp_menu_func_import_sel(self, context):
140+
141+
self.layout.operator(ds_sp.ds_sp_pbr_nodes.bl_idname, text='Substance Painter (Selected)').import_setting = 'selected'
142+
143+
def ds_sp_draw_btns(self, context):
144+
145+
if context.region.alignment != 'RIGHT':
146+
147+
layout = self.layout
148+
row = layout.row(align=True)
149+
150+
if bpy.context.preferences.addons[__package__].preferences.option_show_sp_toggle:
151+
152+
if bpy.context.preferences.addons[__package__].preferences.option_show_sp_toggle_state:
153+
row.operator(ds_sp_toggle.bl_idname,text="SP",icon="TRIA_LEFT")
154+
else:
155+
row.operator(ds_sp_toggle.bl_idname,text="SP",icon="TRIA_RIGHT")
156+
157+
if bpy.context.preferences.addons[__package__].preferences.option_show_sp_toggle_state or not bpy.context.preferences.addons[__package__].preferences.option_show_sp_toggle:
107158

108-
bl_idname = "ds_sp.prefs_open"
109-
bl_label = "Open Preferences"
159+
row.operator(ds_sp.ds_sp_export_scene.bl_idname,text="SP:Scene",icon="EXPORT")
160+
row.operator(ds_sp.ds_sp_pbr_nodes.bl_idname, text='SP:Scene',icon="IMPORT").import_setting = 'scene'
161+
162+
row.operator(ds_sp.ds_sp_export_sel.bl_idname,text="SP:Sel",icon="EXPORT")
163+
row.operator(ds_sp.ds_sp_pbr_nodes.bl_idname, text='SP:Sel', icon="IMPORT").import_setting = 'selected'
164+
165+
class ds_sp_toggle(bpy.types.Operator):
166+
167+
bl_idname = "ds_sp.toggle"
168+
bl_label = "SP"
110169
bl_space_type = 'PROPERTIES'
111170
bl_region_type = 'WINDOW'
112-
171+
113172
def execute(self, context):
114-
115-
bpy.ops.screen.userpref_show('INVOKE_DEFAULT')
116173

174+
if not bpy.context.preferences.addons[__package__].preferences.option_show_sp_toggle_state:
175+
bpy.context.preferences.addons[__package__].preferences.option_show_sp_toggle_state=True
176+
else:
177+
bpy.context.preferences.addons[__package__].preferences.option_show_sp_toggle_state=False
117178
return {'FINISHED'}
118179

180+
classes = (
181+
ds_sp_addon_prefs,
182+
ds_sp_toggle,
183+
)
184+
119185
def register():
120186

121187
from bpy.utils import register_class
122-
123-
register_class(ds_sp_addon_prefs)
124-
register_class(ds_sp_prefs_open)
188+
for cls in classes:
189+
register_class(cls)
125190

126191
ds_sp.register()
127192

128-
def unregister():
193+
bpy.types.TOPBAR_MT_file_export.append(ds_sp_menu_func_export_scene)
194+
bpy.types.TOPBAR_MT_file_import.append(ds_sp_menu_func_import_scene)
195+
bpy.types.TOPBAR_MT_file_export.append(ds_sp_menu_func_export_sel)
196+
bpy.types.TOPBAR_MT_file_import.append(ds_sp_menu_func_import_sel)
129197

130-
from bpy.utils import unregister_class
198+
bpy.context.preferences.addons[__package__].preferences.option_show_sp_toggle_state=False
199+
200+
if bpy.context.preferences.addons[__package__].preferences.option_display_type=='Buttons':
201+
202+
bpy.types.TOPBAR_HT_upper_bar.append(ds_sp_draw_btns)
203+
204+
elif bpy.context.preferences.addons[__package__].preferences.option_display_type=='Menu':
205+
206+
register_class(ds_sp_menu)
207+
bpy.types.TOPBAR_MT_editor_menus.append(ds_sp_draw_menu)
208+
209+
def unregister():
131210

132211
ds_sp.unregister()
133212

134-
unregister_class(ds_sp_addon_prefs)
135-
unregister_class(ds_sp_prefs_open)
213+
bpy.types.TOPBAR_MT_file_export.remove(ds_sp_menu_func_export_scene)
214+
bpy.types.TOPBAR_MT_file_import.remove(ds_sp_menu_func_import_scene)
215+
bpy.types.TOPBAR_MT_file_export.remove(ds_sp_menu_func_export_sel)
216+
bpy.types.TOPBAR_MT_file_import.remove(ds_sp_menu_func_import_sel)
217+
218+
if bpy.context.preferences.addons[__package__].preferences.option_display_type=='Buttons':
219+
220+
bpy.types.TOPBAR_HT_upper_bar.remove(ds_sp_draw_btns)
221+
222+
elif bpy.context.preferences.addons[__package__].preferences.option_display_type=='Menu':
223+
224+
register_class(ds_sp_menu)
225+
bpy.types.TOPBAR_MT_editor_menus.remove(ds_sp_draw_menu)
226+
227+
from bpy.utils import unregister_class
228+
for cls in reversed(classes):
229+
unregister_class(cls)
136230

137231
if __name__ == "__main__":
138232

0 commit comments

Comments
 (0)