Reputation: 11
I am trying to automatically get information from 2D dxf file. The dimension class has no property about tolerance like dxf.dimtm. Such property I can find is in the DXF type Dimstyle, but that is not what I want. I found such information in dxf file looks like
A01 %%C6.14{\H0.2;\S+0.0030^ -0.0000;}
0.0030 is the upper bound and -0.0000 is the lower bound. How to get that two float using ezdxf?
appreciate to any help
Alex
Upvotes: 1
Views: 577
Reputation: 2239
In general the tolerance values are stored in the DIMSTYLE entity, but can be overridden for each DIMENSION entity, you can get them by the DimstyleOverride()
class as shown in the following example:
import ezdxf
from ezdxf.entities import DimStyleOverride
doc = ezdxf.readfile('your.dxf')
msp = doc.modelspace()
for dimension in msp.query('DIMENSION'):
dimstyle_override = DimStyleOverride(dimension)
dimtol = dimstyle_override['dimtol']
if dimtol:
print(f'{str(dimension)} has tolerance values:')
dimtp = dimstyle_override['dimtp']
dimtm = dimstyle_override['dimtm']
print(f'Upper tolerance: {dimtp}')
print(f'Lower tolerance: {dimtm}')
This is a very advanced DXF topic with very little documentation from the DXF creator, so you are on your own to find out the meaning of all the dim...
attributes. Here you can see the result of my research, but no guarantee for the correctness of the information.
Upvotes: 2