If you are seeking precision in dashes to match 4mm in length with a 45° end cap... you won't find any "easy" or automated solution within Illustrator.
Yes you can create dashed strokes with 4mm dashes in Illustrator easily.
However, you won't get any angled end caps.
You can create pattern brush artwork with 4mm lengths and an angled end cap in Illustrator.
However, because of how brushes work the 4mm in dash length will not be maintained on anything other than a strict straight path.
With the above in mind....
The only way to get such precision would be to perhaps create dashed strokes, expand the strokes then manually address the angled end cap aspect (which would mean editing each dash)
Or...
Create a pattern brush, and apply it to strokes, expand, then verify the 4mm length in each dash manually.
Either way, a time consuming venture.
One possible solution, presented by @joojaa, may be a Scatter Brush in Illustrator with all options set to Fixed
and made Relative to Path
.
It may not work for everything, but it appears promising.
It seems to me that Illustrator may be the incorrect tool for this. Not my bailiwick, but something such as a CAD program may be better suited to maintaining dash lengths and angled end caps.