I'm using bpy to script the export of uv maps to svg. Afterwards, I want to re-import said uv maps to generate flat models of my curved 3d models.
However, the imported .svg curves/meshes are way smaller than the original model. Moreover, there does not seem to be a constant (logical) scaling factor to scale the .svg import to fit the original dimensions.

Is it possible to either scale the uv map before exporting to represent the models true size or is there a way to scale the imported .svg to fit the models size?

My code looks as follows:

import bpy
import bmesh
import math

bpy.ops.object.mode_set(mode = 'EDIT')

SliceMe = bpy.context.object.data
SliceBM = bmesh.new()

uv_layer = SliceBM.loops.layers.uv.verify()

Scale the uv map to fit the models dimension

# Export the Slices uv map as an svg
bpy.ops.uv.export_layout(filepath="/tmp/Curve.svg",export_all=True,modified=True, mode='SVG')

# Clean the .svg up using inkscape
# To merge the curves, inkscape needs a gui. Using Xvfb (X-Server virtual
# frame buffer) create a virtual display for the gui to run in.
# Thus, no windows will pop up
subprocess.run("Xvfb :99 && export DISPLAY=:99 && inkscape -f /tmp/Curve.svg --verb=EditSelectAll --verb=SelectionUnion --verb=FileSave --verb=FileQuit &", shell=True, check=True)

# Re-import said uv map to create flat model of the curved original

Scale the import to fit the curved models dimension

Thank you!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.