Skip to content

preview: draw stock outlines from (WORKPIECE,...) comments - #4476

Open
alex-pres wants to merge 1 commit into
LinuxCNC:masterfrom
alex-pres:pr-gremlin-draw-workpiece
Open

preview: draw stock outlines from (WORKPIECE,...) comments#4476
alex-pres wants to merge 1 commit into
LinuxCNC:masterfrom
alex-pres:pr-gremlin-draw-workpiece

Conversation

@alex-pres

@alex-pres alex-pres commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Followup for #4429

A (WORKPIECE,BOX|CYLINDER|TUBE,...) comment declares the stock the program is cut from; the preview draws it as a translucent wireframe, and get_workpieces() hands a GUI the declared params and the outline in machine coordinates. Extents unchanged.

Supported formats:

(WORKPIECE,BOX,XMIN=0,YMIN=0,ZMIN=-40,XMAX=100,YMAX=100,ZMAX=0)
(WORKPIECE,CYLINDER,AXIS=Z,X=0,Y=0,ZMIN=-40,ZMAX=0,DIAMETER=80)
(WORKPIECE,TUBE,AXIS=Z,X=0,Y=0,ZMIN=-40,ZMAX=0,DIAMETER=80,INNER_DIAMETER=40)

If more than 1 specified, it is added to previous. As additional bonus, get_workpieces() function is available for display GUI to create useful shortcuts (like travel to workpiece left side) and especially for probing of workpiece location on the table. Workpieces are rendered in current g-code coordinate system (G54, etc.) and auto-switch inch/mm like rest of gremlin code.

What does it look like
image

@alex-pres

alex-pres commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

Instruction for Autodesk Fusion post-processor:

edit .cps file

add function

function writeLinuxcncStockInfo() {
  var wp = getWorkpiece();                     // BoundingBox, in the setup's WCS
  // var d  = Vector.diff(wp.upper, wp.lower);    // size - if you ever need it

  writeComment("WORKPIECE,BOX" +
               ",XMIN=" + xyzFormat.format(wp.lower.x) +
               ",XMAX=" + xyzFormat.format(wp.upper.x) +
               ",YMIN=" + xyzFormat.format(wp.lower.y) +
               ",YMAX=" + xyzFormat.format(wp.upper.y) +
               ",ZMIN=" + xyzFormat.format(wp.lower.z) +
               ",ZMAX=" + xyzFormat.format(wp.upper.z) );

}

Call it from onOpen(), after the format objects are created.

@c-morley

Copy link
Copy Markdown
Collaborator

Can you add the code from gemlin into qt5_grsphics too please.

@alex-pres
alex-pres force-pushed the pr-gremlin-draw-workpiece branch from 9526a4f to 4a81b29 Compare August 27, 2026 08:18
@alex-pres

Copy link
Copy Markdown
Contributor Author
image

Actually it worked already in QT too, the commit message was misleading.

I only added setShowWorkpiece(self, state); getShowWorkpiece(self); and related QT designer property into this force-pushed commit. The rest of code is unchanged.

A (WORKPIECE,BOX|CYLINDER|TUBE,...) comment declares the stock the program is cut
from; every preview host draws it as a translucent wireframe, toggled per host,
and get_workpieces() hands a GUI the declared params and the outline in machine
coordinates. Program extents are unchanged.
@alex-pres
alex-pres force-pushed the pr-gremlin-draw-workpiece branch from 4a81b29 to 2ad450b Compare August 27, 2026 09:55
@c-morley

Copy link
Copy Markdown
Collaborator

Thank you. This looks useful.

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.

2 participants