File: helix.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 (37 lines) | stat: -rw-r--r-- 1,029 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
33
34
35
36
37
#  Copyright (c) 2022, Manfred Moitzi
#  License: MIT License
from pathlib import Path
import math
import ezdxf

from ezdxf.math import Matrix44

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

# ------------------------------------------------------------------------------
# this example shows how to create a HELIX entity.
#
# docs: https://ezdxf.mozman.at/docs/dxfentities/helix.html
# ------------------------------------------------------------------------------


def simple_helix(filename: str):
    doc = ezdxf.new()
    msp = doc.modelspace()
    msp.add_helix(radius=5, pitch=1, turns=5)
    doc.saveas(CWD / filename)


def transform_helix(filename: str):
    doc = ezdxf.new()
    msp = doc.modelspace()
    helix = msp.add_helix(radius=5, pitch=1, turns=5)
    helix.transform(Matrix44.x_rotate(math.pi/4) @ Matrix44.translate(2, 4, 6))
    doc.saveas(CWD / filename)


if __name__ == "__main__":
    simple_helix("simple_helix.dxf")
    transform_helix("transform_helix.dxf")