Skip to main content

Manim CAD drawing utils

This is a collecion of various functions and utilities that help creating manimations that look like CAD drawings. Also some other stuff that just looks cool.

Features:

  • Round corners
  • Chamfer corners
  • Dimensions
  • Dashed line, dashed mobject
  • Path offset mapping

Installation

manim-CAD_Drawing_Utils is a package on pypi, and can be directly installed using pip:

pip install manim-CAD_Drawing_Utils

Note: CAD_Drawing_Utils uses, and depends on SciPy and Manim.

Usage

Make sure include these two imports at the top of the .py file

from manim import *
from manim_cad_drawing_utils import *

Examples

pointer

class test_dimension_pointer(Scene):
    def construct(self):
        mob1 = Round_Corners(Triangle().scale(2),0.3)
        p = ValueTracker(0)
        dim1 = Pointer_To_Mob(mob1,p.get_value(),r'triangel', pointer_offset=0.2)
        dim1.add_updater(lambda mob: mob.update_mob(mob1,p.get_value()))
        dim1.update()
        PM = Path_mapper(mob1)
        self.play(Create(mob1),rate_func=PM.equalize_rate_func(smooth))
        self.play(Create(dim1))
        self.play(p.animate.set_value(1),run_time=10)
        self.play(Uncreate(mob1,rate_func=PM.equalize_rate_func(smooth)))
        self.play(Uncreate(dim1))
        self.wait()

pointer

dimension

class test_dimension(Scene):
    def construct(self):
        mob1 = Round_Corners(Triangle().scale(2),0.3)
        dim1 = Angle_Dimension_Mob(mob1,
                                   0.2,
                                   0.6,
                                   offset=-4,
                                   ext_line_offset=1,
                                   color=RED)
        dim2 = Linear_Dimension(mob1.get_critical_point(RIGHT),
                                mob1.get_critical_point(LEFT),
                                direction=UP,
                                offset=2.5,
                                outside_arrow=True,
                                ext_line_offset=-1,
                                color=RED)
        self.play(Create(mob1))
        self.play(Create(dim1), run_time=3)
        self.play(Create(dim2), run_time=3)
        self.wait(3)
        self.play(Uncreate(mob1), Uncreate(dim2))

dimension

hatching

class test_hatch(Scene):
    def construct(self):
        mob1 = Star().scale(2)
        # 1 hatch object creates parallel lines
        # 2 of them create rectangles
        hatch1 = Hatch_lines(mob1, angle=PI / 6, stroke_width=2)
        hatch1.add_updater(lambda mob: mob.become(Hatch_lines(mob1, angle=PI / 6, stroke_width=2)))
        hatch2 = Hatch_lines(mob1, angle=PI / 6 + PI / 2, offset=0.5, stroke_width=2)
        hatch2.add_updater(lambda mob: mob.become(Hatch_lines(mob1, angle=PI / 6 + PI / 2, offset=0.5, stroke_width=2)))

        self.add(hatch1,hatch2,mob1)
        self.play(Transform(mob1,Triangle()),run_time=2)
        self.wait()
        self.play(Transform(mob1, Circle()), run_time=2)
        self.wait()
        self.play(Transform(mob1,  Star().scale(2)), run_time=2)
        self.wait()

hatching

Dashed lines

class test_dash(Scene):
    def construct(self):
        mob1 = Round_Corners(Square().scale(3),radius=0.8).shift(DOWN*0)
        vt = ValueTracker(0)
        dash1 = Dashed_line_mobject(mob1,num_dashes=36,dashed_ratio=0.5,dash_offset=0)
        def dash_updater(mob):
            offset = vt.get_value()%1
            dshgrp = mob.generate_dash_mobjects(
                **mob.generate_dash_pattern_dash_distributed(36, dash_ratio=0.5, offset=offset)
            )
            mob['dashes'].become(dshgrp)
        dash1.add_updater(dash_updater)

        self.add(dash1)
        self.play(vt.animate.set_value(2),run_time=6)
        self.wait(0.5)

hatching

rounded corners

class Test_round(Scene):
    def construct(self):
        mob1 = RegularPolygon(n=4,radius=1.5,color=PINK).rotate(PI/4)
        mob2 = Triangle(radius=1.5,color=TEAL)
        crbase = Rectangle(height=0.5,width=3)
        mob3 = Union(crbase.copy().rotate(PI/4),crbase.copy().rotate(-PI/4),color=BLUE)
        mob4 = Circle(radius=1.3)
        mob2.shift(2.5*UP)
        mob3.shift(2.5*DOWN)
        mob1.shift(2.5*LEFT)
        mob4.shift(2.5*RIGHT)

        mob1 = Round_Corners(mob1, 0.25)
        mob2 = Round_Corners(mob2, 0.25)
        mob3 = Round_Corners(mob3, 0.25)
        self.add(mob1,mob2,mob3,mob4)

rounded_corners

cut off corners

class Test_chamfer(Scene):
    def construct(self):
        mob1 = RegularPolygon(n=4,radius=1.5,color=PINK).rotate(PI/4)
        mob2 = Triangle(radius=1.5,color=TEAL)
        crbase = Rectangle(height=0.5,width=3)
        mob3 = Union(crbase.copy().rotate(PI/4),crbase.copy().rotate(-PI/4),color=BLUE)
        mob4 = Circle(radius=1.3)
        mob2.shift(2.5*UP)
        mob3.shift(2.5*DOWN)
        mob1.shift(2.5*LEFT)
        mob4.shift(2.5*RIGHT)

        mob1 = Chamfer_Corners(mob1, 0.25)
        mob2 = Chamfer_Corners(mob2,0.25)
        mob3 = Chamfer_Corners(mob3, 0.25)
        self.add(mob1,mob2,mob3,mob4)

cutoff_corners

Metadata

Release files for manim-CAD_Drawing_Utils 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for manim-CAD_Drawing_Utils 0.0.5
File Size Uploaded Provenance Actions
manim_cad_drawing_utils-0.0.5.tar.gz 14.2 kB Without provenance Details for manim_cad_drawing_utils-0.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for manim-CAD_Drawing_Utils 0.0.5
File Interpreter ABI Platform Actions
manim_cad_drawing_utils-0.0.5-py3-none-any.whl Python 3 none any Details for manim_cad_drawing_utils-0.0.5-py3-none-any.whl

Total release size: 30.2 kB

Release files / manim_cad_drawing_utils-0.0.5.tar.gz

Download URL manim_cad_drawing_utils-0.0.5.tar.gz
Size 14.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a6cc79e72ab1c12981cd584c4d0e8d3b697300a21df26d8056ad939b42dd7c09
BLAKE2b-256 checksum
How to use checksums
380a038cdfa8cdda8936cc660ebb635b7a97651a2a2cbb5c40d34749e02bc45b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.12.8 Windows/10

Release files / manim_cad_drawing_utils-0.0.5-py3-none-any.whl

Download URL manim_cad_drawing_utils-0.0.5-py3-none-any.whl
Size 16.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a43343fefca1886bb6c252cd7ce45f976e8f3d5ec9c49ac3d3ec220fbdfb6bd5
BLAKE2b-256 checksum
How to use checksums
842620ac54cbe1365f70a11ff4aacd038edc4eee4bf9bda2b2ff84cf6ae0eb4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.12.8 Windows/10

Security for manim-CAD_Drawing_Utils 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page