CamBam
News:
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
June 16, 2019, 13:53:15 pm


Login with username, password and session length


Pages: [1]
  Print  
Author Topic: auto part creation  (Read 2425 times)
michel
Storm Trooper
***
Offline Offline

Posts: 233



View Profile WWW
« on: February 25, 2018, 06:15:34 am »

Hi,

I wonder if it is possible to make this in CB

Depending on the layer name assigned to a primitiv id that cb creates a certain mop for that specific type of id that you can preset according to your needs.

Also cb needs to identify if different primtive ids belong together. How can this be one? I was thinking if the part itself is boxed in a rectangle cb check for rectangles and al inside belongs togheter ?

I attached a simple example that shows what my thinking is

this is a part boxed in a rectangle and has the following ids

a contour that should create a profile mop with a specific camstyle
a pocket also with a preseted camstyle
there is a point that should be presetted in that part as machine origin
text ( T6) that should be presetted as the part name

the box would indicate to cb that all these belong together and the layer name each id has can be used to determine the type of mop that will be given to it.

I know this is more a custom demand for me but maybe also usefull for other applications.

Is this a possibility to achieve in cb ? Is this a big thing to program ?? I just try to find a way to speed up processes by minimizing manual interventions or settings.



regards
Michel







* CamBam+ plan cnc.jpg (30.6 KB, 955x271 - viewed 138 times.)
« Last Edit: February 25, 2018, 06:20:28 am by michel » Logged
onekk
Wookie
****
Offline Offline

Posts: 450


View Profile
« Reply #1 on: February 25, 2018, 15:53:16 pm »

Hi, the main problem is that a human can guess some things, but computer no.

The plugin or script has to resolve some problems.


1) How to distinguis the containing rectangle from the inner form
2) how to guess what is the profile and what is the pocket
3) There are more machining operations?

You are speaking of ID they are the CamBam ID (The number that cambam generate when drawing a shape (Entity in CamBam jargon))?
If you draw a Entity in CamBam one approach could be using the "Tag" properties to store some code that could be read and used by the plugin to do something, IE using this Entity to generate a profile MOP. (as example PR01 mean PRofile part 1, and maybe PO01 means POcket of Part 1).

The pugin will read all the entity and decide what to generate and maybe how to generated the MOPS, maybe applying also some settings accordig to a thid code.

In this sense automation is fairly possible, the plugin has to:

1) read a Entity Tag,
2) The Part (say 01) exist
2a) if not create it

3) create the MOP with some predefined values applying a CAMStyle and some other settings

The problem that I'vent solved is the tabs position as the routine of automatica tab creation of CamBam is not perfect and you have to tweak manually almost ever the tab positions

If you intend to import say DXF file into CamBam and automatically process them this is another different case and I think harder to achieve for the consideration I've done at the beginning of the post.

Regards

Carlo D.
Logged

Carlo D. (onekk)

eShapeoko #343 750x1000 mm + GRBL + bCNC + CamBam
EddyCurrent
CNC Jedi
*****
Offline Offline

Posts: 3950



View Profile
« Reply #2 on: February 25, 2018, 16:47:26 pm »

The Groups plugin; http://www.atelier-des-fougeres.fr/Cambam/Aide/Plugins/Groups.html
already uses Tag to group objects.

Finding which layer each member of the group is on would be okay.
Using the layer name to identify the type of MOp would be okay.
Populating the MOp with the entity ID's would be okay.

I'm not 100% how it would all come together at the end once parameters need entering and/or Styles applied, tool selection, etc.

Michel, I thought you were learning how to write plugins ? this could be a great project for you.
« Last Edit: February 25, 2018, 20:08:02 pm by EddyCurrent » Logged

Made in England
michel
Storm Trooper
***
Offline Offline

Posts: 233



View Profile WWW
« Reply #3 on: February 25, 2018, 20:36:45 pm »

Hi Eddy,

Indeed but with my current level and internal cb knowledge it would take a very long time. I am working on it but actualy with babysteps as I have little time left after my work but I am learning ;-)). I like to participate in the build up of the plugin and think with the process and hope someone can help me with it .

So I wil try to explain what I do and would like to see processed

1: I work on an dxf file in a cad program and arrange parts to process them
    - put the parts in the correct direction  
    - number the parts
    - parts are on a certain layer due to the stairprogram that inserts the parts in the cad program
    - I add a machine zero point that is also  put on a certain layer name ( called reference )

2: I import the cad file in cb to process the parts and mops to generate a gcode per part
    - I do not have to process the parts further with cb. The only thing I do with some parts is processing the arc fit to
      reduce the points in some shapes to save gcode size.

