discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Changing grid reference on screen?

TP
tony.pemberton.cowroast@gmail.com
Sun, Jul 24, 2022 12:00 PM

A first post so I’m probably not aware of protocol here!

I have used Openscad for the last 2.5 years and I find it great for doing my models and otherthings. I use version 2021.1. both on W7 and Debian11.

So far, I have not needed to determine absolute sizes during Openscad design stages as, by default, designs are 3D printed with metric dimensions. I am aware that Openscad is actually dimensionless but I would like to be able to determine sizes of designed objects, on screen, before committing to print.

I have searched the settings of Openscad to change the dimension scale of the X,Y and Z lines and or introduce screen grid so that I can zoom in or out to see how big an object is on screen (relatively). At present the screen scale normally shows intervals of 1(cm). I would like to be able to have an optional  grid of 0.1(mm) (not just marks on the X,Y,Z bars) when I zoom in to a very small part I am designing.

Am I missing something in the Openscad settings? It would be nice to be able to switch screen grid on or off with a function button too.

Thanks, Tony

A first post so I’m probably not aware of protocol here! I have used Openscad for the last 2.5 years and I find it great for doing my models and otherthings. I use version 2021.1. both on W7 and Debian11. So far, I have not needed to determine absolute sizes during Openscad design stages as, by default, designs are 3D printed with metric dimensions. I am aware that Openscad is actually dimensionless but I would like to be able to determine sizes of designed objects, on screen, before committing to print. I have searched the settings of Openscad to change the dimension scale of the X,Y and Z lines and or introduce screen grid so that I can zoom in or out to see how big an object is on screen (relatively). At present the screen scale normally shows intervals of 1(cm). I would like to be able to have an **optional grid** of 0.1(mm) (not just marks on the X,Y,Z bars) when I zoom in to a very small part I am designing. Am I missing something in the Openscad settings? It would be nice to be able to switch screen grid on or off with a function button too. Thanks, Tony
JB
Jordan Brown
Sun, Jul 24, 2022 7:07 PM

On 7/24/2022 5:00 AM, tony.pemberton.cowroast@gmail.com wrote:

 A first post so I’m probably not aware of protocol here!

You're fine.

I have used Openscad for the last 2.5 years and I find it great for
doing my models and otherthings. I use version 2021.1. both on W7 and
Debian11.

So far, I have not needed to determine absolute sizes during Openscad
design stages as, by default, designs are 3D printed with metric
dimensions. I am aware that Openscad is actually dimensionless but I
would like to be able to determine sizes of designed objects, on
screen, before committing to print.

I have searched the settings of Openscad to change the dimension scale
of the X,Y and Z lines and or introduce screen grid so that I can zoom
in or out to see how big an object is on screen (relatively). At
present the screen scale normally shows intervals of 1(cm). I would
like to be able to have an optional grid of 0.1(mm) (not just marks
on the X,Y,Z bars) when I zoom in to a very small part I am designing.

Am I missing something in the Openscad settings? It would be nice to
be able to switch screen grid on or off with a function button too.

First... there are no units in OpenSCAD, except what you make up for
yourself.  The screen scale is not in mm, or cm, or inches, or miles, or
smoots.  It's in OpenSCAD units, and OpenSCAD units are as large as you
want to pretend them to be.  Indeed, people often or even usually treat
them as millimeters, because that's what slicers want, but OpenSCAD
doesn't know nor care.  (When I model my house at one OpenSCAD unit per
real-world inch, and then print it at one OpenSCAD unit per millimeter,
how big is an OpenSCAD unit?)

Second... no, there's no grid mechanism.  (What would a 3D grid look
like?  Or maybe you'd lay a 2D grid on one of the axis planes.)

However, there's nothing stopping you from drawing your own grid.  Use %
so that it isn't included in your model.

Here's a semi-fancy implementation.  Rotate and reposition as desired. 
There's an argument that this should all be done in 2D, but rotating 2D
off of the XY plane bothers me.  Note that the minor ticks are pretty
small and can sometimes disappear on the display unless zoomed in.  You
might want to turn off displaying the axes.

module grid2D(min=[-100,-100], max=[100,100], minor=1, major=10) {
    minor_len = 0.3;
    minor_thick = 0.05;
    major_len = 0.6;
    major_thick = 0.2;
    thick = 0.1;
    labelsize = 2;
    yoffset = 1;
    xoffset = 1;
    close = 0.1;

