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
4c8bfbe8
Commit
4c8bfbe8
authored
12 years ago
by
Campbell Barton
Browse files
Options
Downloads
Patches
Plain Diff
add option to copy textures on export.
parent
4d24e706
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
object_print3d_utils/__init__.py
+5
-0
5 additions, 0 deletions
object_print3d_utils/__init__.py
object_print3d_utils/export.py
+34
-0
34 additions, 0 deletions
object_print3d_utils/export.py
object_print3d_utils/ui.py
+4
-2
4 additions, 2 deletions
object_print3d_utils/ui.py
with
43 additions
and
2 deletions
object_print3d_utils/__init__.py
+
5
−
0
View file @
4c8bfbe8
...
...
@@ -66,6 +66,11 @@ class Print3DSettings(PropertyGroup):
(
'
OBJ
'
,
"
OBJ
"
,
""
)),
default
=
'
STL
'
,
)
use_export_texture
=
BoolProperty
(
name
=
"
Copy Textures
"
,
description
=
"
Copies textures on export to the output path
"
,
default
=
False
,
)
export_path
=
StringProperty
(
name
=
"
Export Directory
"
,
description
=
"
Path to directory where the files are created
"
,
...
...
This diff is collapsed.
Click to expand it.
object_print3d_utils/export.py
+
34
−
0
View file @
4c8bfbe8
...
...
@@ -24,6 +24,31 @@ import bpy
import
os
def
image_copy_guess
(
filepath
,
objects
):
# 'filepath' is the path we are writing to.
import
shutil
from
bpy_extras
import
object_utils
image
=
None
for
obj
in
objects
:
image
=
object_utils
.
object_image_guess
(
obj
)
if
image
is
not
None
:
break
if
image
is
not
None
:
imagepath
=
bpy
.
path
.
abspath
(
image
.
filepath
,
library
=
image
.
library
)
if
os
.
path
.
exists
(
imagepath
):
filepath_noext
=
os
.
path
.
splitext
(
filepath
)[
0
]
ext
=
os
.
path
.
splitext
(
imagepath
)[
1
]
imagepath_dst
=
filepath_noext
+
ext
print
(
"
copying texture: %r -> %r
"
%
(
imagepath
,
imagepath_dst
))
try
:
shutil
.
copy
(
imagepath
,
imagepath_dst
)
except
:
import
traceback
traceback
.
print_exc
()
def
write_mesh
(
context
,
info
,
report_cb
):
scene
=
context
.
scene
print_3d
=
scene
.
print_3d
...
...
@@ -32,6 +57,7 @@ def write_mesh(context, info, report_cb):
obj
=
obj_base
.
object
export_format
=
print_3d
.
export_format
path_mode
=
'
COPY
'
if
print_3d
.
use_export_texture
else
'
AUTO
'
context_override
=
context
.
copy
()
...
...
@@ -111,6 +137,7 @@ def write_mesh(context, info, report_cb):
filepath
=
filepath
,
use_mesh_modifiers
=
True
,
use_selection
=
True
,
path_mode
=
path_mode
,
)
elif
export_format
==
'
WRL
'
:
addon_ensure
(
"
io_scene_vrml2
"
)
...
...
@@ -120,6 +147,7 @@ def write_mesh(context, info, report_cb):
filepath
=
filepath
,
use_mesh_modifiers
=
True
,
use_selection
=
True
,
path_mode
=
path_mode
,
)
elif
export_format
==
'
OBJ
'
:
addon_ensure
(
"
io_scene_obj
"
)
...
...
@@ -129,10 +157,16 @@ def write_mesh(context, info, report_cb):
filepath
=
filepath
,
use_mesh_modifiers
=
True
,
use_selection
=
True
,
path_mode
=
path_mode
,
)
else
:
assert
(
0
)
# for formats that don't support images
if
export_format
in
{
'
STL
'
,
'
PLY
'
}:
if
path_mode
==
'
COPY
'
:
image_copy_guess
(
filepath
,
context_override
[
"
selected_objects
"
])
if
obj_base_tmp
is
not
None
:
obj
=
obj_base_tmp
.
object
mesh
=
obj
.
data
...
...
This diff is collapsed.
Click to expand it.
object_print3d_utils/ui.py
+
4
−
2
View file @
4c8bfbe8
...
...
@@ -110,11 +110,13 @@ class Print3DToolBar:
col
=
layout
.
column
()
col
.
label
(
"
Export Directory:
"
)
col
.
prop
(
print_3d
,
"
export_path
"
,
text
=
""
)
rowsub
=
col
.
row
()
rowsub
.
prop
(
print_3d
,
"
export_path
"
,
text
=
""
)
rowsub
.
prop
(
print_3d
,
"
use_export_texture
"
,
text
=
""
,
icon
=
'
FILE_IMAGE
'
)
rowsub
=
col
.
row
(
align
=
True
)
rowsub
.
prop
(
print_3d
,
"
export_format
"
,
text
=
""
)
rowsub
.
operator
(
"
mesh.print3d_export
"
,
text
=
""
,
icon
=
'
EXPORT
'
)
rowsub
.
operator
(
"
mesh.print3d_export
"
,
text
=
"
Export
"
,
icon
=
'
EXPORT
'
)
Print3DToolBar
.
draw_report
(
layout
,
context
)
...
...
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