File: extrude_twist_scale_profile.py

package info (click to toggle)
ezdxf 1.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 104,528 kB
  • sloc: python: 182,341; makefile: 116; lisp: 20; ansic: 4
file content (32 lines) | stat: -rw-r--r-- 1,043 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#  Copyright (c) 2022, Manfred Moitzi
#  License: MIT License
import pathlib
import math
import ezdxf
from ezdxf.render import forms


CWD = pathlib.Path("~/Desktop/Outbox").expanduser()
if not CWD.exists():
    CWD = pathlib.Path(".")

# ------------------------------------------------------------------------------
# This example shows how to use the extended ezdxf.forms.extrude_twist_scale
# method to create a 3D figure from a base polygon (profile).
#
# docs: https://ezdxf.mozman.at/docs/render/forms.html#ezdxf.render.forms.extrude_twist_scale
# ------------------------------------------------------------------------------

DEBUG_COLOR = ezdxf.colors.CYAN

doc = ezdxf.new()
msp = doc.modelspace()


circle = list(forms.translate(forms.circle(8), (1, 0, 0)))
extrusion_path = [(0, 0, 0), (1, 0, 10)]
mesh = forms.extrude_twist_scale(
    circle, extrusion_path, close=True, caps=True, scale=2, twist=math.pi / 2
)
mesh.render_mesh(msp, dxfattribs={"color": ezdxf.colors.MAGENTA})
doc.saveas(CWD / "extrude_twist_scale_profile.dxf")