    module minor_tick() {
        cube([minor_len, minor_thick, thick], center=true);
        cube([minor_thick, minor_len, thick], center=true);
    }

    module major_tick() {
        cube([major_len, major_thick, thick], center=true);
        cube([major_thick, major_len, thick], center=true);
    }

    module minor_ticks(xrange, yrange) {
        for (x=xrange, y=yrange) {
            if (abs(x%major) > close || abs(y%major) > close) {
                translate([x,y,0]) minor_tick();
            }
        }
    }

    module major_ticks(xrange, yrange) {
        for (x=xrange, y=yrange) {
            translate([x,y,0]) major_tick();
        }
    }

    module xlabel(x) {
        translate([x,yoffset,0])
            linear_extrude(height=thick, center=true)
            text(str(x), size=labelsize, halign="center");
    }

    module ylabel(y) {
        translate([xoffset,y,0])
            linear_extrude(height=thick, center=true)
            text(str(y), size=labelsize, valign="center");
    }

    for (x=[-major:-major:min.x]) xlabel(x);
    for (x=[major:major:max.x]) xlabel(x);
    for (y=[-major:-major:min.y]) ylabel(y);
    for (y=[major:major:max.y]) ylabel(y);

    minor_ticks(xrange=[-minor:-minor:min.x], yrange=[-minor:-minor:min.y]);
    minor_ticks(xrange=[0:minor:max.x], yrange=[-minor:-minor:min.y]);
    minor_ticks(xrange=[-minor:-minor:min.x], yrange=[0:minor:max.y]);
    minor_ticks(xrange=[0:minor:max.x], yrange=[0:minor:max.y]);

    major_ticks(xrange=[-major:-major:min.x], yrange=[-major:-major:min.y]);
    major_ticks(xrange=[0:major:max.x], yrange=[-major:-major:min.y]);
    major_ticks(xrange=[-major:-major:min.x], yrange=[0:major:max.y]);
    major_ticks(xrange=[0:major:max.x], yrange=[0:major:max.y]);
}

%grid2D(min=[-20,-20], max=[20,20]);
On 7/24/2022 5:00 AM, tony.pemberton.cowroast@gmail.com wrote: > > A first post so I’m probably not aware of protocol here! > You're fine. > I have used Openscad for the last 2.5 years and I find it great for > doing my models and otherthings. I use version 2021.1. both on W7 and > Debian11. > > So far, I have not needed to determine absolute sizes during Openscad > design stages as, by default, designs are 3D printed with metric > dimensions. I am aware that Openscad is actually dimensionless but I > would like to be able to determine sizes of designed objects, on > screen, before committing to print. > > I have searched the settings of Openscad to change the dimension scale > of the X,Y and Z lines and or introduce screen grid so that I can zoom > in or out to see how big an object is on screen (relatively). At > present the screen scale normally shows intervals of 1(cm). I would > like to be able to have an *optional grid* of 0.1(mm) (not just marks > on the X,Y,Z bars) when I zoom in to a very small part I am designing. > > Am I missing something in the Openscad settings? It would be nice to > be able to switch screen grid on or off with a function button too. > First... there are no units in OpenSCAD, except what you make up for yourself.  The screen scale is not in mm, or cm, or inches, or miles, or smoots.  It's in OpenSCAD units, and OpenSCAD units are as large as you want to pretend them to be.  Indeed, people often or even usually treat them as millimeters, because that's what slicers want, but OpenSCAD doesn't know nor care.  (When I model my house at one OpenSCAD unit per real-world inch, and then print it at one OpenSCAD unit per millimeter, how big is an OpenSCAD unit?) Second... no, there's no grid mechanism.  (What would a 3D grid look like?  Or maybe you'd lay a 2D grid on one of the axis planes.) However, there's nothing stopping you from drawing your own grid.  Use % so that it isn't included in your model. Here's a semi-fancy implementation.  Rotate and reposition as desired.  There's an argument that this should all be done in 2D, but rotating 2D off of the XY plane bothers me.  Note that the minor ticks are pretty small and can sometimes disappear on the display unless zoomed in.  You might want to turn off displaying the axes. module grid2D(min=[-100,-100], max=[100,100], minor=1, major=10) { minor_len = 0.3; minor_thick = 0.05; major_len = 0.6; major_thick = 0.2; thick = 0.1; labelsize = 2; yoffset = 1; xoffset = 1; close = 0.1; module minor_tick() { cube([minor_len, minor_thick, thick], center=true); cube([minor_thick, minor_len, thick], center=true); } module major_tick() { cube([major_len, major_thick, thick], center=true); cube([major_thick, major_len, thick], center=true); } module minor_ticks(xrange, yrange) { for (x=xrange, y=yrange) { if (abs(x%major) > close || abs(y%major) > close) { translate([x,y,0]) minor_tick(); } } } module major_ticks(xrange, yrange) { for (x=xrange, y=yrange) { translate([x,y,0]) major_tick(); } } module xlabel(x) { translate([x,yoffset,0]) linear_extrude(height=thick, center=true) text(str(x), size=labelsize, halign="center"); } module ylabel(y) { translate([xoffset,y,0]) linear_extrude(height=thick, center=true) text(str(y), size=labelsize, valign="center"); } for (x=[-major:-major:min.x]) xlabel(x); for (x=[major:major:max.x]) xlabel(x); for (y=[-major:-major:min.y]) ylabel(y); for (y=[major:major:max.y]) ylabel(y); minor_ticks(xrange=[-minor:-minor:min.x], yrange=[-minor:-minor:min.y]); minor_ticks(xrange=[0:minor:max.x], yrange=[-minor:-minor:min.y]); minor_ticks(xrange=[-minor:-minor:min.x], yrange=[0:minor:max.y]); minor_ticks(xrange=[0:minor:max.x], yrange=[0:minor:max.y]); major_ticks(xrange=[-major:-major:min.x], yrange=[-major:-major:min.y]); major_ticks(xrange=[0:major:max.x], yrange=[-major:-major:min.y]); major_ticks(xrange=[-major:-major:min.x], yrange=[0:major:max.y]); major_ticks(xrange=[0:major:max.x], yrange=[0:major:max.y]); } %grid2D(min=[-20,-20], max=[20,20]);
K
Ken
Mon, Jul 25, 2022 3:21 AM

