Skip to content

Conversation

max-mrgrsk
Copy link
Contributor

What's New

Users can now export any sketch to DXF format directly from the context menu of the sketch feature in the feature tree.

How to Use

  1. Right-click on any sketch in the feature tree
  2. Select "Export to DXF" from the context menu
  3. Both environments show a file save dialog

Known Limitations

⚠️ Blocked by engine: Exported files cannot be opened by several DXF viewers due to engine output format

Why This Matters

This feature is essential for manufacturing workflows:

  • CNC milling machines (3-axis) require 2D formats for toolpath generation
  • Laser cutting software primarily supports 2D formats

Technical Implementation

  • Uses sendSceneCommand with export2d instead of Rust export rustContext.export()
  • Rust export is designed for whole scene export, but we need selection-based export
  • Generates meaningful filenames from sketch variable names (e.g., bracket-sketch.dxf)

Future Improvements

The Rust export system should be refactored into a more flexible architecture that can handle:

  • ✅ Whole file export (current) rustContext.export()
  • 🔄 Selection-based export (this PR's approach) (for all selections and all formats) rustContext.exportEntities()

This would replace the current sendSceneCommand approach and enable users to select geometry in the viewport and export just that selection.


Testing: Includes comprehensive test coverage and works in both desktop and browser environments.

Closes: #7989

Screenshot 2025-08-11 at 19 51 00

@max-mrgrsk max-mrgrsk linked an issue Aug 11, 2025 that may be closed by this pull request
Copy link

vercel bot commented Aug 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Project Deployment Preview Comments Updated (UTC)
modeling-app Ready Preview Comment Aug 12, 2025 2:50pm

@max-mrgrsk max-mrgrsk self-assigned this Aug 11, 2025
@max-mrgrsk max-mrgrsk added the feature Feature Requests label Aug 11, 2025
@max-mrgrsk max-mrgrsk marked this pull request as ready for review August 26, 2025 20:52
@max-mrgrsk max-mrgrsk requested a review from a team as a code owner August 26, 2025 20:52
@max-mrgrsk
Copy link
Contributor Author

Hold off on merging until the DXF fix lands later this week.

@pierremtb
Copy link
Contributor

pierremtb commented Aug 26, 2025

Awesome! 🔥

Hold off on merging until the DXF fix lands later this week.

You might want to keep it in Draft state then. We can still review that will 100% prevent accidental merges (esp. since it's green already!)

const sketchName = getOperationVariableName(operation, kclManager.ast)
const fileName = `${sketchName || 'sketch'}.dxf`

if (isDesktop()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's maybe nuance but @jtran had a PR recently which was using electron param instead of checking isDesktop() directly, so following that direction you could check for window.electron? That way it wouldn't be necessary to check writeFile and showSaveDialog and throw an error potentially.

But it may be not so simple because I see you're mocking the value of isDesktop in the test file.

@max-mrgrsk max-mrgrsk marked this pull request as draft August 27, 2025 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature Requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[NEW FEATURE] Export DXF
3 participants