[Plugin] 2.5D CAM Plugin 20121202

[Plugin] 2.5D CAM Plugin 20121202

Postby jgro11 » Tue May 22, 2012 7:47 pm

Hi all. I've been working on a plugin that will create gcode for my CNC router. This plug-in will take your 3D model and create 2.5D toolpaths for use on your CNC. Just download the Ruby file and put it in your plugins folder. I'm not a programmer by trade. I just started learning at the beginning of this year. This script took me that last 5 months to create and it probably is not coded the greatest, but it works!

= CNC 2.5D Profile
Copyright 2012, John Groeschel
All Rights Reserved

== Disclaimer
THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE. PLEASE VERIFY GCODE CREATED PRIOR TO RUNNING ON CNC. I AM NOT
RESPONSIBLE FOR DAMAGE AS A RESULT OF USING THIS SCRIPT.

Permission to use, copy, modify, and distribute this software for
any purpose and without fee is hereby granted, provided that the above
copyright notice appear in all copies.

== Information
Author:: John Groeschel
Pieces of this code came from the following:
-Hatchfaces.rb by Joel Gustafsson
-Offset.rb by Rick Wilson
Organization:: none
Name:: CNC 2.5D Profile
Version:: 0.5
SU Version:: I developed this on SketchUp version 8. I have not tested on previous versions.
Date:: 05-May-2012
Description:: Creates gcode for CNC applications using 3D models in Sketchup
Requires:: TIG's Smart Offset viewtopic.php?f=323&t=49624 V1.9 or higher (version 2.1 included in zip file)
History::
0.1 beta:: 22-May-2012
* Original release
0.2:: Corrected final cut from going in opposite direction from rest of cut.
Fixed inside only and outside only cuts.
0.3:: Updated to work on MACs and to make the code unit independent, so now it works with metric parts.
Added stock size to output file.
Revised so that z axis does not lift between cuts on single hole inside cuts.
Now more than one part can be cut at a time. They have to be grouped together.
It now sets the G90 or G91 automatically in the gcode file based on model units
You no longer need to supress the units symbol. This has been turned off in the plugin
0.4:: Added require 'offset.rb'
0.5:: Revised group checking on line 167. Fixed a bug that would not change the layer status back to default. Incorporated TIG's Smart Offset. Added "Stock to Leave for inside & outside cuts.

Usage:

There are a couple of settings within Sketchup that need to be set. Select Window/Model Info and this window pops up:



Uncheck the "Display units format" If you don't, the inches symbol (") will show up in your gcode and your controller software will not recognize it.You can also set your precision to what you want in your gcode file. Whatever the precision is set to here, is what your gcode file's decimal places will be. (This has been changed in V03. The default decimal places is 3)

A few more rules to using this script. First, the part cannot be below the X-Y plane (tabletop). It will give an error if it is. Second, the script is set up that if looks for the closest point to the origin in the X-Y plane to determine where to plunge down. The best place to put your part is in the +X/+Y quadrant. If you do not, there could be a possibility that there are two closest points to origin and Sketchup will pick one at random, which could cause the tool to plunge where you don't want it to. Third, inside radii need to be modeled slightly larger than half of the cutter diameter. For example, if I'm using a .25 diameter endmill, I need to model my INSIDE fillets to .13 inches. If you really need a .125 radius, you can use a smaller endmill or model the inside corner sharp. This is not a problem on outside radii.This is changed in V05 with the incorporation of TIG's Smart Offset

Here is the model that I want to machine. The model is placed in the +X/+Y quadrant.



Your part must be in a group or this script will not work. If your model is not in a group, the script will give you an pop-up window stating that your selection is not a group. Once it is in a group, select it and select CNC 2.5D Profile from the plugin menu.



The option menu pops up. Fill in what you want for this cut. The values that you enter are stored in a text file in your plugins folder. The next time you run the script, the plugin will read these values back into the options panel.



The script will run. When it is done, a file save menu will pop up asking you where you want to save your gcode file.



When completed, the cutter paths are displayed on the screen. The cutter paths are put on a separate layer, so you can toggle them on and off.



Here is the output of the gcode file in NCplot



Please delete previous versions before installing V04!
Extract zip file to your plugins folder. You should see CNC-profile.rb in the plugins folder and you should see a new folder called CNC_Files. This is required for macs.
4
Last edited by jgro11 on Sun Jan 06, 2013 7:28 pm, edited 6 times in total.

jgro11 
PluginStore Author
PluginStore Author
 