3: currently I create part per part. The name of the part is the same as the numbering I gave in the cad progam. This
     is a text that I also put on a certain layer (called part).
    I select the point to define the machine origin
    I select the shapes and add the corresponding mop and camstyle. Most parts have 2 shapes and this can go till 3
    or 5 shapes in 1 part.
   I have to repeat this for all parts in the sheet ( time consuming )

What I would like to see happening


annotating plug-in needed for automatically process the following

1: identify complete parts that can be existing out of 2 to 4 different shapes. My thinking was to enclose complete
   parts in a rectangle in a certain layer called (box) so that CB has some reference ( all shapes inside the rectangle is 1 part ). So hopefully this
    is possible.
2: create the part per rectangle  in cb and using the numbering of the part as partname . Example  ( text in rectangle
    T10 has to be used to name the part T10)
3: defining the machine origin point by take the point in the rectangle that is assigned on the layer called (reference)
    using this one as machine origin
4: selecting shape by shape in the rectangle and assign a certain MOP operation depending on the layer it is linked to
   (example ) a shape linked to the layer called ( step-outline ) must get a profile MOP with camstyle called "Treden"

   This means the plug in should have  a adaptable reference table that I fill in with the layer names and the
   corresponding mop types and camstyles.

So In my humble opinion I think this should be possible but I do not know the internal working of cb and what it is able to do.

 After this is all done  a run my great plug-in called (gcode per part)

This will create seperated gcodes for each part and store it in a folder on my harddrive.

I attached a cb file with the layout I would use with rectangles as boxes added


regards
Michel


* plan-test cnc.cb (85.33 KB - downloaded 81 times.)
« Last Edit: February 25, 2018, 20:41:15 pm by michel » Logged
EddyCurrent
CNC Jedi
*****
Offline Offline

Posts: 3950



View Profile
« Reply #4 on: February 25, 2018, 21:21:34 pm »

Best of luck with the project Michel, I certainly won't have time this year to look at it.
Logged

Made in England
michel
Storm Trooper
***
Offline Offline

Posts: 233



View Profile WWW
« Reply #5 on: February 25, 2018, 21:26:03 pm »

Hi Eddy,

thanks but what is your opinion on the logic I put behind it?

is it possible to achieve it  this way or are there issues that needs to be done completely differently ?

regards
Michel
Logged
onekk
Wookie
****
Offline Offline

Posts: 450


View Profile
« Reply #6 on: February 26, 2018, 08:11:24 am »

What I would like to see happening


annotating plug-in needed for automatically process the following

1: identify complete parts that can be existing out of 2 to 4 different shapes. My thinking was to enclose complete
   parts in a rectangle in a certain layer called (box) so that CB has some reference ( all shapes inside the rectangle is 1 part ). So hopefully this is possible.


Yes this is possible, defining the rectangle as selection area and selecting only the parts on the "part layer"



2: create the part per rectangle  in cb and using the numbering of the part as partname . Example  ( text in rectangle
    T10 has to be used to name the part T10)


quite possible, if you intend the part as a MOP part


3: defining the machine origin point by take the point in the rectangle that is assigned on the layer called (reference)
    using this one as machine origin


No problem with this is only a matter of defining a machine origin in the mop, if you intend as machine origin the 0,0 point of the created Gcode

4: selecting shape by shape in the rectangle and assign a certain MOP operation depending on the layer it is linked to
   (example ) a shape linked to the layer called ( step-outline ) must get a profile MOP with camstyle called "Treden"

   This means the plug in should have  a adaptable reference table that I fill in with the layer names and the
   corresponding mop types and camstyles.


If you put some skeleton in the plugin I could help you with some hints in parts and MOP creation via plugins I have learned and used in some of my plugins.

but

What SO you are using, I'm using Linux so if you use Windows and Visual Studio I could pass you only some code hints or snnippets, but I can't help you in compiling or so on.

I prefer to code the interface by hands, as on Linux the visual interface creation is not implemented, and as a side effect I could create some automation in interface creation, but this is matter of taste.

Regards

Carlo D.
Logged

Carlo D. (onekk)

eShapeoko #343 750x1000 mm + GRBL + bCNC + CamBam
michel
Storm Trooper
***
Offline Offline

Posts: 233



View Profile WWW
« Reply #7 on: February 27, 2018, 05:35:49 am »

Hi Carlo,

Indeed I use Windows with visual studio


regards
Michel
Logged
onekk
Wookie
****
Offline Offline

Posts: 450


View Profile
« Reply #8 on: February 27, 2018, 10:28:31 am »

The only drawback is that we have to pass the code through some text files, but this is not a big problem, as it is a matter of extend some lines in the code.

In a pratical way you want to load the dxf file in cambam and to obtain the MOP in an automated way.

so you have to create a CamBam Project, assuming you have all the relevant developing tools installed, it's a matter to to create a project and put some files in the directory.

Attached an example as Plugin.zip

This contain the Main Class as in the VB project MyClass.cs that became the main class of the plugin
and a GUI class that became the GUI of the Plugin (empty as you can design it with a GUI designer)

Code:
using System;
using System.Windows.Forms;
using CamBam;
using CamBam.UI;

/*
   CamBam Plugin Template
*/

namespace YourPluginNamespace

{
    public class PluginClass
    {
        public PluginClass()
        {
        }

        public static void InitPlugin(CamBamUI ui)
        {

            // Create a new menu item in the top Plugins menu
            ToolStripMenuItem mi = new ToolStripMenuItem();
            mi.Text = "Your Plugin Name";
            mi.Click += new EventHandler(plugin_clicked);
            ui.Menus.mnuPlugins.DropDownItems.Add(mi);

         
        }

        public static void plugin_clicked(object sender, EventArgs e)
        {
            BoxesForm iface = new PluginForm(); // This is the class that define the GUI
            iface.Owner = CamBam.ThisApplication.TopWindow;
            iface.Show();

        }



    }

}


Code:
// This namespace definition has to be the same of those in MyClass.cs

namespace YourPluginNamespace

{
partial class PluginForm // This is defined as partial as you could split some action in another class
{
// Here you will define the GUI maybe with the aid of a GUI designer
}
}

For the fine implementation in Visual Studio maybe some other in this forum could help you better than me.

* Plugin.zip (0.88 KB - downloaded 82 times.)
Logged

Carlo D. (onekk)

eShapeoko #343 750x1000 mm + GRBL + bCNC + CamBam
EddyCurrent
CNC Jedi
*****
Offline Offline

Posts: 3950



View Profile
« Reply #9 on: February 27, 2018, 11:27:18 am »

Here is a Visual Studio C# project I made for someone else;
http://www.cambam.co.uk/forum/index.php?topic=6668.msg53974#msg53974

You should download and install Visual Studio 2017 Community.
https://www.visualstudio.com/downloads/
The free version fits my use.

Ignore the rest of the thread, the original poster was a bouffon
« Last Edit: February 27, 2018, 11:34:37 am by EddyCurrent » Logged

Made in England
jk
Wookie
****
Offline Offline

Posts: 262


View Profile
« Reply #10 on: February 27, 2018, 11:38:28 am »

IMHO this is better done as script - code is very problem-specific and must be highly modifiable.
Reference table may be directly embedded into the script body. Plugin writing overhead is hardly worth the hassle.
Logged
EddyCurrent
CNC Jedi
*****
Offline Offline

Posts: 3950



View Profile
« Reply #11 on: February 27, 2018, 11:43:09 am »

Plugin writing overhead is hardly worth the hassle.

Unless you are learing how to write a plugin.
The example I posted is very general and once someone can compile it successfully they are well on the way.

There is nothing wrong with writing scripts too.
Logged

Made in England
lloydsp
CNC Jedi
*****
Offline Offline

Posts: 7886



View Profile
« Reply #12 on: February 27, 2018, 11:56:30 am »

At least for CamBam, there are a number of reasons to choose writing a plugin over a script, and vice-versa.

Scripts are quick and easy to write.  Plugins have the ability to interface with the user and CB's internals in ways scripts cannot.

For most 'trivial' jobs, I write scripts.  For things that will get used often, or require user-interaction, plugins.

Lloyd
Logged

"Pyro for Fun and Profit for More Than Fifty Years"
onekk
Wookie
****
Offline Offline

Posts: 450


View Profile
« Reply #13 on: February 27, 2018, 18:03:45 pm »

Hi michel, I have done some testing in your file, but i noted some problems.

1) The box are not external to the entities, so they can't be used to define a selection area
2) the text that define the name of the polyline have the same problem

I try to explain better:

if the box is enclosing the polyline and the text you can use the xmin,xmax and ymin,ymax to define a selection area and then process all the entities in the  selection area with a for loop and do something for the polylines and something other for the text, like:

A little idea of some workflow with dummy names of functions

Code:

foreach box in boxes

selection = box.create_selection

list = {}

foreach entity in selection
if entity.gettype() is text
createpart()
else
list.append(entity)
endif


foreach entity in  list
ent_a = CAM.entity()
if entity.gettype() is polyline
ent_a = part.createmop(entity)
ent_a.createprofile("name")

ent_a.property("profile type") = inner
...
...
...
if entity.gettype() is poinlist
if ent_a.name() is not ""
ent_a.property("mach_origin") = entity.coordinates

Logged

Carlo D. (onekk)

eShapeoko #343 750x1000 mm + GRBL + bCNC + CamBam
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.175 seconds with 19 queries.

Copyright © 2018 HexRay Ltd. | Sitemap