Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

Transforming a sketch into straight vertical and horizontal lines for 3D printing

IvdaIvda Member Posts: 4

Hi! This is my first post here.
The problem I want to solve is that if you 3d print something small, it matters where the slicer places the outer layers. When drawing a sketch, you don't know where the edges of the layers will appear. That's why I'm trying to make a new feature that allows you to copy and transform a sketch into a new sketch that only consists of horizontal and vertical lines. With the option to set a layer height.
Since I have no coding knowledge, I asked IA to help me with that. Unfortunately it never seems to be able to write a peace of code that has no errors.
Maybe if someone could help me with this part, AI will be able to work out the rest. Thank you!

FeatureScript 2559;
import(path : "onshape/std/common.fs", version : "2559.0");

annotation { "Feature Type Name" : "Layer Simplifier", "Feature Type Description" : "Convert lines in a sketch to layer-based lines" }
export const layerSimplifier = defineFeature(function(context is Context, id is Id, definition is map)
precondition
{
annotation { "Name" : "Sketch", "Description" : "Select a sketch with lines" }
definition.sketch is Query withFilters(
qSketchFilter() // Filter to select only sketches
);
}
{
// Action: Select lines in the sketch
const lines = evaluateQuery(context, definition.sketch);
println(context, "Selected lines: " ~ lines);

// Placeholder for further actions like simplifying lines or adding layers
});

Comments

  • jelte_steur814jelte_steur814 Member Posts: 259 PRO
    edited January 16

    hmm, this seems a stretch.

    first off, i don't understand the problem:

    "When drawing a sketch, you don't know where the edges of the layers will appear"

    how so? if you slice an object, the outer edge of the outer layer line will be on the outside of the object. (to the best of the slicers ability)…

    then I don't understand your solution. how will it make it better if you create vertical and horizontal lines?

    are you trying to slice the thing in sketches? How will you then create gcode from the sketches?
    I expect AI will be better at helping you tweak gcode than create featurescript. (since there's more data it's trained on)

  • IvdaIvda Member Posts: 4

    I agree, it's a somewhat unusual approach. You have to know this is for very small scale and precise printing. When I want two printed parts to fit together really well, the slicer changes the shape slightly. This is rarely a problem, but now I'd like to take control over that.
    In these screenshots, you can see this happening. The place where the sketch shows a horizontal peak or a wedge (I'm not a native English speaker), the slicer distributes this over two layers, canceling out the peak. I know, this is tiny winy nitpicky stuff, but I'd like to try that.

    If a feature could sort of pixelize (not really in pixels but in layers) the sketch, I could adjust things so they are as they should be.

    I'm not looking for anyone to write the hole code of course. But if someone could tell me why I'm getting error messages, than AI might be able to help me finish this.

  • jelte_steur814jelte_steur814 Member Posts: 259 PRO

    Ah, i see. so this would be only for Z layer sharpness issues then?

    perhaps an underlayer grid with the point size as your layer height (or multiples of it) may help in getting the wedge tip of such a design at the right position. note that slicer usually set a separate height for the first layer so you might want to add a sketch line for the bottom layer.

    That would also be a pro-active measure as well, rather than finding out afterwards by lining ("semi slicing" the sketch and having to iterate.

    Else you might try Kiri-moto from the onshape appstore to quickly iterate your design in a slicer before finalizing it and exporting to your own slicer with all the proper configurations and settings. (or get kiri-moto setup for your printer, I haven't got much experience with it, but might be worth a try.)

    I still dream of a way to get PrusaSlicer more integrated into onshape for faster slicing iterations. Haven't got the coding experience to get that done though.

    Have you tried the featurescript from this document here

    from this thread?

Sign In or Register to comment.