Re: [Plugin] 2.5D CAM Plugin 20120522

Postby pilou » Tue May 22, 2012 8:23 pm

Seems a true gem! :enlight:
0
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
pilou 
Top SketchUcator
 

Re: [Plugin] 2.5D CAM Plugin 20120522

Postby jgro11 » Wed May 23, 2012 5:10 am

I fixed a couple of bugs that I found tonight while testing. I uploaded the latest file to the first thread.

jgro
0

jgro11 
PluginStore Author
PluginStore Author
 

Re: [Plugin] 2.5D CAM Plugin 20120522

Postby crash5050 » Fri May 25, 2012 7:16 am

I keep getting this error:

Safety height is lower than top of part. Please correct.
1

crash5050 
 

Re: [Plugin] 2.5D CAM Plugin 20120522

Postby jgro11 » Sat May 26, 2012 2:58 am

What is the thickness of your part and what safety height did you set? I put a comparison in the code that checks the part thickness (bounding box size) against the safety height. If the safety height (which is measured from the table top X/Y plane or Z 0) is lower than the part thickness, the message pops up. I put this in because I can't tell you how many times I changed the part thickness and forgot to change the safety height. I've ruined quite a few pieces of MDF. :oops:

jgro
0

jgro11 
PluginStore Author
PluginStore Author
 

Re: [Plugin] 2.5D CAM Plugin 20120522

Postby Michaelv » Fri Jun 01, 2012 11:54 pm

Awesome!

I've been wanting to do a CAM plugin for a long time, just never got to it.
I tried it on Mac, didn't work, but I'm fixing it.
It was looking for my default text file, which of course doesn't exist since I never ran it, so it's stuck. Like I said I will debug on Mac and keep you posted.

Michael
0

Michaelv 
 

Re: [Plugin] 2.5D CAM Plugin 20120522

Postby Michaelv » Sat Jun 02, 2012 1:28 am

crash5050 wrote:I keep getting this error:

Safety height is lower than top of part. Please correct.


Are you working in mm? This version is inches by default, and the default safety height is 1 inch.
So unless you enter a safety higher than your part it won't work. If working in mm and the part is let's say 40mm high, it requires a 41 inches default.
0

Michaelv 
 

Re: [Plugin] 2.5D CAM Plugin 20120522

Postby saikhamhein » Wed Jun 06, 2012 4:22 pm

I cant save the gcode. There is no save window.
0

saikhamhein 
 

Re: [Plugin] 2.5D CAM Plugin 20120522

Postby trock2957 » Thu Jun 21, 2012 3:52 am

Unable to get anything the generate code sceen. No warnings, just blank results....
Tried a simple square and grouped it, No action after clicking OK in the Gcode Screen..Tried several basic primitive shapes and grouped.
Any Idea?
Thanks,
0

trock2957 
 

Re: [Plugin] 2.5D CAM Plugin 20120522

Postby squartochi » Mon Jul 02, 2012 4:12 pm

Same as above, looks like it makes some passes. But no popup save window. This is from the ruby console

