1. Hey guyz. Welcome to the All New Phlatforum!



    Sign Up and take a look around. There are so many awesome new features.

    The Phlatforum is a place we can all hang out and

    have fun sharing our RC adventures!

  2. Dismiss Notice

(Maybe not a bug) it is generating gcode for a contour backwards ...

Discussion in 'SketchUcam Bugs' started by Serge Ecoiffier, Jul 26, 2015.

  1. Serge Ecoiffier

    Serge Ecoiffier New Member

    Offline
    Messages:
    18
    Trophy Points:
    3
    Location:
    Ontario, Canada
    I have this relative complex curve, full of ornate segments, with which SketchUcam seems to have many issues when generating the gcode. I tried TIG-WELD to make it one curve (no end points appear) but it doesn't help. Did the RepairBL&Phlatten, which finds and corrects some segments, but still no go.

    I eventually got it going, not knowing what triggered the correct generation of gcode - a smooth path all around for each depth pass. The job takes about 1 hour to complete.

    The problem, as a contour, is I can't add tabs to keep the cutout attached. I either need to specify going 95% or so deep to leave an 'onion skin' which needs to be cleaned out manually or be prepared to hold the cutout while the router goes on to an other part of the job - not necessarily the safest route.

    Now I split this curve in two segments, joining each to half a circle (the next outer cutout) so I could build a tab manually where the circle and curve were cut. The problem is back ! What should take a few minutes to route takes nearly 6 hours (according to simulation in OpenSCAM, double the time in reality from experience). So I started looking real close at the simulation in slow mow (1x time actually).

    This is a screen capture of the SketchUp with SketchUcam marking. We can see the manually created tabs near top and bottom (as displayed - triple guide lines used to align the tabs) :

    upload_2015-7-26_15-51-16.png

    From the slow simulation, and having looked at the physical routing of the part (first time I actually sat for a few hours wondering if it will ever finish), this is what I discovered :

    the gcode being generated for the complex portion of the combined half circle&curve is backwards ! For each segment on the complex portion, and there are thousands (!), the gcode goes to the 'far' end point, moves tool down and routes while coming back on itself to the 'near' end point to then raise the tool and go to the far end point of the next line segment and start over ... It basically goes around the line counterclockwise but only to cut each segment of the complex curve clockwise !! The half circle portion is done in one move ... It's only the complex portion that gets 'backwards'.

    When looking at the one which 'works', it does the full circle according to whether it is an outside or inside run, and it does the whole complex curve as contour (no tabs possible) CLOCKWISE as a smooth curve. I don't dare make any changes to that SketchUp file at this time, having spend a good three days trying to figure this out.

    Oddly enough, after doing a few RepairDL&Phlatten and TIG-WELD, portions of the complex curve in the half circle scenario suddenly 'work' while other portions remain 'backwards'. Do I just keep hacking at it with these two steps until both curves are 100% ok ? After about five cycles of this I seem to have one curve going, but the other now doesn't want to generate gcode ...

    What could I be doing wrong ?

    Is there a way to control or trick the generator to trace such a complex curve as one curve ?

    Would it be difficult to allow tabs on contours ?

    Of course, one 'solution' would probably be to generate gcode separately for the complex curve and join that to the rest, forcing it to run last and not be as risky to have a loose element within the work area.

    But it would be nice for SketchUcam to be able to handle this kind of job as it seems 99% there as it stands.

    I'll go back to hacking at it as it seems to eventually work for now.
     
  2. swarfer

    swarfer Moderator Staff Member

    Offline
    Messages:
    803
    Trophy Points:
    28
    Location:
    Grahamstown, South Africa
    can you post the sketchup file for me?

    I take it the complex curve is a 'centerline cut'?

    I have spent MANY hours trying to solve this issue. Sketchup gives the set of line segments to SketchUcam as a 'curve' (if you welded them).
    the order of segments depends on many things, including it seems, the phase of the moon !?. sometimes they are in order, sometimes not. mostly, I can determine the order and cut all in the same direction, but sometimes the order reverses somewhere along the line and so far I have not found a way to 'know that' during the Gcode generation without having to process every cut twice (will make generating Gcode take a LOT longer).

    I got to a point where the processing 'mostly worked' and 'was better than previous versions' and had to release 1.3a or else face even more delay before the release of ramping (and ramping is essential for the release of the CBeam plate cutter on Openbuilds.com). If you are not running V1.3a then get it now!

    Sometimes using the BZtools to 'create polyline' works, sometimes Weld works better.
    BZtool
     
  3. swarfer

    swarfer Moderator Staff Member

    Offline
    Messages:
    803
    Trophy Points:
    28
    Location:
    Grahamstown, South Africa
    you can actually make a centerline cut do this on purpose (-:

    select the freehand draw tool, and draw a shape, going clockwise.
    now start somewhere on that shape and draw a new section, but go anticlockwise.
    set it as a centerline cut and generate gcode.
    in Gplot (or your simulator) you will see that one section will be a smooth cut, while the other one will 'backtack' along each segment.

    on the quick trial I did now, using 'repair and flatten' then the Bezier tools to 'create polyline' fixed it instantly, but I know I have battled with other drawings where nothing will 'fix' certain segments of the drawing.

    another idea is to split your drawing into 2 parts.
    in the first, retain the complex cut line and remove all other cut lines.
    in the second copy, remove the complex line.

    1- make sure the complex line is the outline of a face, remove the 'centerline cut' from it (select bounding edges then use the PB delete tool to remove the cut, leaving plain lines behind).
    2 - use the offset tool to create a line outside the face, offset by half your bit diameter.
    3 - delete the original cut line
    4 - add an 'inside cut'. this will now be your cut line, but will always cut 'inside outside cut %' deep.
    5 - set your safe area to only enclose this drawing and generate the Gcode with material thickness = how deep you want this cut, and inside/outside cut% set to 100%

    6 - move the safe area to the other drawing
    7 - set material thickness to the actual material thickness and change cut% if you need to.
    8- generate the gcode
    9 - join the two files with the joiner tool, fancy cut first.

    watch my recent video about the seat knob to see this process in action
     
  4. Serge Ecoiffier

    Serge Ecoiffier New Member

    Offline
    Messages:
    18
    Trophy Points:
    3
    Location:
    Ontario, Canada
    Yes, 'centerline cut' is meant where I was saying 'contour'. Sorry, my frenglish sometimes gets in the way ...

    I will send you the version that 'works', using a centerline for the complex curve - which cuts it off completely from the rest of the 3/4" plywood, as well as the one where I'm trying to do it in two halves to manually introduce couple of tabs where the inner shape almost touches the outermost circle. Look for it shortly. OpenSCAM says the first should run in about 38 minutes while the second would be towards 1 hour. That is way better than the 6-10 hours when the curvy line gets the woodpecker treatment ...

    As for the 'phase of the moon' factor, I certainly believe it and the alignment of planets around a randomly selected sun in an randomly selecteted far off galaxy is also at play. ;(

    Even if I weld the lines, where SketchUp Make shows them as one long curved segment, SketchUcam still gets them as a bunch of short segments. Welding does not seem to affect the troublesome curve. The RepairBL&Phlatten seems to help more ... questionable as I am banging my head on this a bit too much. To the point I don't feel the pain anymore ...

    SketchUcam seems consistent as far as the order of those line segments. It's just doing a "two step forward one step backward" trace of these curves. Although, at times, it does the 2-1 stepping only for random length along the curve.

    I have it where the one half is done 'perfect' while the second half is just not working. So I split that half into 3 parts : a did a manual arc splitting it from the 'bridge' line segment linking to the complex curve. All works EXCEPT the arc which is doing the the two step. WTF? (Sorry) That's the version down to an estimated 1 hour run (OpenSCAM).

    Anyways, thanks for looking into this. Don't spend too much time on this, unless it will help you improve SketchUcam and the issues of SketchUp not passing segments in a somewhat logical order.

    Just an aside, every time I do a modification SketchUcam seems to change the order it does the cuts (or is it SketchUp ?) SketchUcam is doing a great job at optimizing the cuts to minimize 'rapids' (air cuts) nonetheless. It would be nice, however, to have some control on it. That way, I, for example, could keep the tabless full cut to the very end of the run instead of having it somewhere in the middle of the job SketchUcam allows reordering groups, but they are done first so it would not help.

    I guess I'm really kicking the tires here, eh ? Oh, if you really look close, you will see one of the two cuts inside the 'O' is also doing the 2 steps. It was not doing it earlier on. It just started at some point without even touching those cuts. It is less of an issue since it is only a shallow cut (manual pocket to avoid the other issues of SketchUp).

    Next time, I will probably 'hand' redraw tparts of a pattern instead of doing a pure raster to vector conversion. The conversion is creating tons of itsy bitsy tiny line segments for no reason (ex: in some arcs). I would probably of spent a lot less time battling SketchUp's issues.

    Maybe I should split the generation of the gcode into two : one with everything that seems to work 100% of the time and then an other with just the complex curve. See if SketchUp then passes the info to SketchUcam so it can do a perfect job as in the first file to follow.

    Again, thanks.
     
    swarfer likes this.
  5. swarfer

    swarfer Moderator Staff Member

    Offline
    Messages:
    803
    Trophy Points:
    28
    Location:
    Grahamstown, South Africa
    no problem, we have 11 official languages and I only speak 2 of them....
    that is exactly the issue, that the 'direction' of the line segments reverses somewhere along the length of the curve.
    if you split it where the direction changes and let it cut as 2 separate pieces, then each piece will cut optimally.
    it is Sketchup, when you edit a line the internal data structure changes. entities are in the list 'in no particular order' according to the programmers documentation.
    this just means you have to group EVERY CUT so that you can set the order. so a group of all the cuts you want done first, then a group of all the cuts you want done last.
    ah! no wonder there are so many small lines!
    that is what I was suggesting, the split into 'easy stuff' and 'harder stuff' so you, and SketchUcam, have less to deal with..
    I am going to try exactly this idea in a moment.
     
  6. Serge Ecoiffier

    Serge Ecoiffier New Member

    Offline
    Messages:
    18
    Trophy Points:
    3
    Location:
    Ontario, Canada
    SketchUp listing entities in "no particular order" explains a lot. For a while I thought it was bringing the last edited entity to the top of a list of entities, but then things would seem to be randomly ordered no matter what. Even when I tried to do the SketchUcam stuff over, thinking it'll generate the gcode in the same order, I would end up with a different sequence of gcode, sometimes with the same results and sometimes with unexpected differences. It really through me for a loop ...

    Thanks for the time and work done to help me out. It is much appreciated. I definitely owe you one Swarfer.

    I suddenly remembered a few others mentioning there is usually no need to tell SketchUp to draw circles with too many line segments. It will just slow it down and extensions like SketchUcam will know it is a circle or an arc and handle it accordingly anyways. Sure, the SketchUp file will look real pretty and all, but you only slow it down to a crawl and probably mess other things along the way.

    So I learned a few key things with this first 'real' project of mine and mostly your (Swarfer's) help and explanations :
    • first, when doing raster to vector conversion a simplification process is a must since the conversion will likely create thousands of line segments/entities, many of which won't make a difference in your work but, at best, slow things down and, at worse, mess things up ! This means using extensions: EdgeTools2 (ThomThom) to basically get rid of the excess details, RepairBL&Phlatten (SketchUcam) to further join neighbouring segments which are aligned, and Weld (TIG) to make curves out of neighbouring segments. As Swarfer has shown me, this gets rid of lots of segments without loosing details once milled/routed. Call it lossless optimization.

    • second, don't be afraid to split the design into simpler parts sharing a reference point to make your work and SketchUcam's work that much easier. The old divide and conquer approach can work. The individually generated gcode can always be joined with PhlatBoyz' Gcode Joiner (part of SketchUcam) into a single file or you could run them individually to give your machine a break between each ... This would also allow you to change tool, do roughing then detailing, etc.

    • third, group things and you will be able to control the order the gcode is generated by SketchUcam, thus how your machine works the material. Otherwise, SketchUp will sorta-kinda randomize things with no apparent logic nor reason.
    I am now ready to tackle my next sign. This time its for my mother-in-law (teaches special education) ... So it better be good, eh ?
     

Share This Page