Skip to content

Commit

Permalink
resolved #595: 'change object type' operator
Browse files Browse the repository at this point in the history
  • Loading branch information
PavelBlend committed Jan 17, 2023
1 parent 611f896 commit 5daab13
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 6 deletions.
77 changes: 71 additions & 6 deletions io_scene_xray/ops/props_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,6 @@ def invoke(self, context, event):
('ACTIVE', 'Active Object', 'Copy motion refs from active object.'),
('TEXT', 'Text', 'Copy motion refs from text data block.')
)
change_items = (
('ACTIVE', 'Active Object', ''),
('SELECTED', 'Selected Objects', ''),
('ALL', 'All Objects', '')
)
op_props = {
'mode': bpy.props.EnumProperty(
name='Mode',
Expand Down Expand Up @@ -348,7 +343,77 @@ def invoke(self, context, event):
return wm.invoke_props_dialog(self)


classes = (XRAY_OT_change_userdata, XRAY_OT_change_motion_refs)
type_items = (
('st', 'Static', ''),
('dy', 'Dynamic', ''),
('pd', 'Propgressive Dynamic', ''),
('ho', 'HOM', ''),
('mu', 'Multiple Usage', ''),
('so', 'SOM', ''),
)
op_props = {
'obj_type': bpy.props.EnumProperty(
name='Type',
items=type_items,
default='st'
),
'change': bpy.props.EnumProperty(
name='Change',
items=change_items,
default='SELECTED'
),
'hq_export': bpy.props.BoolProperty(name='HQ Export', default=False)
}


class XRAY_OT_change_object_type(bpy.types.Operator):
bl_idname = 'io_scene_xray.change_object_type'
bl_label = 'Change Object Type'
bl_options = {'REGISTER', 'UNDO'}

props = op_props

if not utils.version.IS_28:
for prop_name, prop_value in props.items():
exec('{0} = props.get("{0}")'.format(prop_name))

def draw(self, context):
layout = self.layout

column = layout.column(align=True)
column.label(text='Type:')
column.prop(self, 'obj_type', expand=True)

column = layout.column(align=True)
column.label(text='Change:')
column.prop(self, 'change', expand=True)

layout.prop(self, 'hq_export')

def execute(self, context):
result = search_objects(self, context)
if result == {'FINISHED'}:
return result
else:
root_objs = result

for obj in root_objs:
obj.xray.flags_simple = self.obj_type
obj.xray.flags_custom_hqexp = self.hq_export

self.report({'INFO'}, 'Objects Changed: {}'.format(len(root_objs)))
return {'FINISHED'}

def invoke(self, context, event):
wm = context.window_manager
return wm.invoke_props_dialog(self)


classes = (
XRAY_OT_change_object_type,
XRAY_OT_change_userdata,
XRAY_OT_change_motion_refs
)


def register():
Expand Down
2 changes: 2 additions & 0 deletions io_scene_xray/panels/viewport.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ class XRAY_PT_props_tools(ui.base.XRayPanel):
def draw(self, context):
layout = self.layout
col = layout.column(align=True)

col.operator(ops.props_tools.XRAY_OT_change_object_type.bl_idname)
col.operator(ops.props_tools.XRAY_OT_change_userdata.bl_idname)
col.operator(ops.props_tools.XRAY_OT_change_motion_refs.bl_idname)

Expand Down

0 comments on commit 5daab13

Please sign in to comment.