AutoCAD-style dimensioning utilities for Julia drawings, with direct support for Plots.jl.
set_dimstyleglobal style configurationdim_linearfor horizontal/vertical linear dimensionsdim_alignedfor true-length aligned dimensionsdim_angularfor angle dimensionsdim_arcfor arc-length dimensionsdim_centerfor center marksdim_joggedfor jogged/broken linear dimensionsdim_radialfor radius dimensionsdim_diameterfor diameter dimensionsdim_ordinatefor x/y ordinate dimensionsdim_baselinefor baseline/stacked linear dimensionsdim_continuefor continued chain dimensions- Rendering through
RecipesBaseso objects can be plotted directly inPlots.jl
using Pkg
Pkg.develop(path=".")
Pkg.instantiate()using DrawingDim
using Plots
set_dimstyle(
text_height = 8.0,
arrow_size = 3.0,
color = :black,
unit_suffix = " mm",
decimals = 1,
)
p1 = (10.0, 10.0)
p2 = (70.0, 25.0)
d1 = dim_linear(p1, p2; orientation=:horizontal, offset=15)
d2 = dim_aligned(p1, p2; offset=-10)
d3 = dim_angular((40.0, 40.0), (70.0, 40.0), (55.0, 62.0); radius=18)
d3b = dim_arc((40.0, 40.0), (58.0, 40.0), (40.0, 58.0); radius=18)
dcenter = dim_center((40.0, 40.0); size=10)
djog = dim_jogged((10.0, 30.0), (70.0, 30.0); orientation=:horizontal, offset=12, jog_size=5)
d4 = dim_radial((40.0, 40.0), (58.0, 40.0); offset=8)
d5 = dim_diameter((40.0, 40.0), (40.0, 58.0))
d6 = dim_ordinate((70.0, 25.0); axis=:x, origin=(0.0, 0.0), offset=10, tol_plus=0.2, tol_minus=0.1)
dbase = dim_baseline((10.0, 10.0), (30.0, 10.0), (50.0, 10.0); orientation=:horizontal, offset=20)
dcont = dim_continue((10.0, 20.0), (30.0, 20.0), (50.0, 20.0); orientation=:horizontal, offset=5)
plot(legend=false, aspect_ratio=:equal)
plot!(d1)
plot!(d2)
plot!(d3)
plot!(d3b)
plot!(dcenter)
plot!(djog)
plot!(d4)
plot!(d5)
plot!(d6)
plot!(dbase)
plot!(dcont)DimStyle(; kwargs...)set_dimstyle(; kwargs...)(sets active style)current_dimstyle()dimstyle!(style)reset_dimstyle!()
Important style options:
arrowhead_style(:closed_filled,:closed,:closed_blank,:open,:open30,:open90,:open_out,:open30_out,:open90_out,:small_open,:oblique,:tick,:dot,:dot_small,:hook,:none)text_font(GR-safe default:"Helvetica")text_orientation(:aligned,:horizontal,:vertical)text_placement(:above,:below,:centered)fit_mode(:best,:text_inside,:text_outside)hand_drawn(true/false) andhand_drawn_amplitude,hand_drawn_wigglestolerance_mode(:symmetric,:deviation,:none)
Preferred style example:
set_dimstyle(
arrowhead_style=:small_open,
text_font="Helvetica",
text_orientation=:aligned,
text_placement=:above,
fit_mode=:best,
hand_drawn=false,
tolerance_mode=:symmetric,
tolerance_plus=0.05,
)Color note: use color=:black (or any symbol/color supported by your backend) in set_dimstyle to force all lines/arrows/text to a single color.
dim_tolerance(value; plus=nothing, minus=nothing, style=current_dimstyle())
Example:
set_dimstyle(decimals=2, unit_suffix=" mm", tolerance_mode=:deviation, tolerance_plus=0.05, tolerance_minus=0.02)
dim_tolerance(25.0) # "25.0 mm +0.05 mm/-0.02 mm"
dim_tolerance(25.0; plus=0.1) # "25.0 mm ±0.1 mm"
dim_tolerance(25.0; plus=0.1, minus=0.03)dim_limits(nominal, lower, upper; style=current_dimstyle())
Limit-style dimensions return a compact upper / lower string.
set_dimstyle(decimals=2, unit_suffix=" mm")
dim_limits(25.0, 24.95, 25.05) # "25.05 mm / 24.95 mm"
dim_limits(10.0, 9.8, 10.2)dim_linear(p1, p2; orientation=:auto, offset=10.0, text=nothing, tol_plus=nothing, tol_minus=nothing, style=current_dimstyle())dim_aligned(p1, p2; offset=10.0, text=nothing, tol_plus=nothing, tol_minus=nothing, style=current_dimstyle())dim_angular(vertex, p1, p2; radius=20.0, text=nothing, tol_plus=nothing, tol_minus=nothing, style=current_dimstyle())dim_arc(center, p1, p2; radius=nothing, text=nothing, tol_plus=nothing, tol_minus=nothing, style=current_dimstyle())dim_center(center; size=10.0, style=current_dimstyle())dim_jogged(p1, p2; orientation=:auto, offset=10.0, jog_size=6.0, jog_fraction=0.12, text=nothing, tol_plus=nothing, tol_minus=nothing, style=current_dimstyle())dim_radial(center, point; offset=10.0, text=nothing, tol_plus=nothing, tol_minus=nothing, style=current_dimstyle())dim_diameter(center, point; text=nothing, tol_plus=nothing, tol_minus=nothing, style=current_dimstyle())dim_ordinate(point; axis=:x, origin=(0.0, 0.0), offset=10.0, text=nothing, tol_plus=nothing, tol_minus=nothing, style=current_dimstyle())dim_baseline(base_point, points...; orientation=:auto, offset=10.0, tol_plus=nothing, tol_minus=nothing, style=current_dimstyle())- `dim_continue(start_point, points...; orientation=:auto, offset=10.0, tol_plus=nothing, tol_minus=nothing, style=current_dimstyle())
All points can be passed as (x, y) tuples or Point2D.
- This package currently focuses on 2D dimension graphics and annotation.
- Commands follow Julia naming conventions with snake_case for functions (e.g.,
dim_linear,dim_aligned,dim_angular). - Future extensions can add radial/diameter/ordinate dimensions, tolerances, and richer style tables.
- Documentation entry:
docs/index.md - Command reference:
docs/commands.md - Formatter reference:
docs/formatters.md - Examples guide:
docs/examples.md - Registry registration guide:
docs/registration.md
Runnable examples:
examples/linear_aligned_angular.jlexamples/radial_diameter_ordinate.jlexamples/chain_and_jogged.jlexamples/formatters_example.jlexamples/iso_dimstyle_example.jl