Author Topic: Grid size/shape saves with .cb file  (Read 39692 times)

Offline EL34

  • CNC Jedi
  • *****
  • Posts: 783
    • View Profile
    • EL34's CNC Stuff
Grid size/shape saves with .cb file
« on: October 21, 2021, 14:26:52 pm »
I change grid sizes and shapes for many projects

It's a pain to go into options and change the grid for each project
And hopefully I can remember what the grid setup was for a previous project

Any way to save the grid for each .cb file?
« Last Edit: October 21, 2021, 17:02:07 pm by dh42 »
Mach 3, Cambam, Autodesk Quickcad 8, machine info -> http://www.el34world.com/Misc/Cnc/CNC0.htm

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7566
    • View Profile
    • Cambam V1.0 French Doc
Re: Grid aize/shape saves with .cb file
« Reply #1 on: October 21, 2021, 14:38:19 pm »
Hello

Quote
Any way to save the grid for each .cb file?

No, but you can use this plugin to select a grid (minor scale) quickly.

http://www.atelier-des-fougeres.fr/Cambam/Aide/Plugins/gridmanager.html

I have a look and the grid is also not saved in template file so we can't use a "New from template" ...

++
David


Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5322
  • Made in England
    • View Profile
Re: Grid aize/shape saves with .cb file
« Reply #2 on: October 21, 2021, 15:23:52 pm »
How about a modification to the gridmanager plugin.

1. For each cb file the user should create a Layer called "Grid" and populate the Tag field with grid parameters, minX, minY, maxX, maxY, major scale, minor scale 
e.g. -400,-300,400,300,10,1
2. This info will be saved in the cb file.
3. Add a button to the gridmanager plugin called, "Update Grid" for example
4. When a cb is opened, the gridmanger will check if a Layer called "Grid" exists and will ask the user if they want to update it.
5. Pressing the "Update Grid" button will read the values in the layer Tag and update the grid accordingly.
Filmed in Supermarionation

Offline Dragonfly

  • CNC Jedi
  • *****
  • Posts: 2678
    • View Profile
Re: Grid aize/shape saves with .cb file
« Reply #3 on: October 21, 2021, 16:11:58 pm »
I must admit I never use grid. Maybe except the very beginning of my work with CB. :)

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7566
    • View Profile
    • Cambam V1.0 French Doc
Re: Grid aize/shape saves with .cb file
« Reply #4 on: October 21, 2021, 16:22:38 pm »
Yep, or another way can be a script object ... but I'm very not comfortable with Python  >:(

++
David

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7566
    • View Profile
    • Cambam V1.0 French Doc
Re: Grid aize/shape saves with .cb file
« Reply #5 on: October 21, 2021, 16:43:50 pm »
Re

try this:

In Tools/options, edit the " Default Script Entity" property and enter this for mm user

Code: [Select]
# change the scale values then click RUN
minor_scale = 1
major_scale = 10

CamBamConfig.Defaults.GridInfo_Metric.MinorScale = minor_scale
CamBamConfig.Defaults.GridInfo_Metric.MajorScale = major_scale

or for Inches user, enter this one

Code: [Select]
# change the scale values then click RUN
minor_scale = .125
major_scale = 1

CamBamConfig.Defaults.GridInfo_Inches.MinorScale = minor_scale
CamBamConfig.Defaults.GridInfo_Inches.MajorScale = major_scale

Of course, feel free to change the values for minor_scale and major_scale for those you use mostly.

Now, when you creates a new file, just add a script objet through the toolbar ; it will contain the script with the default settings we have added in the options ; if needed, double click on the script object, change the values for scales and click RUN (or OK) in the script window. Because the script object is saved with the file, the setting are retained, and when you open the file the script object is automatically executed and the grid updated.

++
David
« Last Edit: October 21, 2021, 17:18:34 pm by dh42 »

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7566
    • View Profile
    • Cambam V1.0 French Doc
Re: Grid aize/shape saves with .cb file
« Reply #6 on: October 21, 2021, 16:56:46 pm »
if you want also manage the grid size you can enter this for mm user

Code: [Select]
# change the scale values then click RUN
minor_scale = 1
major_scale = 10

# change the grid size
MinX = -100
MinY = -100
MaxX = 100
MaxY = 100

#
CamBamConfig.Defaults.GridInfo_Metric.MinorScale = minor_scale
CamBamConfig.Defaults.GridInfo_Metric.MajorScale = major_scale

CamBamConfig.Defaults.GridInfo_Metric.Minimum = Point2F(MinX,MinY)
CamBamConfig.Defaults.GridInfo_Metric.Maximum = Point2F(MaxX,MaxY)

and for inches

Code: [Select]
# change the scale values then click RUN
minor_scale = 0.125
major_scale = 1

# change the grid size
MinX = -10
MinY = -10
MaxX = 10
MaxY = 10

#
CamBamConfig.Defaults.GridInfo_Inches.MinorScale = minor_scale
CamBamConfig.Defaults.GridInfo_Inches.MajorScale = major_scale

CamBamConfig.Defaults.GridInfo_Inches.Minimum = Point2F(MinX,MinY)
CamBamConfig.Defaults.GridInfo_Inches.Maximum = Point2F(MaxX,MaxY)

PS: the script object can be anywhere in the mop tree

++
David

Offline Bubba

  • CNC Jedi
  • *****
  • Posts: 3376
    • View Profile
Re: Grid size/shape saves with .cb file
« Reply #7 on: October 21, 2021, 23:44:19 pm »
I must admit I never use grid. Maybe except the very beginning of my work with CB. :)
****************************
+1 ;)
My 2ยข

