Hand-coding a DXF file?

I have been stewing on an idea lately and want to look into getting started. I want to be able to enter some parameters and have a program spit out a DXF file consisting of a procedurally generated design ready for the laser. I am thinking it will be a python script using dxfwrite · PyPI. Does anyone have a better suggestion on how to tackle this?

1 Like

That seems like a pretty good solution to me.

Other options:

SVG is a really easy-to-read plaintext XML format that you can convert to
DXF the typical way.

Inkscape’s plugin system is just a collection of Python scripts, and can be
a good way of iterating your script and having immediate visual feedback.

OpenSCAD is sometimes used for parametric laser cutter designs.

You seem to be on the right path already, though, there’s nothing wrong
with that method :slight_smile:

Thanks.

The research I’ve done came up with the point that most Inkscape plugins are python so I figured if I go this route, it could be used as, or converted into, a plugin. I’d have to look into what is required to make it work with inkscape, but if I can essentially use Inkscape as he GUI, then that would be a bonus.

1 Like

Yeah, I think @Jarrett is on to something. Having a format that can easily be displayed is in my opinion very powerful tool. Like Jarrett said, this will allow you to quickly iterate over your script, or even playing around with parameters. Plus, Python is an easy yet powerful enough programming language to get things going quickly.

Your two options are really these:

Develop a plugin
Pro: Visual interface with immediate visual feedback
Con: New programming challenge
Bonus: There’s a gear plugin for Inkscape that might be a good starting point

Standalone
Pro: Easier to develop
Con: Need for external program to display

1 Like

If you go the Inkscape extension route, there are two files you should
check out in your code editor of choice:

C:\Program Files\Inkscape\share\extensions\render_gears.py

C:\Program Files\Inkscape\share\extensions\render_gears.inx

Ty is right, that’s an excellent starting point for what you want to do.
Very simple, and I can talk you through anything you don’t understand :slight_smile:

1 Like

… shall we start with Line 1, then? :wink:

Thanks to both of you. I’ll have a look at that and get to thinking about how to boil my idea down into code.

Hey this is cool! I’ve been researching how to create SVG files programatically for a sewing pattern generator that I’m doing. I like the DXF generator as an option as well.

I came across this post which indicates that dxfwrite is no longer in active development. The developer Manfred Moitzi is now working on ezdxf.

“If you want to create later DXF versions just use my ezdxf package (ezdxf · PyPI). dxfwrite is in maintenance mode - not further developement planned, while ezdxf is in active (but slow) development and ezdxf is also MIT licensed.”

EZDXF can be found at ezdxf · PyPI

There also seems to be a fairly active ezdxf google group

Thanks for the info, @Majicj. I’ll look into that instead. Sewing patterns sound cool. is the idea that you could design the pattern once, then scale it to your proportions? With a DXF you could even use that to cut the fabric too, either on a cutter or on The LAZER!!! bwahahahahah laser-cut fabric for all your sewing needs!

The idea is that you enter your body measurements and then have a pattern generated specifically for your measurments.

I picked up a copy of Metric Pattern Cutting for Menswear and I am trying to programatically create some basic patterns.

There are software packages available for pattern making however these are not cheap. And they “sell each pattern group”. I found one open source pattern generating platform called Valentina. I don’t really like the approach they have taken. I guess I’ve been spoiled by Fusion 360 or other online SaaS applications.

Anyways I am starting off small just to learn about pattern making and trying to recreate a basic pattern for pants using SVG/DXF as the output format. This python library looks like a good place to start.

[quote] With a DXF you could even use that to cut the fabric too, either on a cutter or on The LAZER!!! bwahahahahah laser-cut fabric for all your sewing needs!
[/quote]

That is part of the plan :slight_smile:

Woah! I saw you mention that you picked up the book, but I had no clue that your plans were so nefarious epic! Once I get into it, I may have to pick your brain a bit. Which route are you going? Stand-alone python or plug-in?

I believe there is a python api for Fusion360

https://autodeskfusion360.github.io

1 Like

Thats cool.

I started off doing a pattern sketch in Fusion 360 and was liking the parametric functionality but I soon came to realize that Fusion 360 is not meant for 2D work. You can save your F360 sketch as a DXF file but you cannot add text notes or labels to points in a sketch which is essential to making a pattern for sewing.

I’m really starting simple here. Just stand alone and no user gui.
Start with reading a text file with body measurements and then generate a dxf pattern file.

Pretty much every “flat” pattern block created follows a set of instructions to create it.
For example a set of steps to create a 2 piece trouser block is shown below. This uses recorded body measurements

The actual Pattern Block (points 1-25 correspond to instructions above)

A few of the Body Measurements that you would store

There is a LOT more stuff than this to deal with when making patterns (Seam allowances, alterations based on posture, body shape etc, material ease etc.) but gotta start somewhere. :slight_smile:

I have written some DXF export stuff. only the oldest format. You can find the code here:

https://github.com/MarginallyClever/Makelangelo-software/blob/master/java/src/main/java/com/marginallyclever/makelangeloRobot/loadAndSave/LoadAndSaveDXF.java

I’ll have a look at that when I get time, thanks!

Ooh! Even more awesome…

Processing* supports DXF output, so if you’re going to generate it, it might be an interesting one-stop-shop to explore:

Processing is like Arduino, but (initially) Java based and made for visual/media.

@miststlkr

2 Likes

Interesting. i’ll have a look. Thanks

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.