Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender-addons
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
blender-addons
Commits
9f6319db
Commit
9f6319db
authored
9 years ago
by
Ines Almeida
Browse files
Options
Downloads
Patches
Plain Diff
[Selection Sets] Tweaks and optimizations
parent
70a88905
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bone_selection_sets.py
+23
-24
23 additions, 24 deletions
bone_selection_sets.py
with
23 additions
and
24 deletions
bone_selection_sets.py
+
23
−
24
View file @
9f6319db
...
@@ -84,8 +84,7 @@ class POSE_PT_selection_sets(Panel):
...
@@ -84,8 +84,7 @@ class POSE_PT_selection_sets(Panel):
def
poll
(
cls
,
context
):
def
poll
(
cls
,
context
):
return
(
context
.
object
return
(
context
.
object
and
context
.
object
.
type
==
'
ARMATURE
'
and
context
.
object
.
type
==
'
ARMATURE
'
and
context
.
object
.
pose
and
context
.
object
.
pose
)
)
def
draw
(
self
,
context
):
def
draw
(
self
,
context
):
layout
=
self
.
layout
layout
=
self
.
layout
...
@@ -94,6 +93,7 @@ class POSE_PT_selection_sets(Panel):
...
@@ -94,6 +93,7 @@ class POSE_PT_selection_sets(Panel):
arm
=
context
.
object
arm
=
context
.
object
row
=
layout
.
row
()
row
=
layout
.
row
()
row
.
enabled
=
(
context
.
mode
==
'
POSE
'
)
# UI list
# UI list
rows
=
4
if
len
(
arm
.
selection_sets
)
>
0
else
1
rows
=
4
if
len
(
arm
.
selection_sets
)
>
0
else
1
...
@@ -159,12 +159,12 @@ class POSE_OT_selection_set_add(PluginOperator):
...
@@ -159,12 +159,12 @@ class POSE_OT_selection_set_add(PluginOperator):
def
execute
(
self
,
context
):
def
execute
(
self
,
context
):
arm
=
context
.
object
arm
=
context
.
object
selection
_set
=
arm
.
selection_sets
.
add
()
new_sel
_set
=
arm
.
selection_sets
.
add
()
# naming
# naming
selection
_set
.
name
=
"
SelectionSet
"
new_sel
_set
.
name
=
"
SelectionSet
"
if
POSE_OT_selection_set_add
.
created_counter
>
0
:
if
POSE_OT_selection_set_add
.
created_counter
>
0
:
selection
_set
.
name
+=
"
.{:03d}
"
.
format
(
POSE_OT_selection_set_add
.
created_counter
)
new_sel
_set
.
name
+=
"
.{:03d}
"
.
format
(
POSE_OT_selection_set_add
.
created_counter
)
POSE_OT_selection_set_add
.
created_counter
+=
1
POSE_OT_selection_set_add
.
created_counter
+=
1
# select newly created set
# select newly created set
...
@@ -201,17 +201,17 @@ class POSE_OT_selection_set_assign(NeedSelSetPluginOperator):
...
@@ -201,17 +201,17 @@ class POSE_OT_selection_set_assign(NeedSelSetPluginOperator):
def
execute
(
self
,
context
):
def
execute
(
self
,
context
):
arm
=
context
.
object
arm
=
context
.
object
pose
=
arm
.
pose
pose
=
arm
.
pose
act_sel_set
=
arm
.
selection_sets
[
arm
.
active_selection_set
]
#if arm.active_selection_set <= 0:
#if arm.active_selection_set <= 0:
# arm.selection_sets.add()
# arm.selection_sets.add()
#TODO naming convention
#TODO naming convention
# return {'FINISHED'}
# return {'FINISHED'}
selection_set
=
arm
.
selection_sets
[
arm
.
active_selection_set
]
# iterate only the selected bones in current pose that are not hidden
for
bone
in
pose
.
bones
:
for
bone
in
context
.
selected_pose_bones
:
if
(
bone
.
bone
.
select
and
not
bone
.
bone
.
hide
if
bone
.
name
not
in
act_sel_set
.
bone_ids
:
and
bone
.
name
not
in
selection_set
.
bone_ids
):
bone_id
=
act_sel_set
.
bone_ids
.
add
()
bone_id
=
selection_set
.
bone_ids
.
add
()
bone_id
.
name
=
bone
.
name
bone_id
.
name
=
bone
.
name
return
{
'
FINISHED
'
}
return
{
'
FINISHED
'
}
...
@@ -226,14 +226,13 @@ class POSE_OT_selection_set_unassign(NeedSelSetPluginOperator):
...
@@ -226,14 +226,13 @@ class POSE_OT_selection_set_unassign(NeedSelSetPluginOperator):
def
execute
(
self
,
context
):
def
execute
(
self
,
context
):
arm
=
context
.
object
arm
=
context
.
object
pose
=
arm
.
pose
pose
=
arm
.
pose
act_sel_set
=
arm
.
selection_sets
[
arm
.
active_selection_set
]
selection_set
=
arm
.
selection_sets
[
arm
.
active_selection_set
]
# iterate only the selected bones in current pose that are not hidden
for
bone
in
context
.
selected_pose_bones
:
for
bone
in
pose
.
bones
:
if
bone
.
name
in
act_sel_set
.
bone_ids
:
if
(
bone
.
bone
.
select
and
not
bone
.
bone
.
hide
idx
=
act_sel_set
.
bone_ids
.
find
(
bone
.
name
)
and
bone
.
name
in
selection_set
.
bone_ids
):
act_sel_set
.
bone_ids
.
remove
(
idx
)
idx
=
selection_set
.
bone_ids
.
find
(
bone
.
name
)
selection_set
.
bone_ids
.
remove
(
idx
)
return
{
'
FINISHED
'
}
return
{
'
FINISHED
'
}
...
@@ -247,11 +246,11 @@ class POSE_OT_selection_set_select(NeedSelSetPluginOperator):
...
@@ -247,11 +246,11 @@ class POSE_OT_selection_set_select(NeedSelSetPluginOperator):
def
execute
(
self
,
context
):
def
execute
(
self
,
context
):
arm
=
context
.
object
arm
=
context
.
object
pose
=
arm
.
pose
pose
=
arm
.
pose
act_sel_set
=
arm
.
selection_sets
[
arm
.
active_selection_set
]
selection_set
=
arm
.
selection_sets
[
arm
.
active_selection_set
]
for
bone
in
context
.
visible_pose_bones
:
for
bone
in
pose
.
bones
:
if
bone
.
name
in
act_sel_set
.
bone_ids
:
if
not
bone
.
bone
.
hide
and
bone
.
name
in
selection_set
.
bone_ids
:
bone
.
bone
.
select
=
True
bone
.
bone
.
select
=
True
return
{
'
FINISHED
'
}
return
{
'
FINISHED
'
}
...
@@ -265,10 +264,10 @@ class POSE_OT_selection_set_deselect(NeedSelSetPluginOperator):
...
@@ -265,10 +264,10 @@ class POSE_OT_selection_set_deselect(NeedSelSetPluginOperator):
def
execute
(
self
,
context
):
def
execute
(
self
,
context
):
arm
=
context
.
object
arm
=
context
.
object
pose
=
arm
.
pose
pose
=
arm
.
pose
act_sel_set
=
arm
.
selection_sets
[
arm
.
active_selection_set
]
selection_set
=
arm
.
selection_sets
[
arm
.
active_selection_set
]
for
bone
in
context
.
selected_pose_bones
:
for
bone
in
pose
.
bones
:
if
bone
.
name
in
act_sel_set
.
bone_ids
:
if
not
bone
.
bone
.
hide
and
bone
.
name
in
selection_set
.
bone_ids
:
bone
.
bone
.
select
=
False
bone
.
bone
.
select
=
False
return
{
'
FINISHED
'
}
return
{
'
FINISHED
'
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment