Author Topic: Combining splines?  (Read 10601 times)

Offline pstemari

  • Storm Trooper
  • ***
  • Posts: 146
    • View Profile
Combining splines?
« on: January 11, 2024, 02:22:47 am »
I'm having some issues importing an Inkscape drawing into CAMBAM.  The import works well enough, but the splines are being broken apart into the individual segments.  The JOIN command glues them back together, but it converts them to polylines in doing so and the results are a bit ragged.

Is there an alternative to JOIN that I'm missing?  Sample files are attached.

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7410
    • View Profile
    • Cambam V1.0 French Doc
Re: Combining splines?
« Reply #1 on: January 11, 2024, 02:46:25 am »
Hello

Yes if splines are joined, they are automatically converted to polyline.

There is a way to convert a polyline to a spline with a script (python) ; select the polyline then run the following script.

Code: [Select]
# New CamBam Python Script

pline = Polyline()

for ent in view.Selection:
  if ent.GetType().Name == "Polyline":
    pline = Polyline(ent)
   

    spline = Spline(pline,0)

    doc.Add(spline)

++
David

Offline dave benson

  • CNC Jedi
  • *****
  • Posts: 1829
    • View Profile
Re: Combining splines?
« Reply #2 on: January 11, 2024, 22:43:09 pm »
Engraving from dxf's has always been a bit of a 'Lucky Dip' ,especially the early versions
of Inkscape, I noticed that your file and a previous one posted earlier are very small scale
wise, I discovered that if you work with a larger image in Inkscape the trace bitmap works
better, then import it to CB and re-scale it. In the posted file see pic I used a 31x31 icon in the pic,
The original image imported as a dxf is fairly lumpy, whereas the scaled version ran through the file
cleaner 'Inscape prefs' set to output as splines looks better.

There is a plugin 'polyline smooth' which could help here too.

Dave
« Last Edit: January 11, 2024, 22:46:27 pm by dave benson »

Offline pixelmaker

  • CNC Jedi
  • *****
  • Posts: 1967
    • View Profile
    • pixelmaker
Re: Combining splines?
« Reply #3 on: January 12, 2024, 12:07:09 pm »
Spline to Polyline Tolerance: Splines are converted to polylines internally before they can be used for some operations, such as toolpath generation.
This setting controls the degree of error allowed in this conversion, measured in drawing units.
A smaller value will result in more accurate spline conversions but can hinder performance considerably.

As far as I know, the splines are converted to polylines internally for each operation and then converted back again at the end of the operation. So there is no advantage to working with splines, except when drawing. The existing tolerances, which can be set, occur again with every operation.

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5263
  • Made in England
    • View Profile
