Giter Site home page Giter Site logo

addam / export-paper-model-from-blender Goto Github PK

View Code? Open in Web Editor NEW
401.0 30.0 53.0 1.41 MB

Python addon for creating paper models in Blender (development version)

Home Page: https://blenderartists.org/t/export-paper-model/476597

Python 100.00%
blender-addon blender

export-paper-model-from-blender's Introduction

Export-Paper-Model-from-Blender

Python addon that lets you create paper models directly from Blender objects, even complex ones. Just clicking a button and selecting a file name produces results.

preview

The script is included in Blender. Do not install from this repository unless you have an explicit reason. This branch is only compatible with Blender 2.83 or newer.

Features:

  • Textured meshes, both painted and procedural
  • Markers describing which parts stick together
  • Customizable colors and line style
  • Visualization of the net in UV editor and 3D View
  • Interactive recalculation in Edit Mode

Documentation is available on the github.io site.

export-paper-model-from-blender's People

Contributors

addam avatar comac2k avatar hannesdelbeke avatar jdugge avatar tlecomte avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

export-paper-model-from-blender's Issues

create flat blender object ?

Hello !

I am trying to create an unfolded mesh inside blender, as a new object, not as a svg file.
Is it possible using your wonderful script ?
Or do you know a way to achieve this ?

The goal is to prototype fabric and plastic film shapes for real construction projects.

Thanks !

Error: Circular reference in texture stack

Hi,
I'm starting to get issues when trying to export a model with a painted texture. I have everything set up as described on the wiki page (and as I have done many times before), but every time I try export the model with the texture (using Blender Internal), I get a "Circular reference in texture stack" error.
image

When I try export using Cycles, I get the below error.
image

I have also tried with older meshes (from at least a year or two ago) where it used to work, and I get the same issues. Part of me is hoping I've just forgotten something really obvious!

-Eoin

Duplicate island names when manually marking seams

When new islands are generated by applying the Unfold operator after marking additional seams on an already unfolded model, the islands no longer have unique names. Instead, the "child" islands resulting from splitting a larger "parent" island have the parent island's name.

It would be nice to have an option to force the regeneration of unique island names.

Rendered images should be cleaned up

Especially when trying the best settings and exporting the same object multiple times, there appear loads of images. The script should try to remove them from blender (if that is possible at all).

output number of pages should vary

Currently, for a given 3d mesh output comes in 3 pages. Options within blender do not allow to change this. It should let user can number of pages. How is it possible ??

Thank you

N-gons with holes

First of all thank you much for that addon, i have many fun time with it. For now try to solve one issue, using paper model addon impacted with:

i reported to blender org developers, not asking here
If i have Ngon with concaved inside vertices, why it not works?
try to make that on image - holes to connect mesh with bolts:

bugreport

To unfold mesh use your addon, to make holes use sverchok + my scripted node making circles inside polygon on middle point and rotating automatically. Tried welded and separated vertex, all the same:

Traceback (most recent call last):
  File "/home/olo/.config/blender/2.78/scripts/addons/io_export_paper_model.py", line 1845, in execute
    unfolder.prepare(cage_size, self.do_create_uvmap, mark_seams=True, priority_effect=priority_effect, scale=sce.unit_settings.scale_length/settings.scale)
  File "/home/olo/.config/blender/2.78/scripts/addons/io_export_paper_model.py", line 168, in prepare
    self.mesh.generate_cuts(cage_size / scale if cage_size else None, priority_effect)
  File "/home/olo/.config/blender/2.78/scripts/addons/io_export_paper_model.py", line 300, in generate_cuts
    if island_a.join(island_b, edge, size_limit=page_size):
  File "/home/olo/.config/blender/2.78/scripts/addons/io_export_paper_model.py", line 981, in join
    raise UnfoldError("Export failed. Please report this error, including the model if you can.")
io_export_paper_model.UnfoldError: Export failed. Please report this error, including the model if you can.

TypeError: normal() takes exactly 4 arguments (1 given) when exporting or unfolding

Hi
I'm a total noob in Blender and python-in-blender so may be I've missed a very simple step.

I've installed the addon (git clone, Ctrl-Alt-U, choose python file, activate the plugin)
On the starting scene with the cube when i do File->Export->Paper Model i get an
"TypeError: normal() takes exactly 4 arguments (1 given) " on line 783

The line 783 is self.normal = M.geometry.normal(v.co for v in self.verts)

In the Blender-python console if i try
import mathutils as M
cubedata = bpy.data["Cube"]
for v in cubedata.vertices:
print(M.geometry.normal(v.co))
i get the same message

Blender 2.72 on Debian 8

Best regards.

Add plotter-related settings

Cutting out paper models with a plotter is a very attractive method. In order to make it possible and comfortable, the script should:

  1. Create a separate file for cutting and another one for printing (just a guess, please confirm)
  2. Display alignment marks in the corners of the paper (requested by @alpharesearch)
  3. Add an optional margin to baked textures (requested by @jdugge)
  4. Always draw folds in dashed lines for cutting and optionally differentiate convex and concave folds using a colored solid line (just a guess, please confirm)

tabs are cut by my cutting plotter

Hello,
I'm using a Silhouette SD cutting plotter with Robocut https://launchpad.net/robocut and Ubuntu 10.10... I can export the SVG from Blender via your script (thank you!), everything works very good.
The cutting plotter software cuts the path just fine, however the tabs are not connected with dashed lines so it cuts the lines off as well.
It would be nice if the script could generate different layers in the SVG file. Like a print layer with all the lines also on the tabs and a cut layer with dashed lines on the tabs. The cut layer could be disabled by default.
Regards,
Markus

make page size buttons

It would be nice to have buttons (or drop down list) to specify the page size, like the most used sizes world wide (all in mm):
A4 = 210 × 297
A3 = 297 × 420
letter = 216 × 279
legal = 216 × 356
PS: sorry I don't how to use labels

Handle edges that interconnect three or more faces

In the current basic design, every edge is expected to be between 0, 1 or 2 faces. Blender, however, allows us to connect any number of faces to an edge, and sometimes it is useful.
The script should handle it somehow.

Make glue tabs alternate

As of tight now, if you export a paper model using the script, it usually places the tabs so all/most of the tabs ar all on the same side of a seam, making it harder to glue the model correctly. Making the tabs alternate every edge on a seam (or having the option to) would greatly improve the quality of models made using this script.

Exception while exporting

Hey there,

not sure if this is still maintained, but anyways...
I am seeing the following exception while exporting a model:

Traceback (most recent call last):
  File "/home/asdasdasd/.config/blender/2.73/scripts/addons/io_export_paper_model.py", line 1837, in invoke
    self.unfolder.prepare(cage_size, create_uvmap=self.do_create_uvmap, scale=sce.unit_settings.scale_length/self.scale)
  File "/home/asdasdasd/.config/blender/2.73/scripts/addons/io_export_paper_model.py", line 160, in prepare
    self.mesh.generate_cuts(cage_size / scale if cage_size else None, priority_effect)
  File "/home/asdasdasd/.config/blender/2.73/scripts/addons/io_export_paper_model.py", line 284, in generate_cuts
    if island_a.join(island_b, edge, size_limit=page_size):
  File "/home/asdasdasd/.config/blender/2.73/scripts/addons/io_export_paper_model.py", line 1003, in join
    segments.sort(key=slope_from(position))
  File "/home/asdasdasd/.config/blender/2.73/scripts/addons/io_export_paper_model.py", line 904, in slope
    return (vec.y / vec.length + 1) if ((vec.x, vec.y) > (0, 0)) else (-1 - vec.y / vec.length)
ZeroDivisionError: float division by zero

If you want me to provide you with the file, please tell me.

Ignore flat surfaces

Flat surface (consisting of many faces) should be never cut. If it has interior vertices, these should be ignored as if it was just a plane.
There must be user setting for "flatness" or, better, an intelligent decision algorithm.

Image in SVG file is out of paper

When I open exported SVG file, image with UV map is placed totally out of paper, in a left upper corner of working place. It's a small thing . . .
(Tested in Illustrator CS5)

Generated UV layout should be reused

Every time an object gets exported, there's a new UV layout added. For simplicity and clarity, the script should reuse the old UV layout. To prevent unwanted edits, it could check that the user has not changed the generated layout by hand.

Division by zero

Hi,

When I try to export a model of mine I get the following error:

