-
I have some trouble with dimensions which have small values. I have created a DXF file which sets the dimension styles and use that as a template. When I add dimensions in paperspace and do a transform because of the scale of the view, I end up with a very strange dimension. I opened the exported DXF file in Bricscad. When I select the dimension and change for example the layer, it will automatically update to the correct settings. Below the function I'm using which adds the dimension. Previously I transformed the whole dimension, but rewrote it to only transform the needed points. def add_dimension(self, layout, viewport, start, end, dim_type, offset=20, text=None):
# get the scale and transformation matrix
matrix = viewport.get_transformation_matrix()
scale = viewport.get_scale()
start_pos = matrix.transform(start)
end_pos = matrix.transform(end)
if dim_type == 'horizontal':
base = (0, offset)
angle = 0
else:
base = (offset, 0)
angle = 90
dim_place = matrix.transform(base)
dim = layout.add_linear_dim(
base=dim_place,
angle=angle,
p1=start_pos,
p2=end_pos,
dimstyle='ISO-25',
override={
'dimlfac': 1 / scale,
'dimdec': 0,
}
)
if text:
dim.set_text_format(postfix=text)
dim.render() This works perfectly for placing the dimensions and for the larger dimensions. But the smaller ones needs some extra attention. Do I need an extra check myself for small values? Or is this something in ezdxf I can use? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The Here is a tutorial for overriding the default text location: https://ezdxf.mozman.at/docs/tutorials/linear_dimension.html#user-defined-text-locations |
Beta Was this translation helpful? Give feedback.
-
That would be impossible and wasn't my question. I hoped if there was a kind of function to give me the result if the arrows and text were fitting between the lines. Then I could take action on that. For example to flip the arrows, I swap the two points. For shifting the text I'm using https://ezdxf.readthedocs.io/en/stable/tutorials/linear_dimension.html#location-relative-to-default-location |
Beta Was this translation helpful? Give feedback.
The
ezdxf
dimension renderer will never be on par with CAD applications!Here is a tutorial for overriding the default text location: https://ezdxf.mozman.at/docs/tutorials/linear_dimension.html#user-defined-text-locations