pythonezdxf

Change linear dimension output using ezdxf from decimal inches to architectural


Currently all my dimensions output in decimal inches. I would like to change the output to architectural but have been unable to do so. I found in the documentation that there is a 'dimlunits' and setting it's value to 4 specifies architectural. I either don't have the needed import, or am completely using it incorrectly. I have lots of loops with linear and aligned dimensions, so if there is a way to set architectural as the default rather than using override for each one that would be awesome. Any of the example changes would work as I don't know what ezdxf's output would be. Thanks.

enter image description here

import PySimpleGUI as sg
from openpyxl import load_workbook
import ezdxf
import os
import sys
from ezdxf import zoom
from ezdxf.enums import TextEntityAlignment
import time


dim1 = msp.add_linear_dim(base=(4, 24), p1=(4, 23.4375), p2=(leng2 + 4 - 2.625, 23.4375),
                          override={'dimexe': 0.25, 'dimdsep': ord('.'), 'dimlunits': 4},
                          dxfattribs={"layer": "104"})
dim1.set_tick(size=0.25)
dim1.render()

Solution

  • I found an alternative to trying to use 'dimlunits'. I needed to use the override 'dimpost' to simply append an inch mark to the end of the dimension text.

    dim1 = msp.add_linear_dim(base=(4, 24), p1=(4, 23.4375), p2=(leng2 + 4 - 2.625, 23.4375),
                              override={'dimexe': 0.25, 'dimdsep': ord('.'), 'dimpost': '<>"'},
                              dxfattribs={"layer": "104"})
    dim1.set_tick(size=0.25)
    dim1.render()