2

I am trying to automate generation of a 2D plan from a 3D ship. example complex object

For that I need to get a contoured object in some projection. To accomplish that I make the object flat, but there are a lot of vertices inside the contour. This is the result I get:result

How can you delete the inner vertices and get only the contour ones? I have tried deleting and dissolving but it is not enough for complex objects, the vertices that make this hole in the exapmle object (highlighted red) still remain.

  • You might try selecting the outside vertices and then CTRL "I" to select the inverse and then dissolve vertices. – Dontwalk Feb 22 '18 at 15:00
  • 1
    Do you really want to have mesh with zero thcikness on one axis? Or an image of the side view of the mesh? If the latter it's easier to place camera (orthographic to avoid perspective distortion) to be oriented by X axis in case of the screenshot and render an image – Mr Zak Feb 22 '18 at 15:00
  • Maybe the remesh modifier? – SilverWolf Feb 22 '18 at 18:20
  • @Dontwalk I need this to be an automated thing, how can I get the outside vertices like that? – Paul Vinogradov Feb 22 '18 at 19:34
  • @MrZak Image would look like something I need, but the plan is for all the parts of a ship, and it needs to be exported to a 2D vector format (cbs,xaml), that's why I need the get projections as actual objects – Paul Vinogradov Feb 22 '18 at 19:37
  • What does it mean "all parts of the ship" in this context? You can place multiple cameras and render multiple images thus getting several sprites. I haven't heard of xaml as vector format but in anyway the only vector format Blender can write is svg, dealing with geometry or images won't change this. To use Blender Freestyle svg exporter maybe render image of the object, save it, import as image, activate freestyle and render again to export as svg – Mr Zak Feb 22 '18 at 20:22
  • Suggest dont flatten it, select all faces on end, delete the others, then dissolve all non boundary edges. Can you provide a sample file https://blend-exchange.giantcowfilms.com – batFINGER Feb 23 '18 at 05:00

4 Answers4

4

You can also do it interactive:

enter image description here Now you can simply apply the boolean and select the mesh by material if you want to.

Richy
  • 492
  • 2
  • 5
3

One possible way to achieve this is by acquiring a "skeleton" of your mesh. This is a destructive process, if you require the original mesh intact make these steps in a copy of the original.

In Edit Mode erase all faces but leaving edges by pressing X > Only Faces option.

Optionally Scale you object to zero in the desired axis or custom direction (if you don't want any of the orthogonal axis).

Add a new plane or flat mesh to your scene aligned with the desired projection direction, in such way that it stays behind the mesh you want to outline.

Select the outlining mesh, then Shif-select the plane object so it becomes the active object, while still leaving the outlining mesh selected.

Align the view to the desired projection direction, also ake sure you have a orthographic projection view (as opposed to perspective) this is important as it will determine the accuracy of the obtained outline scale and size. Enter Edit Mode in the plane object, then use Knife Project operator from the space bar menu to "imprint" the mesh onto the plane.

Select the major faces surrounding your newly obtained outline, press Ctrl + i to invert the selection and erase everything else.

You now have an outline of your mesh. Do some cleanup, like Remove Doubles and convert to a curve if that is what you desire.

enter image description here

Optionally try the SVG Output script for direct to vector exporting.

Duarte Farrajota Ramos
  • 59,425
  • 39
  • 130
  • 187
  • The selection order has changed in Blender 3 at some point. Select the object to be CUT first in edit mode, THEN shift select the object that will shape the resulting cut. – mredig Oct 18 '22 at 01:19
1

Try this (mainly Inkscape-software):

assign an Emmision-Material to your object and give it the color white,
set the camera to orthographic, in World-tab set surface-strength to zero, switch off Ambient Occlusion and render Image at at a reasonable resolution (for example: 1920x1080); safe it as png-file

Start up the free software Inkscape; load the image into it, select the image with the selection-tool (arrow) and hit SHIFT+ALT+B (draw after bitmap) - a little window opens, hit ok in it, if the preview in this window doesn't give you a proper result immediately, then play around with the numbers until it fits, the result is a path; move the resulting path a bit away from the original image with the selection-tool, select the original image and delete it (DEL-key); hit F2 to start the path-tool, with it you can box-select the points of the path you want to delete; delete the selected points with DEL-key; Hit F1, select the image and then hit SHIFT+CTRL+S, save the image in file format "Inkscape-svg".

Now you can reimport this file into blender (import-button)

user52808
  • 11
  • 1
0

Alternatively what you could do is export the STL, and import it into openscad. It has a projection method to create the outline. I found this method more accurate than exporting to PNG and use Inkscape to vertorize it. And I also found this to be more accurate than using freestyle to export the contour to svg. Depending on your purpose Freestyle might be accurate enough, but I need the vectors for lasercutting, and it needs to be exact.

This would be the script for openscad.

projection(cut=false) {
    import("C:/my/absolute/path/to/model.stl", convexity=3);
}

Make sure to face your model upwards along the z-azis, as this is the axis openscad uses for its projection. (Of course you could also use the rotate method in openscad).

Openscad can export to SVG or DXF (among others). Openscad should be usable via the commandline as well like this:

import os
import subprocess
from subprocess import run

openscadPath = "C:\Program Files\OpenSCAD\openscad.exe"

def stlToDxf(stlFilePath): openscadFileContents = "projection(cut=false) {\r\nimport("" + stlFilePath.replace('\', '\\') + "", convexity=10);\r\n}" filepath = os.path.splitext(stlFilePath)[0] + '.scad'
f = open(filepath, "w") f.write(openscadFileContents) f.close() outputFile = (os.path.splitext(stlFilePath)[0] + '.dxf') _export(filepath, outputFile)

def _export(file, outputFile): commands = [ openscadPath, "-o", outputFile, file ] rc = run(commands)

Little remark: I never meant to move away from Blender to some other software and advertise in any way for it. I really wish Blender had this accurate SVG/DXF export capability. I found the way that modeling works in Blender via its API is way easier than openscad, because Blender keeps object references.

enter image description here

See below a result I've obtained using freestyle, a top border is missing. Not sure why, I tried playing around with several settings (contour, border, silhouette)... enter image description here

Mike de Klerk
  • 393
  • 2
  • 5
  • 12
  • I did pretty much the same thing only without exporting. I wrote a python script that did all the actions that the selected answer does for all the selected objects, only with a variable for direction (front, top, left, etc), and then save all that to an SVG. After that I take that SVG and save it as a XAML? add some interaction to make every element clickable and use it in my WPF project – Paul Vinogradov Feb 05 '21 at 22:04