FreeCAD

Форк
0
/
Mesh2Shape.py 
37 строк · 1.1 Кб
1
# FreeCAD TemplatePyMod module
2
# (c) 2010 Werner Mayer LGPL
3

4

5
import Mesh,Part,MeshPart
6

7
faces = []
8
mesh = App.ActiveDocument.ActiveObject.Mesh
9
segments = mesh.getPlanarSegments(0.00001) # use rather strict tolerance here
10

11
for i in segments:
12
   if len(i) > 0:
13
      # a segment can have inner holes
14
      wires = MeshPart.wireFromSegment(mesh, i)
15
      # we assume that the exterior boundary is that one with the biggest bounding box
16
      if len(wires) > 0:
17
         ext=None
18
         max_length=0
19
         for i in wires:
20
            if i.BoundBox.DiagonalLength > max_length:
21
               max_length = i.BoundBox.DiagonalLength
22
               ext = i
23

24
         wires.remove(ext)
25
         # all interior wires mark a hole and must reverse their orientation, otherwise Part.Face fails
26
         for i in wires:
27
            i.reverse()
28

29
         # make sure that the exterior wires comes as first in the list
30
         wires.insert(0, ext)
31
         faces.append(Part.Face(wires))
32

33

34
shell=Part.Compound(faces)
35
Part.show(shell)
36
#solid = Part.Solid(Part.Shell(faces))
37
#Part.show(solid)
38

39

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.