Win11, CB(1.0)rc 1(64 bit) Mach3, ESS, G540, 4th Axis, Endurance Laser.

Offline EL34

  • CNC Jedi
  • *****
  • Posts: 783
    • View Profile
    • EL34's CNC Stuff
Re: Grid aize/shape saves with .cb file
« Reply #8 on: October 22, 2021, 18:09:02 pm »
How about a modification to the gridmanager plugin.

1. For each cb file the user should create a Layer called "Grid" and populate the Tag field with grid parameters, minX, minY, maxX, maxY, major scale, minor scale 
e.g. -400,-300,400,300,10,1
2. This info will be saved in the cb file.
3. Add a button to the gridmanager plugin called, "Update Grid" for example
4. When a cb is opened, the gridmanger will check if a Layer called "Grid" exists and will ask the user if they want to update it.
5. Pressing the "Update Grid" button will read the values in the layer Tag and update the grid accordingly.

I think you have a better idea of what I need :)

BTW, I have 100's of files and many have their own unique grid
The grid can be in inches or MM
I use inches on my CNC machine
And MM's on my 3D printer and Pick and Place machine

Grids are used in many of my files as snap-to points for hole drillings

For example, in the screen shot below
This file has a non square grid

X - 0.296875 inches
Y - 0.19685 inches

But the grid does not start at 0,0
The material is mounted in a fixture and the X,Y lower edge may be at 0,0, but the grid starts at a different X,Y

The grid origin starts at
X = 0.25 inches
Y = 0.19685

I DL'd the grid manager but it does not do what I want

What I need is whatever grid I am using in a .cb file, needs to be saved as part of that file
If I open that file a year from now, I may have no idea what the original grid was.

« Last Edit: October 22, 2021, 18:11:51 pm by EL34 »
Mach 3, Cambam, Autodesk Quickcad 8, machine info -> http://www.el34world.com/Misc/Cnc/CNC0.htm

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5322
  • Made in England
    • View Profile
Re: Grid size/shape saves with .cb file
« Reply #9 on: October 22, 2021, 19:59:00 pm »
I think David's method is quite good but only if you know about script entities.

I've attached a cb file ready setup to do what you require.

In the "default" layer is a script entity, it is saved in the cb file.

Double click on it and change the values to suit, then hit the "Run" button at the bottom.
Filmed in Supermarionation

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7566
    • View Profile
    • Cambam V1.0 French Doc
Re: Grid size/shape saves with .cb file
« Reply #10 on: October 22, 2021, 21:11:22 pm »
Hello

Quote
I think David's method is quite good but only if you know about script entities.

Just need to follow instructions to create the "default" script ; after that you just need to add a script objet en change the values ; no needs to be programmer ;)

You can also use more than one script entity in the same project with differents grid settings for each .. in this case, disable the "Execute On Update" in the script entity so it is only executed when you want (by selecting the script entity and hit F5)

++
David

Offline EL34

  • CNC Jedi
  • *****
  • Posts: 783
    • View Profile
    • EL34's CNC Stuff
Re: Grid size/shape saves with .cb file
« Reply #11 on: October 23, 2021, 12:44:04 pm »
I think David's method is quite good but only if you know about script entities.

I've attached a cb file ready setup to do what you require.

In the "default" layer is a script entity, it is saved in the cb file.

Double click on it and change the values to suit, then hit the "Run" button at the bottom.

Thanks, that helps a lot
I can copy that layer into my other files and change the values

Too bad we can't have separate X and Y grid spacing.
The screen shot I posted above is from a very old 2D CAD program that can do all of that
Autodesk QuickCad8

I still use it for simple 2D drilling layouts



Mach 3, Cambam, Autodesk Quickcad 8, machine info -> http://www.el34world.com/Misc/Cnc/CNC0.htm

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5322
  • Made in England
    • View Profile
Re: Grid size/shape saves with .cb file
« Reply #12 on: October 23, 2021, 14:25:17 pm »
Another idea, it sounds like a lot has to be done but in reality it takes very little time.

1. install the "Snappy" plugin here; http://www.atelier-des-fougeres.fr/Cambam/Aide/Plugins/Snappy.html
2. open CamBam then under The Plugins menu select "Snappy"
in the options form select "Intersection" and "Snap to Object"
3. hide the CamBam grid, Tools->Options->Show grid = false
4 make a layer called "Grid" and change it's colour to the required grid colour.
5. draw the position and size of the required grid using a Rectangle.
6. use menu item "Draw->Fill Region->Vertical Hatch" then specify the X distance
7. use menu item "Draw->Fill Region->Horizontal Hatch" then specify the Y distance


You now have a grid with different X and Y spacings and the cursor will snap to the intersection points, plus it will be saved with the cb file.

Edit:

I've attached a sample cb file using your previously quoted parameters



« Last Edit: October 23, 2021, 18:31:24 pm by EddyCurrent »
Filmed in Supermarionation

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 9075
    • View Profile
Re: Grid size/shape saves with .cb file
« Reply #13 on: October 23, 2021, 15:58:12 pm »
Cool!  Thank you, Eddy!

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

Offline EL34

  • CNC Jedi
  • *****
  • Posts: 783
    • View Profile
    • EL34's CNC Stuff
Re: Grid size/shape saves with .cb file
« Reply #14 on: October 24, 2021, 12:36:30 pm »

You now have a grid with different X and Y spacings and the cursor will snap to the intersection points, plus it will be saved with the cb file.
Edit:
I've attached a sample cb file using your previously quoted parameters

Thanks
I will test this later today
Mach 3, Cambam, Autodesk Quickcad 8, machine info -> http://www.el34world.com/Misc/Cnc/CNC0.htm