Page Menu
Home
Search
Configure Global Search
Log In
Paste
P82
Test For D578
Active
Public
Actions
Authored by
Andrew Peel (andyrexic)
on Jun 5 2014, 6:43 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Tags
None
Subscribers
None
# ########################################
#
# Sample to demonstrate dynamic operator menus
# It requires https://developer.blender.org/D578
# (patch by Campbell Barton)
#
# CODE SAMPLE, SNIPPETS FOR MY OWN REFERENCE
# NO COPYRIGHT APPLIES
#
# Andrew Peel
#
# microvellum.com
# Central Point, OR USA June 2014
#
# ########################################
import
bpy
bl_info
=
{
"name"
:
"Simple Properties"
,
"author"
:
"Andrew Peel"
,
"version"
:
(
1
,
0
),
"blender"
:
(
2
,
7
,
2
),
"location"
:
"Operator Search"
,
"description"
:
""
,
"warning"
:
"Sample addon to test dynamic menu drawing, requires a patched Blender"
,
"wiki_url"
:
""
,
"tracker_url"
:
""
,
"category"
:
"Object"
}
class
OPS_simple_properties
(
bpy
.
types
.
Operator
):
bl_idname
=
"object.simple_properties"
bl_label
=
"Simple Properties"
tab
=
bpy
.
props
.
EnumProperty
(
name
=
"tab"
,
items
=
[(
'MAIN'
,
"Main"
,
""
),(
'MATERIAL'
,
"Material"
,
""
)],
description
=
"Type of properties to show"
,
default
=
'MAIN'
)
@classmethod
def
poll
(
cls
,
context
):
return
True
def
check
(
self
,
context
):
return
True
def
execute
(
self
,
context
):
return
{
'FINISHED'
}
def
invoke
(
self
,
context
,
event
):
wm
=
context
.
window_manager
return
wm
.
invoke_props_dialog
(
self
,
width
=
400
)
def
draw_main_properties
(
self
,
layout
,
context
):
obj
=
context
.
active_object
row
=
layout
.
row
(
align
=
True
)
row
.
label
(
'Dimension X:'
)
row
.
prop
(
obj
,
"lock_location"
,
index
=
0
,
text
=
''
)
if
obj
.
lock_location
[
0
]:
row
.
label
(
str
(
obj
.
location
.
x
))
else
:
row
.
prop
(
obj
,
"location"
,
index
=
0
,
text
=
""
)
row
=
layout
.
row
(
align
=
True
)
row
.
label
(
'Dimension Y:'
)
row
.
prop
(
obj
,
"lock_location"
,
index
=
1
,
text
=
''
)
if
obj
.
lock_location
[
1
]:
row
.
label
(
str
(
obj
.
location
.
y
))
else
:
row
.
prop
(
obj
,
"location"
,
index
=
1
,
text
=
""
)
row
=
layout
.
row
(
align
=
True
)
row
.
label
(
'Dimension Z:'
)
row
.
prop
(
obj
,
"lock_location"
,
index
=
2
,
text
=
''
)
if
obj
.
lock_location
[
2
]:
row
.
label
(
str
(
obj
.
location
.
z
))
else
:
row
.
prop
(
obj
,
"location"
,
index
=
2
,
text
=
""
)
def
draw_material_properties
(
self
,
layout
,
context
):
obj
=
context
.
active_object
layout
.
template_list
(
"MATERIAL_UL_matslots"
,
""
,
obj
,
"material_slots"
,
obj
,
"active_material_index"
,
rows
=
1
)
def
draw
(
self
,
context
):
layout
=
self
.
layout
layout
.
prop
(
self
,
'tab'
,
expand
=
True
)
if
self
.
tab
==
'MAIN'
:
self
.
draw_main_properties
(
layout
,
context
)
elif
self
.
tab
==
'MATERIAL'
:
self
.
draw_material_properties
(
layout
,
context
)
def
register
():
bpy
.
utils
.
register_class
(
OPS_simple_properties
)
def
unregister
():
bpy
.
utils
.
unregister_class
(
OPS_simple_properties
)
if
__name__
==
"__main__"
:
register
()
# test call
bpy
.
ops
.
object
.
simple_properties
()
Event Timeline
Andrew Peel (andyrexic)
edited the content of this paste.
(Show Details)
Jun 5 2014, 6:43 PM
Andrew Peel (andyrexic)
changed the title of this paste from untitled to
Test For D578
.
Andrew Peel (andyrexic)
updated the paste's language from
autodetect
to
python
.
Log In to Comment