C:/Program Files/Google/Google SketchUp 7/Plugins/CNC-profile_v02.rb:833:in `call'
(eval):892


Thanks,
Scott
0

squartochi 
 

Re: [Plugin] 2.5D CAM Plugin 20120522

Postby crash5050 » Thu Jul 26, 2012 9:27 pm

Ok, I must be doing something wrong.

1. I went out to 3d warehouse and grabbed a hutch that I want to cut on my CNC. http://sketchup.google.com/3dwarehouse/ ... revstart=0

I Imported it into Sketchup, and selected all and made it a group amdI still keep getting this darned error. Am I doing something that is impossible?
0

crash5050 
 

Re: [Plugin] 2.5D CAM Plugin 20120522

Postby Fritzache » Sun Dec 02, 2012 11:21 am

Hi. Interesting plugin. So? no more support for it? I have the same problem as the guys above.
No save window appears. thank you in advance.
0

Fritzache 
 

Re: [Plugin] 2.5D CAM Plugin 20120522

Postby jgro11 » Sun Dec 02, 2012 2:22 pm

I need more details. Do you have the ruby console open? What does it say when you run the plugin.

jgro
0

jgro11 
PluginStore Author
PluginStore Author
 

Re: [Plugin] 2.5D CAM Plugin 20120522

Postby Dave R » Sun Dec 02, 2012 4:17 pm

Hi Joel,

I gave your plugin a try and I seem to be getting the same result. No Save window. I also don't seem to see the tool path as you show in your images, either. Here are some screen shots for you.

CNC1.png

the setup. Note that Units is set to Decimal and units aren't displayed. The thing is a group.

CNC2.png

Immediately after running the plugin. No save option.

CNC3.png

And the same in X-ray.
0
%

(THERE'S NO PLACE LIKE)

G28 X0.0 Y0.0 Z0.0

M30

%
User avatar
Dave R 
Global Moderator
 

Re: [Plugin] 2.5D CAM Plugin 20121202

Postby jgro11 » Sun Dec 02, 2012 8:23 pm

I just uploaded the latest version V03. (look at the first post) Give that a try. It has been changed to work for english and metric units and it should work on macs. (Special thanks to MichaelV for helping me with that!) Hopefully this should fix the problem. If not, upload the .skp file here and I'll take a look at it.

jgro
0

jgro11 
PluginStore Author
PluginStore Author
 

Re: [Plugin] 2.5D CAM Plugin 20120522

Postby Dave R » Sun Dec 02, 2012 9:03 pm

Joel, I tried the latest version. Still no Save box. Here's the dump from the Console.

C:/Program Files/Google/Google SketchUp 8/Plugins/CNC_Files/CNC_Profile_Defaults.txt

2


Error: #<NoMethodError: undefined method `offset' for #<Sketchup::Face:0xab8d4cc>>
C:/Program Files/Google/Google SketchUp 8/Plugins/CNC-profile_v03.rb:712:in `inside_offset'
C:/Program Files/Google/Google SketchUp 8/Plugins/CNC-profile_v03.rb:655:in `each'
C:/Program Files/Google/Google SketchUp 8/Plugins/CNC-profile_v03.rb:655:in `inside_offset'
C:/Program Files/Google/Google SketchUp 8/Plugins/CNC-profile_v03.rb:215:in `mode'
C:/Program Files/Google/Google SketchUp 8/Plugins/CNC-profile_v03.rb:72:in `activate'
C:/Program Files/Google/Google SketchUp 8/Plugins/CNC-profile_v03.rb:912:in `select_tool'
C:/Program Files/Google/Google SketchUp 8/Plugins/CNC-profile_v03.rb:912

This time the green face displayed at the bottom instead of the top.

Another odd thing is that unticking the visibility box for the 'path' layer makes no change.

I would like to also suggest that when the path layer is created it is not made as the active layer. Layer 0 should remain active. And it would be nice if the .rb file kept the same name through version changes so installing a new version just overwrites the old.

Thanks for taking a look at this.
0
%

(THERE'S NO PLACE LIKE)

G28 X0.0 Y0.0 Z0.0

M30

%
User avatar
Dave R 
Global Moderator
 

Re: [Plugin] 2.5D CAM Plugin 20121202

Postby TIG » Sun Dec 02, 2012 9:16 pm

Looks like you need 'offset.rb' in the Plugins folder - it's freely available from http://Smustard.com ... http://www.smustard.com/script/Offset
That file should also have a 'require' at the start of your script's code, as it needs to loaded before the script...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] 2.5D CAM Plugin 20121202

Postby Dave R » Sun Dec 02, 2012 9:41 pm

I thought I had that file installed already from long ago. It is now and I get the following:

C:/Program Files/Google/Google SketchUp 8/Plugins/CNC_Files/CNC_Profile_Defaults.txt
Error: #<NoMethodError: undefined method `typename' for nil:NilClass>
C:/Program Files/Google/Google SketchUp 8/Plugins/CNC-profile_v03.rb:164:in `find_bounds'
C:/Program Files/Google/Google SketchUp 8/Plugins/CNC-profile_v03.rb:71:in `activate'
C:/Program Files/Google/Google SketchUp 8/Plugins/CNC-profile_v03.rb:912:in `select_tool'
C:/Program Files/Google/Google SketchUp 8/Plugins/CNC-profile_v03.rb:912
0
%

(THERE'S NO PLACE LIKE)

G28 X0.0 Y0.0 Z0.0

M30

%
User avatar
Dave R 
Global Moderator
 

Re: [Plugin] 2.5D CAM Plugin 20121202

Postby jgro11 » Sun Dec 02, 2012 11:13 pm

OK, I added "require 'offset.rb' to the plugin and uploaded as V.04. (Thanks for the catch TIG!). I also renamed the plugin back to CNC-profile.rb so you can just load it over the top of what you have in your plugins folder. The version number will still exist in the plugins menu.

Quote "I would like to also suggest that when the path layer is created it is not made as the active layer. Layer 0 should remain active." The path layer is set active during the geometry creation and at the end of the plugin the active layer gets changed back to the default layer. You never got to the end of the plugin, so it never got the chance to change it back to the default layer.

Quote "C:/Program Files/Google/Google SketchUp 8/Plugins/CNC_Files/CNC_Profile_Defaults.txt
Error: #<NoMethodError: undefined method `typename' for nil:NilClass>
C:/Program Files/Google/Google SketchUp 8/Plugins/CNC-profile_v03.rb:164:in `find_bounds'
C:/Program Files/Google/Google SketchUp 8/Plugins/CNC-profile_v03.rb:71:in `activate'
C:/Program Files/Google/Google SketchUp 8/Plugins/CNC-profile_v03.rb:912:in `select_tool'
C:/Program Files/Google/Google SketchUp 8/Plugins/CNC-profile_v03.rb:912"

Try deleting the CNC_Profile_Defaults.txt from the CNC_files folder in your plugins folder. It should create a new one when you run the plugin. See if that helps.

jgro
0

jgro11 
PluginStore Author
PluginStore Author
 

Re: [Plugin] 2.5D CAM Plugin 20121202

Postby TIG » Sun Dec 02, 2012 11:15 pm

@Dave...
That part of the code is checking that the first item in the current selection is a group.
Unfortunately if there's no selection that 'nil' and that has no .typename...
There are better ways yo check what's selected, if anything is...

To get it to work as it is... make sure you have something selected before using the tool, and ensure that it's a group... :roll:
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] 2.5D CAM Plugin 20121202

Postby Dave R » Sun Dec 02, 2012 11:17 pm

I'll try deleting the TXT file and retry.

TIG, I did have the group selected before starting the plugin. I even made sure to make it a group even though I don't like to use groups. ;)
0
%

(THERE'S NO PLACE LIKE)

G28 X0.0 Y0.0 Z0.0

M30

%
User avatar
Dave R 
Global Moderator
 

Re: [Plugin] 2.5D CAM Plugin 20121202

Postby TIG » Sun Dec 02, 2012 11:21 pm

Edit the .rb file with a plain-text editor like Notepad...
The line reads
if Sketchup.active_model.selection[0].typename != "Group"
Change it to read
unless selection[0] && selection[0].is_a?(Sketchup::Group)
This will at least get over that hurdle... :?
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] 2.5D CAM Plugin 20121202

Postby Dave R » Sun Dec 02, 2012 11:35 pm

I deleted the TXT file and tried running it. It worked! The script did give me the save box and I was able to save the file. Unfortunately it left the path layer as active when it completed.

I'll edit the rb file with your additions, TIG.

Another request: Could you set it to save to the same location as the SKP file? You could actually automate the save process giving the file the same name as the SKP file.

gcode.png


Edit to add:

I closed the SKP file without saving it and edited the text per TIG's instruction. Then re-tried it. It worked but I got the following in the console. Note the error message at the end.

C:/Program Files/Google/Google SketchUp 8/Plugins/CNC_Files/CNC_Profile_Defaults.txt

2




#<Sketchup::Face:0xaae9034>



2




#<Sketchup::Face:0xaac57d8>



2




#<Sketchup::Face:0xaaa1f04>



2




#<Sketchup::Face:0xaa7c4ac>



2



#<Sketchup::Face:0xaa69a8c>

#<Sketchup::Face:0xaa68204>


Error: #<TypeError: can't convert nil into String>
C:/Program Files/Google/Google SketchUp 8/Plugins/CNC-profile_v03.rb:879:in `initialize'
C:/Program Files/Google/Google SketchUp 8/Plugins/CNC-profile_v03.rb:879:in `new'
C:/Program Files/Google/Google SketchUp 8/Plugins/CNC-profile_v03.rb:879:in `gcode_write'
C:/Program Files/Google/Google SketchUp 8/Plugins/CNC-profile_v03.rb:275:in `mode'
C:/Program Files/Google/Google SketchUp 8/Plugins/CNC-profile_v03.rb:72:in `activate'
C:/Program Files/Google/Google SketchUp 8/Plugins/CNC-profile_v03.rb:912:in `select_tool'
C:/Program Files/Google/Google SketchUp 8/Plugins/CNC-profile_v03.rb:912
0
%

(THERE'S NO PLACE LIKE)

G28 X0.0 Y0.0 Z0.0

M30

%
User avatar
Dave R 
Global Moderator
 

Re: [Plugin] 2.5D CAM Plugin 20121202

Postby timj » Tue Dec 11, 2012 9:27 pm

I'm having similar issues. OS X, sketchup 8

Everything is installed correctly, 3D model made to be a group. No save window or new layer appear. Here is the dialog box output:

/Users/timjerome/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/CNC_Files/CNC_Profile_Defaults.txt
Error: #<Errno::ENOENT: No such file or directory - /Users/timjerome/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/CNC_Files/CNC_Profile_Defaults.txt>
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/CNC-profile.rb:118:in `initialize'
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/CNC-profile.rb:118:in `new'
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/CNC-profile.rb:118:in `inputs'
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/CNC-profile.rb:71:in `activate'
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/CNC-profile.rb:914:in `select_tool'
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/CNC-profile.rb:914
0

timj 
 

Re: [Plugin] 2.5D CAM Plugin 20121202

Postby Dave R » Tue Dec 11, 2012 10:23 pm

Did you install Offset.rb?

Make sure the Plugins folder has read and write permissions enabled.
0
%

(THERE'S NO PLACE LIKE)

G28 X0.0 Y0.0 Z0.0

M30

%
User avatar
Dave R 
Global Moderator
 

Re: [Plugin] 2.5D CAM Plugin 20121202

Postby timj » Wed Dec 12, 2012 12:09 pm

Yes offset.rb is installed within my plugins folder (I've also checked the read and write permissions). I've tried reinstalling the plugins and am still getting the same errors. I'm not sure what else to try?
0

timj 
 

Re: [Plugin] 2.5D CAM Plugin 20121202

Postby TIG » Wed Dec 12, 2012 12:38 pm

@timj
Your error says:
/Users/timjerome/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/CNC_Files/CNC_Profile_Defaults.txt
So some code is expecting the tool's subfolder and thereby the txt file to be in that Plugins folder structure.
BUT that is NOT the right MAC 'plugins' folder - do NOT install into the 'User' one, rather use the one in the HD tree - ensuring you have full read+write permissions to this folder:
Macintosh HD/Library/Application Support/Google Sketchup 8/Sketchup/plugins

Another potential issue is that if your MAC has a case-sensitive system some files can NOT be 'found' - so for example if a folder is named 'plugins' and a script assumes it's called 'Plugins' it will be found OK on a PC or most MACs, but on a case-sensitive MAC system it will fail... This is unlikely, but if all else fails...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] 2.5D CAM Plugin 20121202

Postby Dave R » Wed Dec 12, 2012 12:51 pm

Good call, TIG. I missed that "Users" detail.
0
%

(THERE'S NO PLACE LIKE)

G28 X0.0 Y0.0 Z0.0

M30

%
User avatar
Dave R 
Global Moderator
 

Re: [Plugin] 2.5D CAM Plugin 20121202

Postby jgro11 » Sun Jan 06, 2013 7:36 pm

I uploaded V05 in the first post. This version's major change is that I incorporated TIG'S Smart Offset plugin. So now you don't have to have inside fillets on your part larger than half the mill diameter. See image below. The fillet radius is .100 and I'm cutting it with a .25 diameter cutter (.125 radius). It creates a nice sharp corner, like it should.

Capture.JPG


I also added the ability to have stock left after machining to either the inside or outside cuts.

Enjoy!

jgro11
0

jgro11 
PluginStore Author
PluginStore Author
 

Re: [Plugin] 2.5D CAM Plugin 20121202

Postby icoff » Sun Jan 06, 2013 9:59 pm

Nice job! I'm sorry but I don't know very well english to follow all your explanation... :( but I'm very interesting in this plugin because I want to buy a CNC mill in the next week....
So i ask you humbly if you can explain me how make work this plugin.
I download the V5,0 and I try use it, but there are something wrong in my program because don't work.
Some simply questions:
It's necessary to have other plugin installed and which?
I use in SU centimeter as measure unit; in the first window that is open (where I can enter the parameter of the milling...) what kind of measure unit do you use?
In the ruby consol I see an error that you can see in the image below.
Cattura.JPG


Ok, after this post I go in my control panel and change the level in "Beginner"..... :D
0
User avatar
icoff 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 

Next


 

Return to Plugins

cron

Who is online

Users browsing this forum: fred.dy and 7 guests

Visit our sponsors: