Author Topic: [polyradius] A script that could be useful for some  (Read 32884 times)

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 8659
    • View Profile
Re: A script that could be useful for some
« Reply #45 on: February 21, 2015, 15:16:16 pm »
Eddy!
Yes!  I have that abstract, and there are those darned perpendiculars again!

Sigh... that may be the only efficient way to do it.  It involves 'de-arcing' the polyline, so that it consists only of (possibly very short) straight-line segments.

Then, using the many, many radius perpendiculars that result will immediately tell you if the tool of that radius will fit the 'curve' it must traverse.

To re-hash an older point -- if any of the perpendiculars intersect anywhere but at their open end-points, the tool will not fit the curve.

LLoyd
"Pyro for Fun and Profit for More Than Fifty Years"

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6932
    • View Profile
    • Cambam V1.0 French Doc
Re: A script that could be useful for some
« Reply #46 on: February 27, 2015, 21:15:41 pm »
Hello,

Some new job on the script.

add detection of internal/external arcs on closed polylines
add center mark
add size text

http://www.usinages.com/cambam/controle-avant-sortie-code-t74420-45.html#p837694

++
David

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6932
    • View Profile
    • Cambam V1.0 French Doc
Re: A script that could be useful for some
« Reply #47 on: April 10, 2015, 21:06:00 pm »
Hello,

A new version of the script.

It create 3 layers used to store the texts ; one for the internals min radii, one for the externals min radii, and one for other values + points list.



++
David
« Last Edit: April 10, 2015, 21:16:30 pm by dh42 »

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5083
  • Made in England
    • View Profile
Re: A script that could be useful for some
« Reply #48 on: April 11, 2015, 09:52:18 am »
Just tried the script, it's very good but the font was so small I could not see it. I had to change this;

const TXT_SIZE = 4/25
to
const TXT_SIZE = 4

I added a Polyline then went into 'Points' to apply a small 'bulge' value. The script successfully found the radius but because it was a very large radius the text was outside my screen area and I only found it after zooming out.
This is not a fault, I'm only saying it in case others have tried it and thought there was something wrong.

It also prints the values below in the log area so best to look there first.
« Last Edit: April 11, 2015, 10:03:39 am by EddyCurrent »
Filmed in Supermarionation

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6932
    • View Profile
    • Cambam V1.0 French Doc
Re: A script that could be useful for some
« Reply #49 on: April 11, 2015, 13:26:13 pm »
Hello,

Quote
Just tried the script, it's very good but the font was so small I could not see it. I had to change this;

Hum, yes, I assumed, maybe wrongly, that the English-speaking users use inches, so I divided the size of the character to 25 when I translate the script.... you are mm user ?

Quote
I added a Polyline then went into 'Points' to apply a small 'bulge' value. The script successfully found the radius but because it was a very large radius the text was outside my screen area and I only found it after zooming out.

Yes, I did not try whith big arcs ... maybe I can try to place the texte close to the arcs instead of close to the center point ..

++
David
« Last Edit: April 11, 2015, 13:30:08 pm by dh42 »

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5083
  • Made in England
    • View Profile
Re: A script that could be useful for some
« Reply #50 on: April 11, 2015, 13:30:47 pm »
Yes I use mm
At the moment I'm converting it to a C# plugin for some practice.
Filmed in Supermarionation

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6932
    • View Profile
    • Cambam V1.0 French Doc
Re: A script that could be useful for some
« Reply #51 on: April 11, 2015, 13:50:08 pm »
good, that give me food for the API doc (in C), and if you code OOP, maybe I understand how OOP must be organized ...

++
David

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5083
  • Made in England
    • View Profile
Re: A script that could be useful for some
« Reply #52 on: April 11, 2015, 21:11:42 pm »
I've got it converted to a C# plugin now and working same as the script, will just tidy up a bit tomorrow and post it, time for bed here.
Filmed in Supermarionation

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 8659
    • View Profile
Re: A script that could be useful for some
« Reply #53 on: April 11, 2015, 21:42:20 pm »
Hooray, Eddy, and THANKS!

With both my original (raw) code and yours to follow, I will have more and better appreciation of OOP.

Lloyd
"Pyro for Fun and Profit for More Than Fifty Years"

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5083
  • Made in England
    • View Profile
Re: A script that could be useful for some
« Reply #54 on: April 12, 2015, 11:38:38 am »
Project attached, it's for Visual Studio Community 2013.
The code file is called Class1.cs and the compiled DLL ready to put into your CamBam plugins folder is in the Bin\Release folder.
Please note I've tried to make it as close to the VB version as I can, so there are no 'enhancements' if you like.
Also added 2 test files.
I also set the font to Arial because most (all ?) have it installed, but the stick fonts look better.
In practice it would need a configuration form to select fonts, etc.

Edit: I could not find a direct C# equivalent of the VB clone method (that worked in this code). If anyone knows better please speak up.
e.g.
'add a clone of the pointlist for this polyline
doc.add(lp.clone,otherlayer )
« Last Edit: April 12, 2015, 14:13:46 pm by EddyCurrent »
Filmed in Supermarionation

Offline dave benson

  • CNC Jedi
  • *****
  • Posts: 1605
    • View Profile
Re: A script that could be useful for some
« Reply #55 on: April 12, 2015, 22:54:54 pm »
Hi Eddy
The otherlayer is not in scope because your function is private and otherlayer is void.
So this works to add the pointlist to the doc  myfile.Add(lp1.Clone()); 
But if your intension was to add lp1 to the otherlayer then you need to pass the otherlayer to
to your function.
Hope this makes sense.
Dave

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5083
  • Made in England
    • View Profile
Re: A script that could be useful for some
« Reply #56 on: April 13, 2015, 07:14:25 am »
Dave,
Thanks, I hear what you are saying and as it stands the code works same as David's script.
My intention was to copy closely David's VB code but could not find a clone method that looked the same.
I can see now from your example that I was missing brackets after clone, clone(), so I'm going to have another look at it.
Thank you.
Filmed in Supermarionation

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5083
  • Made in England
    • View Profile
Re: A script that could be useful for some
« Reply #57 on: April 13, 2015, 08:34:15 am »
New version added, thanks to Dave. I used 'clone()' instead of just 'clone' and it worked   ???
So now it is as close to David's VB script version as possible, and following testing it works the same too.
« Last Edit: April 13, 2015, 08:50:58 am by EddyCurrent »
Filmed in Supermarionation