Skip to content
Discussion options

You must be logged in to vote
import ezdxf
from ezdxf.math import Matrix44
from ezdxf import units

doc = ezdxf.readfile("inch.dxf")

INCH_TO_MM = 25.4
m = Matrix44.scale(sx=INCH_TO_MM, sy=INCH_TO_MM, sz=INCH_TO_MM)
for entity in doc.modelspace():
    try:  # not all entities are transformable
        entity.transform(m)
    except NotImplementedError:
        print(f"ignored entity {str(entity)}")

# Not important, just to store the correct information in the DXF header:
doc.header["$INSUNITS"] = units.MM
doc.header["$MEASUREMENT"] = 1  # for metric; 0 for imperial
doc.saveas("mm.dxf")

Replies: 2 comments 3 replies

Comment options

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

Comment options

You must be logged in to vote
2 replies
@makew0rld
Comment options

@makew0rld
Comment options

Answer selected by makew0rld
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