Thanks for the grid module Jordan- that is going to come in very useful
for me at least.

On 2022-07-25 05:07, Jordan Brown wrote:

However, there's nothing stopping you from drawing your own grid. Use
% so that it isn't included in your model.

Here's a semi-fancy implementation.  Rotate and reposition as
desired.  There's an argument that this should all be done in 2D, but
rotating 2D off of the XY plane bothers me.  Note that the minor ticks
are pretty small and can sometimes disappear on the display unless
zoomed in.  You might want to turn off displaying the axes.

 module grid2D(min=[-100,-100], max=[100,100], minor=1, major=10) {
      minor_len = 0.3;
      minor_thick = 0.05;
      major_len = 0.6;
      major_thick = 0.2;
      thick = 0.1;
      labelsize = 2;
      yoffset = 1;
      xoffset = 1;
      close = 0.1;

      module minor_tick() {
          cube([minor_len, minor_thick, thick], center=true);
          cube([minor_thick, minor_len, thick], center=true);
      }

      module major_tick() {
          cube([major_len, major_thick, thick], center=true);
          cube([major_thick, major_len, thick], center=true);
      }

      module minor_ticks(xrange, yrange) {
          for (x=xrange, y=yrange) {
              if (abs(x%major) > close || abs(y%major) > close) {
                  translate([x,y,0]) minor_tick();
              }
          }
      }

      module major_ticks(xrange, yrange) {
          for (x=xrange, y=yrange) {
              translate([x,y,0]) major_tick();
          }
      }

      module xlabel(x) {
          translate([x,yoffset,0])
              linear_extrude(height=thick, center=true)
              text(str(x), size=labelsize, halign="center");
      }

      module ylabel(y) {
          translate([xoffset,y,0])
              linear_extrude(height=thick, center=true)
              text(str(y), size=labelsize, valign="center");
      }

      for (x=[-major:-major:min.x]) xlabel(x);
      for (x=[major:major:max.x]) xlabel(x);
      for (y=[-major:-major:min.y]) ylabel(y);
      for (y=[major:major:max.y]) ylabel(y);

      minor_ticks(xrange=[-minor:-minor:min.x], yrange=[-minor:-minor:min.y]);
      minor_ticks(xrange=[0:minor:max.x], yrange=[-minor:-minor:min.y]);
      minor_ticks(xrange=[-minor:-minor:min.x], yrange=[0:minor:max.y]);
      minor_ticks(xrange=[0:minor:max.x], yrange=[0:minor:max.y]);

      major_ticks(xrange=[-major:-major:min.x], yrange=[-major:-major:min.y]);
      major_ticks(xrange=[0:major:max.x], yrange=[-major:-major:min.y]);
      major_ticks(xrange=[-major:-major:min.x], yrange=[0:major:max.y]);
      major_ticks(xrange=[0:major:max.x], yrange=[0:major:max.y]);
 }

 %grid2D(min=[-20,-20], max=[20,20]);

OpenSCAD mailing list
To unsubscribe send an email todiscuss-leave@lists.openscad.org

--
Cheers, Ken
bats059@gmail.com
https://vk7krj.com/running.html
https://sstv.vk7krj.com/all_bands.html

A baby is just an ego with a noise at one end and a smell at the other. Your job as a parent is to teach it to control all three.

Thanks for the grid module Jordan- that is going to come in very useful for me at least. On 2022-07-25 05:07, Jordan Brown wrote: > However, there's nothing stopping you from drawing your own grid. Use > % so that it isn't included in your model. > > Here's a semi-fancy implementation.  Rotate and reposition as > desired.  There's an argument that this should all be done in 2D, but > rotating 2D off of the XY plane bothers me.  Note that the minor ticks > are pretty small and can sometimes disappear on the display unless > zoomed in.  You might want to turn off displaying the axes. > > module grid2D(min=[-100,-100], max=[100,100], minor=1, major=10) { > minor_len = 0.3; > minor_thick = 0.05; > major_len = 0.6; > major_thick = 0.2; > thick = 0.1; > labelsize = 2; > yoffset = 1; > xoffset = 1; > close = 0.1; > > module minor_tick() { > cube([minor_len, minor_thick, thick], center=true); > cube([minor_thick, minor_len, thick], center=true); > } > > module major_tick() { > cube([major_len, major_thick, thick], center=true); > cube([major_thick, major_len, thick], center=true); > } > > module minor_ticks(xrange, yrange) { > for (x=xrange, y=yrange) { > if (abs(x%major) > close || abs(y%major) > close) { > translate([x,y,0]) minor_tick(); > } > } > } > > module major_ticks(xrange, yrange) { > for (x=xrange, y=yrange) { > translate([x,y,0]) major_tick(); > } > } > > module xlabel(x) { > translate([x,yoffset,0]) > linear_extrude(height=thick, center=true) > text(str(x), size=labelsize, halign="center"); > } > > module ylabel(y) { > translate([xoffset,y,0]) > linear_extrude(height=thick, center=true) > text(str(y), size=labelsize, valign="center"); > } > > for (x=[-major:-major:min.x]) xlabel(x); > for (x=[major:major:max.x]) xlabel(x); > for (y=[-major:-major:min.y]) ylabel(y); > for (y=[major:major:max.y]) ylabel(y); > > minor_ticks(xrange=[-minor:-minor:min.x], yrange=[-minor:-minor:min.y]); > minor_ticks(xrange=[0:minor:max.x], yrange=[-minor:-minor:min.y]); > minor_ticks(xrange=[-minor:-minor:min.x], yrange=[0:minor:max.y]); > minor_ticks(xrange=[0:minor:max.x], yrange=[0:minor:max.y]); > > major_ticks(xrange=[-major:-major:min.x], yrange=[-major:-major:min.y]); > major_ticks(xrange=[0:major:max.x], yrange=[-major:-major:min.y]); > major_ticks(xrange=[-major:-major:min.x], yrange=[0:major:max.y]); > major_ticks(xrange=[0:major:max.x], yrange=[0:major:max.y]); > } > > %grid2D(min=[-20,-20], max=[20,20]); > > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org -- Cheers, Ken bats059@gmail.com https://vk7krj.com/running.html https://sstv.vk7krj.com/all_bands.html ---------------------------------------- A baby is just an ego with a noise at one end and a smell at the other. Your job as a parent is to teach it to control all three.
TP
tony.pemberton.cowroast@gmail.com
Thu, Aug 11, 2022 9:03 AM

Jordan,

A bit of a belated reply, sorry! I’ve been a bit busy with coding and making stuff!

Firstly, I was aware that Openscad is dimensionless as I said in my original missive. BTW, How big is a smoot? I’m thinking in elephants poo, but perhaps bigger? :-)

Secondly, Thanks very much for your work above, which I will download and try out when I next get back to my case designs. I have a test file that I use for trying out oddments in my designs and the code should come in very handy.

Thanks again, Tony

