Home/ Reference/ View & Performance

doc.Unit

Document unit. Every coordinate and dimension follows it: set millimetres and 100 means 100 mm; set inches and 100 means 100 inches. Set it once at the top of the sc

Signature

doc.Unit

Notes

Document unit. Every coordinate and dimension follows it: set millimetres and 100 means 100 mm; set inches and 100 means 100 inches. Set it once at the top of the script.

Python example (runnable)

Requires pywin32. The example assumes app / doc / page / layer are already connected. See Connection & Init
Python
print("Unit code: ", doc.Unit)                   # usual codes: 0=inch 4=mm

# switch to mm (code 4) so coordinates need no mental maths
try:
    doc.Unit = 4
    print("Set to mm; page width is now: ", doc.ActivePage.SizeWidth, "mm")
except Exception as e:
    print("Setting the unit failed: ", e)

About this section: View & Performance

View & Performance — display and performance switches.

Other entries in this section