Skip to content

Question about scaling base point #1065

Answered by mozman
Hairo asked this question in Q&A
Discussion options

You must be logged in to vote
  1. Move the entity from its current position (around the scaling point) to the origin (0, 0, 0) of the coordinate system.
  2. Scale the entity while it is positioned at the origin.
  3. Move the scaled entity back to its original position around the scaling point.
import ezdxf
from ezdxf.math import Matrix44


def main():
    doc = ezdxf.new()
    msp = doc.modelspace()
    circle = msp.add_circle((100, 100), radius=5)
    doc.saveas("circle_orig.dxf")

    move_to_origin = Matrix44.translate(-100, -100, 0)
    scale = Matrix44.scale(0.5, 0.5, 1)
    move_back = Matrix44.translate(100, 100, 0)
    circle.transform(move_to_origin @ scale @ move_back)

    doc.saveas("circle_scaled_at_center.dxf")


if 

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Hairo
Comment options

Answer selected by Hairo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants