Skip to content

Added edge tagging#29

Open
jmwright wants to merge 1 commit into
mainfrom
edge-tagging
Open

Added edge tagging#29
jmwright wants to merge 1 commit into
mainfrom
edge-tagging

Conversation

@jmwright

@jmwright jmwright commented Jun 16, 2026

Copy link
Copy Markdown
Member

Edge tagging is implemented and works on both the standard and imprinted/conformal paths.

You tag edges exactly the way you already tag faces (tag() on an edge selection) and they come through as 1D physical groups in the mesh:

import cadquery as cq
import assembly_mesh_plugin

beam = cq.Workplane("XY").box(50, 50, 50)
beam.edges("|Z").tag("vertical-edges")

assy = cq.Assembly()
assy.add(beam, name="beam")
assy.saveToGmsh(mesh_path="tagged_mesh.msh")

The naming rules mirror faces: a normal tag is part-prefixed (beam_vertical-edges), and a ~-prefixed tag drops the part name so the same tag on different parts merges into one group 
(e.g. ~contactcontact). Faces and edges can be tagged on the same part and produce separate 2D and 1D groups.

For your transfinite use case, grab the Gmsh object with getTaggedGmsh(), look the curves up by physical-group name, and apply the constraints yourself before meshing:

gmsh_object = assy.getTaggedGmsh()

for dim, tag in gmsh_object.model.getPhysicalGroups(1):
    if gmsh_object.model.getPhysicalName(1, tag) == "beam_vertical-edges":
        for curve in gmsh_object.model.getEntitiesForPhysicalGroup(1, tag):
            gmsh_object.model.mesh.setTransfiniteCurve(int(curve), 11)

gmsh_object.model.mesh.generate(3)
gmsh_object.write("tagged_mesh.msh")
gmsh_object.finalize()

Implementation note: unlike faces (matched by position), tagged edges are matched to their Gmsh curves geometrically (bounding box + midpoint), with the search restricted to each part's own curves. That keeps tags correct even when parts meet at coincident edges. README has a new "Edge Tagging" section and there are tests covering the part-prefixed, multi-part ~, and multi-solid cases.

@jmwright jmwright mentioned this pull request Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant