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
31315311
Commit
31315311
authored
12 years ago
by
Adam Wiseman
Browse files
Options
Downloads
Patches
Plain Diff
Fixed the broken mesh functions.
parent
aab64350
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
space_view3d_copy_attributes.py
+61
-39
61 additions, 39 deletions
space_view3d_copy_attributes.py
with
61 additions
and
39 deletions
space_view3d_copy_attributes.py
+
61
−
39
View file @
31315311
...
@@ -20,12 +20,11 @@
...
@@ -20,12 +20,11 @@
bl_info
=
{
bl_info
=
{
'
name
'
:
'
Copy Attributes Menu
'
,
'
name
'
:
'
Copy Attributes Menu
'
,
'
author
'
:
'
Bassam Kurdali, Fabian Fricke,
w
iseman
303
'
,
'
author
'
:
'
Bassam Kurdali, Fabian Fricke,
Adam W
iseman
'
,
'
version
'
:
(
0
,
4
,
6
),
'
version
'
:
(
0
,
4
,
7
),
"
blender
"
:
(
2
,
6
,
1
),
'
blender
'
:
(
2
,
6
,
3
),
'
location
'
:
'
View3D > Ctrl-C
'
,
'
location
'
:
'
View3D > Ctrl-C
'
,
'
description
'
:
'
Copy Attributes Menu from Blender 2.4
'
,
'
description
'
:
'
Copy Attributes Menu from Blender 2.4
'
,
"
warning
"
:
"
some mesh functions broken
"
,
'
wiki_url
'
:
'
http://wiki.blender.org/index.php/Extensions:2.6/Py/
'
'
wiki_url
'
:
'
http://wiki.blender.org/index.php/Extensions:2.6/Py/
'
'
Scripts/3D_interaction/Copy_Attributes_Menu
'
,
'
Scripts/3D_interaction/Copy_Attributes_Menu
'
,
'
tracker_url
'
:
'
https://projects.blender.org/tracker/index.php?
'
'
tracker_url
'
:
'
https://projects.blender.org/tracker/index.php?
'
...
@@ -607,16 +606,24 @@ class MESH_MT_CopyFaceSettings(bpy.types.Menu):
...
@@ -607,16 +606,24 @@ class MESH_MT_CopyFaceSettings(bpy.types.Menu):
vc
=
len
(
mesh
.
vertex_colors
)
>
1
vc
=
len
(
mesh
.
vertex_colors
)
>
1
layout
=
self
.
layout
layout
=
self
.
layout
layout
.
operator
(
MESH_OT_CopyFaceSettings
.
bl_idname
,
op
=
layout
.
operator
(
MESH_OT_CopyFaceSettings
.
bl_idname
,
text
=
"
Copy Material
"
)[
'
mode
'
]
=
'
MAT
'
text
=
"
Copy Material
"
)
op
[
'
layer
'
]
=
''
op
[
'
mode
'
]
=
'
MAT
'
if
mesh
.
uv_textures
.
active
:
if
mesh
.
uv_textures
.
active
:
layout
.
operator
(
MESH_OT_CopyFaceSettings
.
bl_idname
,
op
=
layout
.
operator
(
MESH_OT_CopyFaceSettings
.
bl_idname
,
text
=
"
Copy Image
"
)[
'
mode
'
]
=
'
IMAGE
'
text
=
"
Copy Image
"
)
layout
.
operator
(
MESH_OT_CopyFaceSettings
.
bl_idname
,
op
[
'
layer
'
]
=
''
text
=
"
Copy UV Coords
"
)[
'
mode
'
]
=
'
UV
'
op
[
'
mode
'
]
=
'
IMAGE
'
op
=
layout
.
operator
(
MESH_OT_CopyFaceSettings
.
bl_idname
,
text
=
"
Copy UV Coords
"
)
op
[
'
layer
'
]
=
''
op
[
'
mode
'
]
=
'
UV
'
if
mesh
.
vertex_colors
.
active
:
if
mesh
.
vertex_colors
.
active
:
layout
.
operator
(
MESH_OT_CopyFaceSettings
.
bl_idname
,
op
=
layout
.
operator
(
MESH_OT_CopyFaceSettings
.
bl_idname
,
text
=
"
Copy Vertex Colors
"
)[
'
mode
'
]
=
'
VCOL
'
text
=
"
Copy Vertex Colors
"
)
op
[
'
layer
'
]
=
''
op
[
'
mode
'
]
=
'
VCOL
'
if
uv
or
vc
:
if
uv
or
vc
:
layout
.
separator
()
layout
.
separator
()
if
uv
:
if
uv
:
...
@@ -683,55 +690,70 @@ class MESH_OT_CopyFaceSettings(bpy.types.Operator):
...
@@ -683,55 +690,70 @@ class MESH_OT_CopyFaceSettings(bpy.types.Operator):
return
context
.
mode
==
'
EDIT_MESH
'
return
context
.
mode
==
'
EDIT_MESH
'
def
execute
(
self
,
context
):
def
execute
(
self
,
context
):
mode
=
getattr
(
self
,
'
mode
'
,
''
)
if
not
mode
in
(
'
MAT
'
,
'
VCOL
'
,
'
IMAGE
'
,
'
UV
'
):
self
.
report
({
'
ERROR
'
},
"
No mode specified or invalid mode.
"
)
return
self
.
_end
(
context
,
{
'
CANCELLED
'
})
layername
=
getattr
(
self
,
'
layer
'
,
''
)
mesh
=
context
.
object
.
data
mesh
=
context
.
object
.
data
mode
=
getattr
(
self
,
'
mode
'
,
'
MODE
'
)
layername
=
getattr
(
self
,
'
layer
'
,
None
)
# Switching out of edit mode updates the selected state of faces and
# Switching out of edit mode updates the selected state of faces and
# makes the data from the uv texture and vertex color layers available.
# makes the data from the uv texture and vertex color layers available.
bpy
.
ops
.
object
.
editmode_toggle
()
bpy
.
ops
.
object
.
editmode_toggle
()
polys
=
mesh
.
polygons
if
mode
==
'
MAT
'
:
if
mode
==
'
MAT
'
:
from_data
=
mesh
.
polygons
to_data
=
from_data
=
polys
to_data
=
from_data
else
:
else
:
if
mode
==
'
VCOL
'
:
if
mode
==
'
VCOL
'
:
layers
=
mesh
.
vertex_colors
layers
=
mesh
.
vertex_colors
act_layer
=
mesh
.
vertex_colors
.
active
act_layer
=
mesh
.
vertex_colors
.
active
el
se
:
el
if
mode
==
'
IMAGE
'
:
layers
=
mesh
.
uv_textures
layers
=
mesh
.
uv_textures
act_layer
=
mesh
.
uv_textures
.
active
act_layer
=
mesh
.
uv_textures
.
active
elif
mode
==
'
UV
'
:
layers
=
mesh
.
uv_layers
act_layer
=
mesh
.
uv_layers
.
active
if
not
layers
or
(
layername
and
not
layername
in
layers
):
if
not
layers
or
(
layername
and
not
layername
in
layers
):
return
_end
({
'
CANCELLED
'
})
self
.
report
({
'
ERROR
'
},
"
Invalid UV or color layer.
"
)
return
self
.
_end
(
context
,
{
'
CANCELLED
'
})
from_data
=
layers
[
layername
or
act_layer
.
name
].
data
from_data
=
layers
[
layername
or
act_layer
.
name
].
data
to_data
=
act_layer
.
data
to_data
=
act_layer
.
data
from_
face
=
from_data
[
mesh
.
poly
gon
s
.
active
]
from_
index
=
polys
.
active
for
f
in
mesh
.
poly
gon
s
:
for
f
in
polys
:
if
f
.
select
:
if
f
.
select
:
if
to_data
!=
from_data
:
if
to_data
!=
from_data
:
from_face
=
from_data
[
f
.
index
]
# Copying from another layer.
# from_face is to_face's counterpart from other layer.
from_index
=
f
.
index
elif
f
.
index
==
from_index
:
# Otherwise skip copying a face to itself.
continue
if
mode
==
'
MAT
'
:
if
mode
==
'
MAT
'
:
f
.
material_index
=
from_face
.
material_index
f
.
material_index
=
polys
[
from_index
]
.
material_index
continue
continue
to_fac
e
=
to_data
[
f
.
index
]
elif
mod
e
=
=
'
IMAGE
'
:
if
to_
face
is
from_face
:
to_
data
[
f
.
index
].
image
=
from_data
[
from_index
].
image
continue
continue
if
mode
==
'
VCOL
'
:
if
len
(
f
.
loop_indices
)
!=
len
(
polys
[
from_index
].
loop_indices
):
to_face
.
color1
=
from_face
.
color1
self
.
report
({
'
WARNING
'
},
"
Different number of vertices.
"
)
to_face
.
color2
=
from_face
.
color2
for
i
in
range
(
len
(
f
.
loop_indices
)):
to_face
.
color3
=
from_face
.
color3
to_vertex
=
f
.
loop_indices
[
i
]
to_face
.
color4
=
from_face
.
color4
from_vertex
=
polys
[
from_index
].
loop_indices
[
i
]
elif
mode
in
{
'
UV
'
,
'
IMAGE
'
}:
if
mode
==
'
VCOL
'
:
attr
=
mode
.
lower
()
to_data
[
to_vertex
].
color
=
from_data
[
from_vertex
].
color
setattr
(
to_face
,
attr
,
getattr
(
from_face
,
attr
))
elif
mode
==
'
UV
'
:
return
_end
({
'
FINISHED
'
})
to_data
[
to_vertex
].
uv
=
from_data
[
from_vertex
].
uv
return
self
.
_end
(
context
,
{
'
FINISHED
'
})
def
_end
(
retval
):
# Clean up by returning to edit mode like it was before.
bpy
.
ops
.
object
.
editmode_toggle
()
def
_end
(
self
,
context
,
retval
):
return
(
retval
)
if
context
.
mode
!=
'
EDIT_MESH
'
:
# Clean up by returning to edit mode like it was before.
bpy
.
ops
.
object
.
editmode_toggle
()
return
(
retval
)
def
register
():
def
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