Jordan, A bit of a belated reply, sorry! I’ve been a bit busy with coding and making stuff! Firstly, I was aware that Openscad is dimensionless as I said in my original missive. BTW, How big is a smoot? I’m thinking in elephants poo, but perhaps bigger? :-) Secondly, Thanks very much for your work above, which I will download and try out when I next get back to my case designs. I have a test file that I use for trying out oddments in my designs and the code should come in very handy. Thanks again, Tony
MM
Michael Möller
Thu, Aug 11, 2022 11:06 AM

"Openscad is dimensionless"

Not true, it has x, y and z dimensions.

:-)  M²

tor. 11. aug. 2022 11.04 skrev tony.pemberton.cowroast@gmail.com:

Jordan,

A bit of a belated reply, sorry! I’ve been a bit busy with coding and
making stuff!

Firstly, I was aware that Openscad is dimensionless as I said in my
original missive. BTW, How big is a smoot? I’m thinking in elephants poo,
but perhaps bigger? :-)

Secondly, Thanks very much for your work above, which I will download and
try out when I next get back to my case designs. I have a test file that I
use for trying out oddments in my designs and the code should come in very
handy.

Thanks again, Tony


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

"Openscad is dimensionless" Not true, it has x, y and z dimensions. :-) M² tor. 11. aug. 2022 11.04 skrev <tony.pemberton.cowroast@gmail.com>: > Jordan, > > A bit of a belated reply, sorry! I’ve been a bit busy with coding and > making stuff! > > Firstly, I was aware that Openscad is dimensionless as I said in my > original missive. BTW, How big is a smoot? I’m thinking in elephants poo, > but perhaps bigger? :-) > > Secondly, Thanks very much for your work above, which I will download and > try out when I next get back to my case designs. I have a test file that I > use for trying out oddments in my designs and the code should come in very > handy. > > Thanks again, Tony > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
TP
tony.pemberton.cowroast@gmail.com
Fri, Aug 12, 2022 9:46 AM

I have just tried your stuff and it is excellent. I will use that as a debug function when I next need to be sure I am not fooling myself about the size of inbuilt objects.

Many thanks.

I have just tried your stuff and it is excellent. I will use that as a debug function when I next need to be sure I am not fooling myself about the size of inbuilt objects. Many thanks.
TP
tony.pemberton.cowroast@gmail.com
Fri, Aug 12, 2022 9:53 AM

@M² - Surely x,y,z are axes not numbers? How many x’s to the foot? How many y’s to the pound? Enough of this Imperial stuff, how many z’s to the kilometre? All we need now is a variable for time on the page - but then it is all good fun n’est pas?

Tony

@M² - Surely x,y,z are axes not numbers? How many x’s to the foot? How many y’s to the pound? Enough of this Imperial stuff, how many z’s to the kilometre? All we need now is a variable for time on the page - but then it is all good fun n’est pas? Tony
M
mikeonenine@web.de
Fri, Aug 12, 2022 11:26 PM

All we need now is a variable for time on the page

Tony

Something like . . . animation?

tony.pemberton.cowroast@gmail.com wrote: > All we need now is a variable for time on the page > > Tony Something like . . . animation?
MM
Michael Möller
Sat, Aug 13, 2022 12:43 PM

All is fun indeed. "Dimension" is - like so many words - used for two
different meanings: Number of coordinates, as in 2D or 3D (or 10D for that
strange string theory) and in"A length" as in the dimension of the box is
10x3x20 cm/inch/kilometers

Sorry if explaing a joke spoils it, or is it a joke if it needs explaing?

Michael, fra mobilen

On Fri, 12 Aug 2022 at 11:54, tony.pemberton.cowroast@gmail.com wrote:

@M² - Surely x,y,z are axes not numbers? How many x’s to the foot? How
many y’s to the pound? Enough of this Imperial stuff, how many z’s to the
kilometre? All we need now is a variable for time on the page - but then it
is all good fun n’est pas?

Tony


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

All is fun indeed. "Dimension" is - like so many words - used for two different meanings: Number of coordinates, as in 2D or 3D (or 10D for that strange string theory) and in"A length" as in the dimension of the box is 10x3x20 cm/inch/kilometers Sorry if explaing a joke spoils it, or is it a joke if it needs explaing? Michael, fra mobilen On Fri, 12 Aug 2022 at 11:54, <tony.pemberton.cowroast@gmail.com> wrote: > @M² - Surely x,y,z are axes not numbers? How many x’s to the foot? How > many y’s to the pound? Enough of this Imperial stuff, how many z’s to the > kilometre? All we need now is a variable for time on the page - but then it > is all good fun n’est pas? > > Tony > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >