2

I'm making a project in which I need to draw several things into a dxf file. I was using dxfwrite but I needed the HATCH function only available on ezdxf, but I cant figure out how to use the dim functions in ezdxf. any ideas?

I have the definitions but there is no clear example: https://github.com/mozman/ezdxf/blob/master/ezdxf/modern/dimension.py

already tried searching for a docstring in the function

import ezdxf

dwg = ezdxf.new('AC1015')  
msp = dwg.modelspace()  
msp.add_aligned_dim?
  • 2
    ezdxf does not support dimensions. Sorry, I can not post this as answer, because some people think facts are not answers. – mozman Jun 14 '17 at 03:09
  • @mozman, It appears that you are the author of 'ezdxf', in which case, you probably know what you are talking about. However, the link in the OPs question goes to sections of code that indicate, at first glance, that dimensions are supported. Some further explanation in your answer may have prevented its closure. I've flagged the answer for un-deleting, so we'll see what happens. If it does get un-deleted, you may want to add more detail. – Stewbob Jun 26 '17 at 19:02
  • These DIMENSION related code is just a preparation for a later implementation - which will (maybe) never happen. – mozman Jun 28 '17 at 03:00

3 Answers3

0

ezdxf does not currently support dimensions.

The DIMENSION related code linked to in the OPs question is just a preparation for a later implementation - which will (maybe) never happen.

Stewbob
  • 16,759
  • 9
  • 63
  • 107
mozman
  • 2,001
  • 8
  • 23
0

I asked similar question on github. This is the reply I got.

The dxfwrite dimensions are available as addons ezdxf.addons.dimlines, for usage see this example.

This addon is not documented. I don't want to encourage the usage of this fake dimensions because real DIMENSION support is coming to ezdxf.

That is from the author. See reply on github issue here

Isaac Sekamatte
  • 5,500
  • 1
  • 34
  • 40
0

Try this

import ezdxf
from ezdxf.tools.standards import setup_dimstyle

DIM_TEXT_STYLE = ezdxf.options.default_dimension_text_style

# create a new DXF R2010 drawing, official DXF version name: 'AC1024'
doc = ezdxf.new('R2010',setup=True)  


#create a new dimstyle
setup_dimstyle(doc,
               name='EZDXF1',
               fmt='EZ_MM_0.1_H25_MM',
               blk=ezdxf.ARROWS.closed_filled,
               style=DIM_TEXT_STYLE,
               )

dimstyle = doc.dimstyles.get('EZDXF1')
#keep dim line with text        
dimstyle.dxf.dimtmove=0

msp = doc.modelspace()
points=[(0,0),(20,0),(20,10),(0,10),(0,0)]
#draw rectang
msp.add_lwpolyline(points)
msp.add_aligned_dim(p1=(0, 0), p2=(0, 10),distance=1, dimstyle='EZDXF1')
msp.add_aligned_dim(p1=(0, 10), p2=(20, 10),distance=11, dimstyle='EZDXF1')
msp.add_aligned_dim(p1=(0, 0), p2=(20, 10),distance=1, dimstyle='EZDXF1',text="test")
doc.saveas('dim.dxf')
Adrian Wu
  • 1
  • 1