Skip to content

[orx-g-code] Add g-code tools for pen plotting - #285

Merged
edwinRNDR merged 28 commits into
openrndr:masterfrom
adriandieter:orx-g-code
Jan 28, 2026
Merged

[orx-g-code] Add g-code tools for pen plotting#285
edwinRNDR merged 28 commits into
openrndr:masterfrom
adriandieter:orx-g-code

Conversation

@adriandieter

Copy link
Copy Markdown
Contributor

An extension to generate g-code from compositions, best used in a live coding environment. The intended use is for a pen plotter, but code to drive a laser cutter or other CNC machines could be generated as well.
I have used the foundation of this for a while now and tried to wrap everything in an more general and easy to use interface.
See the README and demo files on how to use.

Feedback is appreciated ✨

@hamoid

hamoid commented Dec 30, 2022

Copy link
Copy Markdown
Member

Oh nice!! :-) I will take a look in the next days. I do have an Axidraw. Do you know if it's compatible? With what kind of devices have you tried your orx?

@adriandieter

Copy link
Copy Markdown
Contributor Author

From a quick search it looks like the Axidraw does not speak g-code at all natively 🤷‍♂️
I am using a GkDraw only tested with that. It uses grbl firmware. So I guess any similar Axidraw knockoff plotter would be compatible.

However the implementation should allow for customization to any g-code dialect or device. So a 3d printer fitted with a pen holder would work as well 🤔

Comment thread orx-g-code/build.gradle.kts Outdated
Comment thread orx-g-code/build.gradle.kts Outdated
Comment thread orx-g-code/src/jvmTest/kotlin/TestGenerator.kt Outdated
Comment thread orx-g-code/build.gradle.kts Outdated
@adriandieter

Copy link
Copy Markdown
Contributor Author

Thanks @Vechro for the suggestions on the build files! That's where I was a bit lost and didn't know what to follow/what is best practice. Also updated the test files.

I'd like to keep this as a draft for a bit and continue using it with that interface before merging. Just to prevent any bigger changes once merged.
Do you think the design of the Plot extension matches other extensions or see anything that could be improved? I am not too happy with how the configuration/setup works.

@Vechro

Vechro commented Jan 27, 2023

Copy link
Copy Markdown
Contributor

Maybe @edwinRNDR can answer that. I can mostly offer advice on the build scripts.

@edwinRNDR edwinRNDR added question Further information is requested enhancement labels Apr 20, 2023
@adriandieter
adriandieter marked this pull request as ready for review November 12, 2023 20:48
@adriandieter
adriandieter marked this pull request as draft November 12, 2023 20:57
@adriandieter
adriandieter marked this pull request as ready for review November 12, 2023 21:01
@adriandieter

Copy link
Copy Markdown
Contributor Author

I did continue using it a bit since I opened the PR and didn't see any issues with the API so far. Think this is ready to be merged 🤔

extend(plot) {
generator = basicGrblSetup()

// Set output files to be exported to tmp

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

tmp -> /tmp ?

generator = basicGrblSetup()

// Set output files to be exported to tmp
// "g" to export g-code.

@hamoid hamoid Jan 23, 2024

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"g" -> Press "g" ?

// Export each layer to separate file
layerMode = LayerMode.MULTI_FILE

// Set output files to be exported to tmp

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

tmp -> /tmp

layerMode = LayerMode.MULTI_FILE

// Set output files to be exported to tmp
// "g" to export g-code.

@hamoid hamoid Jan 23, 2024

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"g" -> Press "g"

@hamoid

hamoid commented Jan 23, 2024

Copy link
Copy Markdown
Member

Sorry for the long latency! I'm writing a post in the guide about pen plotters and it motivated me to look into this. It would be good to offer both SVG and g-code.

@hamoid

hamoid commented Jan 23, 2024

Copy link
Copy Markdown
Member

Do you think the design of the Plot extension matches other extensions or see anything that could be improved? I am not too happy with how the configuration/setup works.

Maybe @edwinRNDR has now more time to say something about this?

@linde9821

Copy link
Copy Markdown

Any news? Would be a cool feature

@hamoid

hamoid commented Nov 30, 2025

Copy link
Copy Markdown
Member

Are you familiar enough with OPENRNDR @linde9821 to give it a try and report back your impressions? You would need to build a local snapshot of OPENRNDR and ORX, including this PR. You wouldn't need the openrndr-template, as you could use the demos under this ORX.

@linde9821

Copy link
Copy Markdown

@hamoid Sorry but Iam not familiar enough with OPENRNDR

@hamoid

hamoid commented Dec 2, 2025

Copy link
Copy Markdown
Member

No problem. Do you have a device or software that reads g-code to test?

@adriandieter

Copy link
Copy Markdown
Contributor Author

Thanks for the review and sorry for the late response. Lost the focus on this. I'll look into your suggestions and might change the interfaces a bit.

adriandieter and others added 9 commits December 15, 2025 15:01
- add kotlin-multiplatform conventions plugin with id
- Composition & CompositionDrawer moved to orx
- Segment renamed to Segment2D
- use oshai instead of mu KotlinLogging
- remove runtimeOnly(libs.slf4j.simple) dependencies
@hamoid

hamoid commented Dec 15, 2025

Copy link
Copy Markdown
Member

Nice to hear @adriandieter :) Let me know if you need any feedback.

I've been adding a /** comment */ to all demos in orx (I'm almost done) between the imports block and fun main() describing what features the demo tries to demonstrate. It would be great to add such comments to the orx-g-code :-) You can find some examples at 25a01ad

@adriandieter

Copy link
Copy Markdown
Contributor Author

@hamoid implemented my changes and added some demos and documentation.

This makes it much easier to customize how the g-code is generated. Also got it working with my existing projects, so should be good to go 🙌

@hamoid hamoid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looking good. Only left some minor comments.

Comment thread orx-g-code/src/jvmMain/kotlin/Plot.kt
Comment thread orx-g-code/build.gradle.kts Outdated
Comment thread orx-g-code/src/jvmMain/kotlin/Plot.kt Outdated
Comment thread orx-g-code/src/jvmDemo/kotlin/DemoInteractivePlot.kt Outdated
Comment thread orx-g-code/src/jvmDemo/kotlin/DemoInteractivePlot.kt Outdated
@adriandieter

Copy link
Copy Markdown
Contributor Author

Thanks for the review and approval!

Can we merge this soon? It's been open for so long and it would be nice, to have it closed done 🙏

@edwinRNDR

Copy link
Copy Markdown
Member

Hey this looks super neat! apologies for taking so long for merging it in. @adriandieter would you like me to add you to the openrndr organization and allow you to create branches for orx-g-code?

@edwinRNDR
edwinRNDR merged commit 1d00979 into openrndr:master Jan 28, 2026
1 check passed
@hamoid

hamoid commented Jan 28, 2026

Copy link
Copy Markdown
Member

@adriandieter Finally merged :-)

Some small issues in the readme:

@adriandieter

Copy link
Copy Markdown
Contributor Author

@edwinRNDR sure, sounds good!
Especially since @hamoid found some issues already ☝️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

question Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants