Page Menu
Home
Search
Configure Global Search
Log In
Files
F18656
development_inspect_matrices.py
Public
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
John Michael Palmer (jump)
Nov 13 2013, 4:10 PM
Size
5 KB
Subscribers
None
development_inspect_matrices.py
View Options
# -*- coding: utf-8 -*-
# ##### BEGIN GPL LICENSE BLOCK #####
#
# Blender script - Inspect Matrices
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# The Original Code is Copyright (C) Feb 2012 by John Michael Palmer
# All rights reserved.
#
# Contact: john53john@gmail.com
# Information: none yet ###
#
# The Original Code is: all of this file.
#
# Contributor(s): none yet.
#
# ##### END GPL LICENSE BLOCK #####
bl_info
=
{
"name"
:
"Inspect Matrices"
,
"author"
:
"John Michael Palmer (jump)"
,
"version"
:
(
0
,
0
,
5
),
"blender"
:
(
2
,
6
,
3
),
"location"
:
""
,
"description"
:
"Inspect Matrices"
,
"warning"
:
""
,
"wiki_url"
:
""
,
"tracker_url"
:
""
\
""
,
"category"
:
"Development"
}
import
bpy
import
mathutils
as
mut
class
InspectMatricesPanel
(
bpy
.
types
.
Panel
):
bl_space_type
=
'VIEW_3D'
bl_region_type
=
'TOOLS'
bl_idname
=
'InspectMpanel'
bl_label
=
'Inspect Matrices'
def
draw
(
self
,
context
):
ob
=
context
.
active_object
sm
=
mut
.
Matrix
(
bpy
.
context
.
scene
[
'msaved'
])
matrixlist
=
[[
'World Matrix:'
,
ob
.
matrix_world
],
[
'Local Matrix:'
,
ob
.
matrix_local
],
[
'Parent Inverse Matrix:'
,
ob
.
matrix_parent_inverse
],[
'Basis Matrix:'
,
ob
.
matrix_basis
],
[
'Copied Matrix:'
,
sm
]]
lo
=
self
.
layout
morder
=
bpy
.
context
.
scene
[
'morder'
]
mvis
=
bpy
.
context
.
scene
[
'mvis'
]
for
i
in
range
(
5
):
mat
=
matrixlist
[
morder
[
i
]]
if
mvis
[
morder
[
i
]]:
b
=
lo
.
box
()
#b.scale_y = 0.4
row
=
b
.
row
()
row
.
operator
(
"matinops.dispvis"
,
text
=
mat
[
0
],
emboss
=
False
)
.
pos
=
i
if
morder
[
i
]
!=
4
:
row
.
operator
(
"matinops.copy"
,
icon
=
"COPYDOWN"
,
text
=
""
)
.
pos
=
i
row
.
operator
(
"matinops.paste"
,
icon
=
"PASTEDOWN"
,
text
=
""
)
.
pos
=
i
row
.
operator
(
"matinops.dispmove"
,
icon
=
"TRIA_UP"
,
text
=
""
,
emboss
=
False
)
.
pos
=
i
lines
=
matrix_lines
(
mat
[
1
])
c
=
b
.
column
()
c
.
scale_y
=
0.4
for
thisline
in
lines
:
c
.
label
(
thisline
)
else
:
row
=
lo
.
row
()
row
.
scale_y
=
0.5
row
.
operator
(
"matinops.dispvis"
,
text
=
mat
[
0
],
emboss
=
False
)
.
pos
=
i
@classmethod
def
poll
(
cls
,
context
):
inobjectmode
=
(
bpy
.
context
.
mode
==
'OBJECT'
)
atleastoneobject
=
bpy
.
context
.
selected_objects
!=
[]
return
(
inobjectmode
&
atleastoneobject
)
class
MatrixDispMove
(
bpy
.
types
.
Operator
):
bl_idname
=
'matinops.dispmove'
bl_label
=
'Move'
pos
=
bpy
.
props
.
IntProperty
(
default
=
0
)
def
execute
(
self
,
context
):
morder
=
context
.
scene
[
'morder'
]
pos
=
self
.
pos
if
pos
>
0
:
morder
[
pos
-
1
:
pos
+
1
]
=
morder
[
pos
],
morder
[
pos
-
1
]
return
{
'FINISHED'
}
class
MatrixDispVis
(
bpy
.
types
.
Operator
):
bl_idname
=
'matinops.dispvis'
bl_label
=
'Visible'
pos
=
bpy
.
props
.
IntProperty
(
default
=
0
)
def
execute
(
self
,
context
):
morder
=
context
.
scene
[
'morder'
]
mvis
=
context
.
scene
[
'mvis'
]
mvis
[
morder
[
self
.
pos
]]
=
not
(
mvis
[
morder
[
self
.
pos
]])
return
{
'FINISHED'
}
class
MatrixDispCopy
(
bpy
.
types
.
Operator
):
bl_idname
=
'matinops.copy'
bl_label
=
'Copy'
pos
=
bpy
.
props
.
IntProperty
()
def
execute
(
self
,
context
):
copypaste
(
self
.
pos
,
"copy"
)
return
{
'FINISHED'
}
class
MatrixDispPaste
(
bpy
.
types
.
Operator
):
bl_idname
=
'matinops.paste'
bl_label
=
'Paste'
pos
=
bpy
.
props
.
IntProperty
()
def
execute
(
self
,
context
):
copypaste
(
self
.
pos
,
"paste"
)
return
{
'FINISHED'
}
def
copypaste
(
pos
,
corp
):
ob
=
bpy
.
context
.
active_object
morder
=
bpy
.
context
.
scene
[
'morder'
]
matlist
=
[
ob
.
matrix_world
,
ob
.
matrix_local
,
ob
.
matrix_parent_inverse
,
ob
.
matrix_basis
]
index
=
morder
[
pos
]
if
index
!=
4
:
mat
=
matlist
[
index
]
if
corp
==
"copy"
:
bpy
.
context
.
scene
[
'msaved'
]
=
mtolist
(
mat
)
elif
corp
==
"paste"
:
msaved
=
mut
.
Matrix
(
bpy
.
context
.
scene
[
'msaved'
])
if
index
==
0
:
ob
.
matrix_world
=
msaved
elif
index
==
1
:
ob
.
matrix_local
=
msaved
elif
index
==
2
:
ob
.
matrix_parent_inverse
=
msaved
elif
index
==
3
:
ob
.
matrix_basis
=
msaved
#mat = msaved
def
matrix_lines
(
matin
):
s
=
str
(
matin
)
sp
=
s
.
split
(
'('
)
listout
=
[]
for
line
in
sp
:
if
')'
in
line
:
sp2
=
line
.
split
(
')'
)
listout
+=
[
sp2
[
0
]]
return
listout
def
mtolist
(
m
):
ma
=
list
(
m
)
return
[
list
(
b
)
for
b
in
ma
]
def
register
():
bpy
.
utils
.
register_module
(
__name__
)
def
unregister
():
bpy
.
utils
.
unregister_module
(
__name__
)
if
__name__
==
"__main__"
:
register
()
bpy
.
context
.
scene
[
'morder'
]
=
list
(
range
(
5
))
bpy
.
context
.
scene
[
'mvis'
]
=
[
True
]
*
5
bpy
.
context
.
scene
[
'msaved'
]
=
mtolist
(
mut
.
Matrix
.
Identity
(
4
))
File Metadata
Details
Mime Type
text/x-python
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
dd/0c/bbe9f110d79061b3d74f7f2bfa5e
Event Timeline
Log In to Comment