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
08e558d6
Commit
08e558d6
authored
12 years ago
by
Campbell Barton
Browse files
Options
Downloads
Patches
Plain Diff
export PLY with object transformation applied.
parent
b113287a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
io_mesh_ply/export_ply.py
+47
-38
47 additions, 38 deletions
io_mesh_ply/export_ply.py
with
47 additions
and
38 deletions
io_mesh_ply/export_ply.py
+
47
−
38
View file @
08e558d6
...
...
@@ -28,14 +28,12 @@ import bpy
import
os
def
save
(
operator
,
context
,
filepath
=
""
,
use_mesh_modifiers
=
True
,
use_normals
=
True
,
use_uv_coords
=
True
,
use_colors
=
True
,
):
def
save_mesh
(
filepath
,
mesh
,
use_normals
=
True
,
use_uv_coords
=
True
,
use_colors
=
True
,
):
def
rvec3d
(
v
):
return
round
(
v
[
0
],
6
),
round
(
v
[
1
],
6
),
round
(
v
[
2
],
6
)
...
...
@@ -43,34 +41,15 @@ def save(operator,
def
rvec2d
(
v
):
return
round
(
v
[
0
],
6
),
round
(
v
[
1
],
6
)
scene
=
context
.
scene
obj
=
context
.
active_object
if
not
obj
:
raise
Exception
(
"
Error, Select 1 active object
"
)
file
=
open
(
filepath
,
"
w
"
,
encoding
=
"
utf8
"
,
newline
=
"
\n
"
)
fw
=
file
.
write
if
scene
.
objects
.
active
:
bpy
.
ops
.
object
.
mode_set
(
mode
=
'
OBJECT
'
)
if
use_mesh_modifiers
:
mesh
=
obj
.
to_mesh
(
scene
,
True
,
'
PREVIEW
'
)
else
:
mesh
=
obj
.
data
if
not
mesh
:
raise
Exception
(
"
Error, could not get mesh data from active object
"
)
# mesh.transform(obj.matrix_world) # XXX
# Be sure tessface & co are available!
if
not
mesh
.
tessfaces
and
mesh
.
polygons
:
mesh
.
calc_tessface
()
has_uv
=
(
len
(
mesh
.
tessface_uv_textures
)
>
0
)
has_vcol
=
len
(
mesh
.
tessface_vertex_colors
)
>
0
has_uv
=
bool
(
mesh
.
tessface_uv_textures
)
has_vcol
=
bool
(
mesh
.
tessface_vertex_colors
)
if
not
has_uv
:
use_uv_coords
=
False
...
...
@@ -111,7 +90,7 @@ def save(operator,
smooth
=
not
use_normals
or
f
.
use_smooth
if
not
smooth
:
normal
=
tuple
(
f
.
normal
)
normal
=
f
.
normal
[:]
normal_key
=
rvec3d
(
normal
)
if
has_uv
:
...
...
@@ -128,7 +107,7 @@ def save(operator,
v
=
mesh_verts
[
vidx
]
if
smooth
:
normal
=
tuple
(
v
.
normal
)
normal
=
v
.
normal
[:]
normal_key
=
rvec3d
(
normal
)
if
has_uv
:
...
...
@@ -200,13 +179,43 @@ def save(operator,
file
.
close
()
print
(
"
writing %r done
"
%
filepath
)
return
{
'
FINISHED
'
}
def
save
(
operator
,
context
,
filepath
=
""
,
use_mesh_modifiers
=
True
,
use_normals
=
True
,
use_uv_coords
=
True
,
use_colors
=
True
,
):
scene
=
context
.
scene
obj
=
context
.
active_object
if
not
obj
:
raise
Exception
(
"
Error, Select 1 active object
"
)
obj
.
update_from_editmode
()
if
use_mesh_modifiers
:
bpy
.
data
.
meshes
.
remove
(
mesh
)
mesh
=
obj
.
to_mesh
(
scene
,
True
,
'
PREVIEW
'
)
else
:
mesh
=
obj
.
data
.
copy
()
# XXX
"""
if is_editmode:
Blender.Window.EditMode(1,
""
, 0)
"""
if
not
mesh
:
raise
Exception
(
"
Error, could not get mesh data from active object
"
)
return
{
'
FINISHED
'
}
mesh
.
transform
(
obj
.
matrix_world
)
ret
=
save_mesh
(
filepath
,
mesh
,
use_normals
=
use_normals
,
use_uv_coords
=
use_uv_coords
,
use_colors
=
use_colors
,
)
if
use_mesh_modifiers
:
bpy
.
data
.
meshes
.
remove
(
mesh
)
return
ret
\ No newline at end of file
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