Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender-addons-contrib
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-contrib
Commits
ab0aba23
Commit
ab0aba23
authored
8 years ago
by
kostex
Browse files
Options
Downloads
Patches
Plain Diff
object_mesh_versions: changed cleanup mode behaviour
parent
5108c882
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
object_mesh_versions.py
+86
-57
86 additions, 57 deletions
object_mesh_versions.py
with
86 additions
and
57 deletions
object_mesh_versions.py
+
86
−
57
View file @
ab0aba23
...
@@ -16,18 +16,21 @@
...
@@ -16,18 +16,21 @@
#
#
# ##### END GPL LICENSE BLOCK #####
# ##### END GPL LICENSE BLOCK #####
import
bpy
import
time
from
datetime
import
datetime
from
bpy.types
import
Menu
,
Panel
from
bpy.props
import
StringProperty
,
BoolProperty
bl_info
=
{
bl_info
=
{
"
name
"
:
"
KTX Mesh Versions
"
,
"
name
"
:
"
KTX Mesh Versions
"
,
"
author
"
:
"
Roel Koster, @koelooptiemanna, irc:kostex
"
,
"
author
"
:
"
Roel Koster, @koelooptiemanna, irc:kostex
"
,
"
version
"
:
(
1
,
4
,
2
),
"
version
"
:
(
1
,
4
,
3
),
"
blender
"
:
(
2
,
7
,
0
),
"
blender
"
:
(
2
,
7
,
0
),
"
location
"
:
"
View3D > Properties
"
,
"
location
"
:
"
View3D > Properties
"
,
"
category
"
:
"
Object
"
}
"
category
"
:
"
Object
"
}
import
bpy
,
time
from
datetime
import
datetime
from
bpy.types
import
Menu
,
Panel
from
bpy.props
import
StringProperty
,
BoolProperty
class
KTX_MeshInit
(
bpy
.
types
.
Operator
):
class
KTX_MeshInit
(
bpy
.
types
.
Operator
):
bl_label
=
"
Initialise Mesh Versioning
"
bl_label
=
"
Initialise Mesh Versioning
"
...
@@ -35,19 +38,20 @@ class KTX_MeshInit(bpy.types.Operator):
...
@@ -35,19 +38,20 @@ class KTX_MeshInit(bpy.types.Operator):
bl_description
=
"
Initialise the current object to support versioning
"
bl_description
=
"
Initialise the current object to support versioning
"
def
execute
(
self
,
context
):
def
execute
(
self
,
context
):
unique_id
=
str
(
time
.
time
())
unique_id
=
str
(
time
.
time
())
context
.
object
.
data
.
ktx_mesh_id
=
context
.
object
.
ktx_object_id
=
unique_id
context
.
object
.
data
.
ktx_mesh_id
=
context
.
object
.
ktx_object_id
=
unique_id
return
{
'
FINISHED
'
}
return
{
'
FINISHED
'
}
class
KTX_MeshSelect
(
bpy
.
types
.
Operator
):
class
KTX_MeshSelect
(
bpy
.
types
.
Operator
):
bl_label
=
"
Select Mesh
"
bl_label
=
"
Select Mesh
"
bl_idname
=
"
ktx.meshversions_select
"
bl_idname
=
"
ktx.meshversions_select
"
bl_description
=
"
Link the selected mesh to the current object
"
bl_description
=
"
Link the selected mesh to the current object
"
m_index
=
StringProperty
()
m_index
=
StringProperty
()
def
execute
(
self
,
context
):
def
execute
(
self
,
context
):
c_mode
=
bpy
.
context
.
object
.
mode
c_mode
=
bpy
.
context
.
object
.
mode
if
c_mode
!=
'
OBJECT
'
:
if
c_mode
!=
'
OBJECT
'
:
bpy
.
ops
.
object
.
mode_set
(
mode
=
'
OBJECT
'
)
bpy
.
ops
.
object
.
mode_set
(
mode
=
'
OBJECT
'
)
obj
=
context
.
object
obj
=
context
.
object
...
@@ -55,37 +59,52 @@ class KTX_MeshSelect(bpy.types.Operator):
...
@@ -55,37 +59,52 @@ class KTX_MeshSelect(bpy.types.Operator):
bpy
.
ops
.
object
.
mode_set
(
mode
=
c_mode
)
bpy
.
ops
.
object
.
mode_set
(
mode
=
c_mode
)
return
{
'
FINISHED
'
}
return
{
'
FINISHED
'
}
class
KTX_MeshRemove
(
bpy
.
types
.
Operator
):
class
KTX_MeshRemove
(
bpy
.
types
.
Operator
):
bl_label
=
"
Remove Mesh
"
bl_label
=
"
Remove Mesh
"
bl_idname
=
"
ktx.meshversions_remove
"
bl_idname
=
"
ktx.meshversions_remove
"
bl_description
=
"
Remove/Delete the selected mesh
"
bl_description
=
"
Remove/Delete the selected mesh
"
m_index
=
StringProperty
()
m_index
=
StringProperty
()
def
execute
(
self
,
context
):
def
execute
(
self
,
context
):
bpy
.
data
.
meshes
.
remove
(
bpy
.
data
.
meshes
[
self
.
m_index
])
bpy
.
data
.
meshes
.
remove
(
bpy
.
data
.
meshes
[
self
.
m_index
])
return
{
'
FINISHED
'
}
return
{
'
FINISHED
'
}
class
KTX_Cleanup
(
bpy
.
types
.
Operator
):
bl_label
=
"
Cleanup Mode
"
bl_idname
=
"
ktx.cleanup
"
bl_description
=
"
Cleanup Mode
"
def
execute
(
self
,
context
):
for
o
in
bpy
.
data
.
objects
:
o
.
select
=
False
context
.
scene
.
objects
.
active
=
None
return
{
'
FINISHED
'
}
class
KTX_MeshCreate
(
bpy
.
types
.
Operator
):
class
KTX_MeshCreate
(
bpy
.
types
.
Operator
):
bl_label
=
"
Create Mesh Version
"
bl_label
=
"
Create Mesh Version
"
bl_idname
=
"
ktx.meshversions_create
"
bl_idname
=
"
ktx.meshversions_create
"
bl_description
=
(
"
Create a copy of the mesh data of the current object
\n
"
bl_description
=
(
"
Create a copy of the mesh data of the current object
\n
"
"
and set it as active
"
)
"
and set it as active
"
)
def
execute
(
self
,
context
):
def
execute
(
self
,
context
):
defpin
=
bpy
.
context
.
scene
.
ktx_defpin
defpin
=
bpy
.
context
.
scene
.
ktx_defpin
obj
=
context
.
object
obj
=
context
.
object
if
obj
.
type
==
'
MESH
'
:
if
obj
.
type
==
'
MESH
'
:
c_mode
=
bpy
.
context
.
object
.
mode
c_mode
=
bpy
.
context
.
object
.
mode
me
=
obj
.
data
me
=
obj
.
data
if
c_mode
!=
'
OBJECT
'
:
if
c_mode
!=
'
OBJECT
'
:
bpy
.
ops
.
object
.
mode_set
(
mode
=
'
OBJECT
'
)
bpy
.
ops
.
object
.
mode_set
(
mode
=
'
OBJECT
'
)
new_mesh
=
me
.
copy
()
new_mesh
=
me
.
copy
()
obj
.
data
=
new_mesh
obj
.
data
=
new_mesh
obj
.
data
.
use_fake_user
=
defpin
obj
.
data
.
use_fake_user
=
defpin
bpy
.
ops
.
object
.
mode_set
(
mode
=
c_mode
)
bpy
.
ops
.
object
.
mode_set
(
mode
=
c_mode
)
return
{
'
FINISHED
'
}
return
{
'
FINISHED
'
}
class
KTX_Mesh_Versions
(
bpy
.
types
.
Panel
):
class
KTX_Mesh_Versions
(
bpy
.
types
.
Panel
):
bl_label
=
"
KTX Mesh Versions
"
bl_label
=
"
KTX Mesh Versions
"
bl_idname
=
"
ktx.meshversions
"
bl_idname
=
"
ktx.meshversions
"
...
@@ -96,45 +115,54 @@ class KTX_Mesh_Versions(bpy.types.Panel):
...
@@ -96,45 +115,54 @@ class KTX_Mesh_Versions(bpy.types.Panel):
scene
=
context
.
scene
scene
=
context
.
scene
obj
=
context
.
object
obj
=
context
.
object
layout
=
self
.
layout
layout
=
self
.
layout
if
obj
==
None
:
layout
.
label
(
'
No Object Selected
'
)
meshes_exist
=
bool
(
bpy
.
data
.
meshes
.
items
()
!=
[])
else
:
if
meshes_exist
:
if
obj
.
type
==
'
MESH
'
:
if
obj
!=
None
:
if
obj
.
ktx_object_id
!=
''
and
(
obj
.
data
.
ktx_mesh_id
==
obj
.
ktx_object_id
):
if
obj
.
type
==
'
MESH
'
:
icon
=
'
PINNED
'
if
scene
.
ktx_defpin
else
'
UNPINNED
'
if
obj
.
ktx_object_id
!=
''
and
(
obj
.
data
.
ktx_mesh_id
==
obj
.
ktx_object_id
):
row
=
layout
.
row
(
align
=
True
)
icon
=
'
PINNED
'
if
scene
.
ktx_defpin
else
'
UNPINNED
'
row
.
prop
(
scene
,
"
ktx_defpin
"
,
text
=
""
,
icon
=
icon
)
row
=
layout
.
row
(
align
=
True
)
row
.
operator
(
"
ktx.meshversions_create
"
)
row
.
prop
(
scene
,
"
ktx_defpin
"
,
text
=
""
,
icon
=
icon
)
box
=
layout
.
box
()
row
.
operator
(
"
ktx.meshversions_create
"
)
box
.
scale_y
=
0.65
box
=
layout
.
box
()
box
.
label
(
"
Currently active mesh:
"
+
obj
.
data
.
name
)
box
.
scale_y
=
0.65
for
m
in
bpy
.
data
.
meshes
:
box
.
label
(
"
Currently active mesh:
"
+
obj
.
data
.
name
)
if
m
.
ktx_mesh_id
==
obj
.
ktx_object_id
:
for
m
in
bpy
.
data
.
meshes
:
mesh_name
=
m
.
name
if
m
.
ktx_mesh_id
==
obj
.
ktx_object_id
:
row
=
box
.
row
(
align
=
True
)
mesh_name
=
m
.
name
row
.
operator
(
"
ktx.meshversions_select
"
,
text
=
""
,
icon
=
'
RIGHTARROW
'
).
m_index
=
mesh_name
row
=
box
.
row
(
align
=
True
)
row
.
prop
(
m
,
"
name
"
,
text
=
""
,
icon
=
'
MESH_DATA
'
)
row
.
operator
(
"
ktx.meshversions_select
"
,
text
=
""
,
icon
=
'
RIGHTARROW
'
).
m_index
=
mesh_name
if
m
.
users
==
0
:
row
.
prop
(
m
,
"
name
"
,
text
=
""
,
icon
=
'
MESH_DATA
'
)
row
.
operator
(
"
ktx.meshversions_remove
"
,
text
=
""
,
icon
=
"
X
"
).
m_index
=
mesh_name
if
m
.
users
==
0
:
icon
=
'
PINNED
'
if
m
.
use_fake_user
else
'
UNPINNED
'
row
.
operator
(
"
ktx.meshversions_remove
"
,
text
=
""
,
icon
=
"
X
"
).
m_index
=
mesh_name
row
.
prop
(
m
,
"
use_fake_user
"
,
text
=
""
,
icon
=
icon
)
icon
=
'
PINNED
'
if
m
.
use_fake_user
else
'
UNPINNED
'
box
.
label
()
row
.
prop
(
m
,
"
use_fake_user
"
,
text
=
""
,
icon
=
icon
)
box
.
label
()
row
=
layout
.
row
(
align
=
True
)
row
.
operator
(
"
ktx.cleanup
"
,
text
=
"
Cleanup Mode
"
)
else
:
layout
.
operator
(
"
ktx.meshversions_init
"
)
else
:
else
:
layout
.
operator
(
"
ktx.meshversions_init
"
)
layout
.
label
(
"
Select a Mesh Object
"
)
layout
.
operator
(
"
ktx.cleanup
"
,
text
=
"
Cleanup Mode
"
)
else
:
else
:
if
bpy
.
data
.
meshes
.
items
()
!=
[]:
layout
.
label
(
'
All Meshes (Cleanup/Pin):
'
)
layout
.
label
(
'
All Meshes (Cleanup/Pin):
'
)
box
=
layout
.
box
()
box
=
layout
.
box
()
box
.
scale_y
=
0.65
box
.
scale_y
=
0.65
for
m
in
bpy
.
data
.
meshes
:
for
m
in
bpy
.
data
.
meshes
:
mesh_name
=
m
.
name
mesh_name
=
m
.
name
row
=
box
.
row
(
align
=
True
)
row
=
box
.
row
(
align
=
True
)
row
.
prop
(
m
,
"
name
"
,
text
=
""
,
icon
=
'
MESH_DATA
'
)
row
.
prop
(
m
,
"
name
"
,
text
=
""
,
icon
=
'
MESH_DATA
'
)
if
m
.
users
==
0
:
if
m
.
users
==
0
:
row
.
operator
(
"
ktx.meshversions_remove
"
,
text
=
""
,
icon
=
"
X
"
).
m_index
=
mesh_name
row
.
operator
(
"
ktx.meshversions_remove
"
,
text
=
""
,
icon
=
"
X
"
).
m_index
=
mesh_name
icon
=
'
PINNED
'
if
m
.
use_fake_user
else
'
UNPINNED
'
icon
=
'
PINNED
'
if
m
.
use_fake_user
else
'
UNPINNED
'
row
.
prop
(
m
,
"
use_fake_user
"
,
text
=
""
,
icon
=
icon
)
row
.
prop
(
m
,
"
use_fake_user
"
,
text
=
""
,
icon
=
icon
)
box
.
label
()
box
.
label
()
else
:
layout
.
label
(
"
No Meshes Exist
"
)
def
register
():
def
register
():
bpy
.
types
.
Object
.
ktx_object_id
=
bpy
.
props
.
StringProperty
(
name
=
"
KTX Object ID
"
,
description
=
"
Unique ID to
'
link
'
one object to multiple meshes
"
)
bpy
.
types
.
Object
.
ktx_object_id
=
bpy
.
props
.
StringProperty
(
name
=
"
KTX Object ID
"
,
description
=
"
Unique ID to
'
link
'
one object to multiple meshes
"
)
...
@@ -149,5 +177,6 @@ def unregister():
...
@@ -149,5 +177,6 @@ def unregister():
del
bpy
.
types
.
Object
.
ktx_object_id
del
bpy
.
types
.
Object
.
ktx_object_id
del
bpy
.
types
.
Scene
.
ktx_defpin
del
bpy
.
types
.
Scene
.
ktx_defpin
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
register
()
register
()
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