Re: Combining splines?
« Reply #4 on: January 12, 2024, 16:51:41 pm »
Maybe this post from Andy can shed some light on it. (it's rather old so I hope it still applies to CB v1.0)

https://cambamcnc.com/forum/index.php?PHPSESSID=i16cscndvo4leo7tdp6ge1fi90&topic=325.msg2098#msg2098
Filmed in Supermarionation

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7410
    • View Profile
    • Cambam V1.0 French Doc
Re: Combining splines?
« Reply #5 on: January 12, 2024, 22:09:44 pm »
Hello

With the given dog example, to get a spline to polyline conversion without too much distortion, I must use a value about 0.0001 in "spline to polyline tolerance" (tools/options) ... seems it is a suitable value for inches users. (0.01 for mm users)

++
David

Offline dave benson

  • CNC Jedi
  • *****
  • Posts: 1829
    • View Profile
Re: Combining splines?
« Reply #6 on: January 13, 2024, 02:58:52 am »
For me, I've found that my most productive efforts are in the early stages of doing an engraving
that is in the initial drawing or image selection is the most important (some images are not worth the effort) and then what you do in
Inkscape is where you save a lot of time and headaches before you get to CB which has (even with the plugins) modest capabilities.

In the pics you can see a random image from the internet (snipped) put through Inkscape
and imported to CB and sent to camotics 5 minutes at the most, early on this would have taken
much longer as I persisted on trying to fix the import problems in CB rather than go back to Inkscape.
Having good Inkscape Foo is also critical for laser engraving.

Dave

Offline Tool-n-Around

  • Wookie
  • ****
  • Posts: 289
    • View Profile
2D Graphics Conversion
« Reply #7 on: January 13, 2024, 18:14:24 pm »
For me, I've found that my most productive efforts are in the early stages of doing an engraving that is in the initial drawing or image selection is the most important (some images are not worth the effort) and then what you do in Inkscape is where you save a lot of time and headaches before you get to CB which has (even with the plugins) modest capabilities. In the pics you can see a random image from the internet (snipped) put through Inkscape and imported to CB and sent to camotics 5 minutes at the most, early on this would have taken much longer as I persisted on trying to fix the import problems in CB rather than go back to Inkscape. Having good Inkscape Foo is also critical for laser engraving. Dave

I've been following along. I have a need to swap 2D CAD files between CB and Alibre. Alibre can only export SVG and CB only import DXF. I see there are a host of online convertors but would rather to do it locally. I also occassionally need to convert artwork and image files to 2D line/CAD file for import to CB and Alibre. I've used the CB plugins for image importing and other tools for surfaces like edge detect and silohuette, which are great to have but often a lot of work to clean up. Looks like Inkscape is about the best thing going and would be a good addition for me especially being open source and free. I was also poking around Corel and FreeCad since the latter can import/export a large number of 3D files too.......but not to jack this thread, anything else I should consider in preference to Inkscape for the 2D conversion and grapghics manipulation?

Best,
Kelly

Offline dave benson

  • CNC Jedi
  • *****
  • Posts: 1829
    • View Profile
Re: Combining splines?
« Reply #8 on: January 13, 2024, 22:16:35 pm »
Kelly, there is a SVG import plugin for CB which works well, so you may not have to use
Inkscape, just go straight from Alibre to CB if Alibre has good tools for working with SVG's.
if not Inkscape is a good option, I don't know if it's any help but CB has an import function for
3DS files as well.
Dave

Offline Tool-n-Around

  • Wookie
  • ****
  • Posts: 289
    • View Profile
Re: Combining splines?
« Reply #9 on: January 14, 2024, 15:48:14 pm »
Kelly, there is a SVG import plugin for CB which works well, so you may not have to use Inkscape, just go straight from Alibre to CB if Alibre has good tools for working with SVG's.
if not Inkscape is a good option.

Thank's David. I completely whiffed on that one. I found it in the Misc plugin category. I tried it out and worked very well. A couple small pieces of the Alibre sketch I exported as svg did not come over even though the Alibre skecth analyzer said the sketch had no problems. I'll need to investigate that a little further but even so, I could patch that up in less than a minute and had a high quaiity polyline so great improvement there.

The svg plugin is only import. Export would be nice too. However, I can import dxf to Alibre and most of my need is import to CB from Alibre for easily creating 3D bounding CB for imported Alibre objects so this certainly fills that role nicely. I think I'll still look into Inkscape for refinement/conversion and import of image files..

I don't know if it's any help but CB has an import function for 3DS files as well.

I'm not familiar with 3DS but did a quick search. It doesn't appear to be one of the Alibre import options and not sure I'll need to be importing models from CB to Alibre, but will make note of that.

Thanks for the reply. Glad I asked. I'll give the OP back his thread... :)

Best,
Kelly

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5263
  • Made in England
    • View Profile
Re: Combining splines?
« Reply #10 on: January 14, 2024, 16:29:19 pm »
The svg plugin is only import. Export would be nice too.


SVG export plugin is here; https://cambamcnc.com/forum/index.php?topic=8746.msg69710#msg69710

For some reason David did not manage to add a link in his plugins page.

The plugin was written for use with my laser.
Filmed in Supermarionation

Offline Tool-n-Around

  • Wookie
  • ****
  • Posts: 289
    • View Profile
Re: Combining splines?
« Reply #11 on: January 14, 2024, 17:28:18 pm »
Thanks Eddy. Ask and ye shall receive  :)

I downloaded it and will see how it works for import to Alibre. Unless I overlooked it, I dont think it is listed on the CB plugin web page.

Best,
Kelly

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7410
    • View Profile
    • Cambam V1.0 French Doc
Re: Combining splines?
« Reply #12 on: January 14, 2024, 18:15:18 pm »
Hello

Quote
For some reason David did not manage to add a link in his plugins page.

Because I forgot  ;D (and it is probably not the only one)

++
David