There are 62 twisted face(s) with ids: 0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 52, 53, 55, 56, 57, 60, 61, 64, 66, 67, 68, 69, 70, 71
Traceback (most recent call last):
  File "/home/smimram/.blender/2.63/scripts/addons/io_export_paper_model.py", line 1467, in invoke
    self.unfolder.prepare(create_uvmap=self.do_create_uvmap)
  File "/home/smimram/.blender/2.63/scripts/addons/io_export_paper_model.py", line 168, in prepare
    self.mesh.generate_cuts()
  File "/home/smimram/.blender/2.63/scripts/addons/io_export_paper_model.py", line 265, in generate_cuts
    if island_a.join(island_b, edge):
  File "/home/smimram/.blender/2.63/scripts/addons/io_export_paper_model.py", line 852, in join
    rot = fitting_matrix(first_b - second_b, uvedge_a.vb - uvedge_a.va)
  File "/home/smimram/.blender/2.63/scripts/addons/io_export_paper_model.py", line 125, in fitting_matrix
    return (1/v1.length_squared)*M.Matrix((
ZeroDivisionError: float division by zero

location:<unknown location>:-1

location:<unknown location>:-1

Do you have an idea of what could have gone wrong? I guess that v1.length_squared was null because I have a vector of null length somewhere...

Thanks!

Provide tab/space functionality for laser cutting plywood etc

I don't think it would be too difficult to modify the tabbing behaviour to place a square tab (or series of them) instead of the paper tabs, and alternated tabs on the other part to make "snap together" plywood panels. These would then be cut on a laser cutter or CNC machine. I already use BlenderCAM for machining on a CNC router. Excellent work, BTW!!

Objects must be uncomfortably small to be exported

Because the script uses directly world dimensions (so that the default cube is 2x2x2 meters), the user usually has to scale the exported object down many times. Not only it is one more step to do, it can cause problems with view clipping and depth buffer resolution.

The script could have a scale setting, likely as SSS has. The default value should be somewhat sensible so that the default cube and Suzanne will get exported flawlessly :)

Divide islands that are too big to fit the page

If a generated island is bigger than the page, the script fails with an error message about the objects scale.
It should try to divide the island so that it fits the page instead. The process may fail only when a single face is bigger than the whole page.

Flipped normals

Edge between two faces with opposite normals will be always marked as cut. Although there is some sense to it, it is usually not wanted and rather surprising to the user.

The script should try to handle these cases or, at least, notify the user when such a problem occurs.

Find and solve overlaps of faces

When two faces of an island overlap, the exported net becomes unusable.
Such cases should be detected and if they occur, the island must be split to two.

support for Inkscape layers

I did add Inkscape layers to the SVG output, please have a look at my clone and let me know if this is something you are interested... if so I could create a patch or you can just copy the part.

Edge number on inside of the net

It would be useful to have an option of putting the edge number on the inside of the net when create tabs is also enabled. It would make the assembly much easier on a more complicated model.

The script does not work Bug

hello
I installed the script
but when I give "Make unfoldable"
error
Traceback (most recent call last):
File "C: \ Users \ Nico \ AppData \ Roaming \ Blender Foundation \ Blender \ 2.63 \ scripts \ addons \ io_export_paper_model.py", line 1271, in execute
UNFOLDER = Unfolder (context, active_object)
File "C: \ Users \ Nico \ AppData \ Roaming \ Blender Foundation \ Blender \ 2.63 \ scripts \ addons \ io_export_paper_model.py", line 128, in init
self.mesh = Mesh (ob_data, ob_matrix_world)
Foundation \ Blender \ 2.63 \ scripts \ addons \ io_export_paper_model.py ", line 181, in init
for bpy_face in mesh.faces:
Attribute error: 'Mesh' object has no attribute 'faces'
location: : -1
I can't export

Create description tags

The script should have an interactive mode when the user may define descriptions for all islands. These descriptions would then be written besides the islands and on all tabs that are to be glued on them.
A renderable version of the tags pointing at their parts of the model could be also generated.

Traceback error when exporting with textures

When the textures parameter is anything but "No Textures", the output isn't created and I get this traceback error:

Traceback (most recent call last):
  File "C:\Users\snuggles08\AppData\Roaming\Blender Foundation\Blender\2.71\scri
pts\addons\io_export_paper_model.py", line 1833, in execute
    self.unfolder.save(self.properties)
  File "C:\Users\snuggles08\AppData\Roaming\Blender Foundation\Blender\2.71\scri
pts\addons\io_export_paper_model.py", line 232, in save
    self.mesh.save_separate_images(tex, printable_size.y * ppm, filepath, do_emb
ed=True)
  File "C:\Users\snuggles08\AppData\Roaming\Blender Foundation\Blender\2.71\scri
pts\addons\io_export_paper_model.py", line 598, in save_separate_images
    image.save()
RuntimeError: Error: Image 'tmp7ondnh65.png' could not be saved to 'C:\Users\SNU
GGL~1\AppData\Local\Temp\tmp7ondnh65.png'

Use paper thickness

If the paper used is really thick, it has an influence on the model. If the script knew the paper thickness, it would work better.

Improve the algorithm that fits the islands onto page

A long-term target.
The algorithm has two main problems:

  • Quite often, it will leave right side of the page nearly empty.
  • It does not fill hollow islands at all. That is especially noticeable when unfolding a torus.

Texture is rendered incorrectly

I'm trying to project an equirectangular image onto an icosphere. This is my blend file
bugreport.blend.zip

Instead of the texture as seen in the viewport & renders, I get this:

generated_image

What I expected is an unwrap of this:

viewport

This is with both the version shipped with Blender-2.78-rc1 as the latest from this git repo's master branch.

Normal() takes 4 arguments (1 given)

I have never used this addon. When I try to export, it says

line 799, in __init__
    self.normal = M.geometry.normal(v.co for v in self.vertices)
TypeError: normal() takes exactly 4 arguments (1 given) 

I have checked that the generator used as an argument, generates 3 Vector

I haven't marked seams or anything. I admit I don't know how to use it, but assumptions should be checked and error messages with usage hints should be printed

Save each image separately

If each island had its image as a separate file in the SVG, it would be possible to change the layout as easily as when exporting a "pure net".
Each image would be saved in a newly created directory, because there can be hundreds of them. Or, optionally, the script could read them all, embed them into the SVG file and then remove the image files from disk.

Notify the user about tilted quads

If there are quads in the model that are not flat, the user should be notified. They may wish to cancel the export process and edit their model beforehand.

Add curvature modeling support

Imagine I wanted to make a smooth cylinder. I would have to make a mesh with a lot of facets. Instead, I could just used a single curved sheet.
This would simplify construction of models, since a quad can be represented with the four resulting parameters (3 × plane + 1 × curvature) so there would be no need for triangulation.

Feature request add margin option

because the cutting plotter can not cut so close the the page edge it would be nice if one could enter a margin for left 1cm, right 1 cm, top 1cm, bottom 4 cm

Previews on this website

Create several preview models and give them for download on this site. The cube isn't enough.

Thanks! for a wonderful program/script

I'm not sure how to word this exactly, but after reviewing Pepakura and Waybe for sketchup, I would like to see something that allows for more complex builds, I am trying to build warships like the Spruance class destroyer, but am limited by both programs because they were designed for simple builds such as facial masks, what we really need is something that incorporates more organic builds like a vase or in my case a sonar bulb for the bow.

I haven't had time to try your script as of yet but look forward to it, other minor suggestions would included the following, an
unfold button, side by side 3d/unfold views, and grouping larger models into smaller groups/parts with matching number tabs for building the model together and adding import of .skp files

Thanks again!

Unicode Error on lines 1393 and 1396

Problem loading in blender. Needs to be changed from:
('DOT', "Dots (· · ·)", "Dotted line"),
and
('DASHDOT', "Dash-dotted (-- ·)", "Solid line")]
to
('DOT', "Dots (. . .)", "Dotted line"),
and
('DASHDOT', "Dash-dotted (-- .)", "Solid line")]

Notice the full stops instead of the dots. Not as nice but it doesn't work without it.

Overlap detection algorithm sometimes fails

It does not happen often, but the overlap detection can allow faces within an island to overlap.

The algorithm detects only line-line intersection, but in certain (artificial) circumstances, two faces can overlap so that there are vertex-vertex or vertex-line intersections only. A simple example can be downoaded from: http://adam.dominec.eu/fail.blend

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.