discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Measure distances of a parametric design - and create a report

Y
YigalB
Wed, Oct 21, 2020 6:05 AM

Is it possible to get an output report of distances between pre-set defined
points (e.g. between A1-A2, B1-B2 etc.) of a parametric design?

So if I run it with X=10, Y=25, A specific report will be generated, and if
I run with X=22, Y=17 - a different report will be generated.

A text file report is fine, a 2D drawing with the distances on it (like in a
spec) would be great.

--
Sent from: http://forum.openscad.org/

Is it possible to get an output report of distances between pre-set defined points (e.g. between A1-A2, B1-B2 etc.) of a parametric design? So if I run it with X=10, Y=25, A specific report will be generated, and if I run with X=22, Y=17 - a different report will be generated. A text file report is fine, a 2D drawing with the distances on it (like in a spec) would be great. -- Sent from: http://forum.openscad.org/
NH
nop head
Wed, Oct 21, 2020 6:19 AM

You can create a text report with echo() and str() and output it to a .echo
file but you need a bit of post processing to make it look pretty. I.e.
remove ECHO: and the quotes.

You can also generate dimension lines yourself by making a line of length
A1-B2 with text of A1-B1 on it placed at A1 going to B1. You can then
generate a png with those on.

On Wed, 21 Oct 2020 at 07:05, YigalB yigalb@hotmail.com wrote:

Is it possible to get an output report of distances between pre-set defined
points (e.g. between A1-A2, B1-B2 etc.) of a parametric design?

So if I run it with X=10, Y=25, A specific report will be generated, and if
I run with X=22, Y=17 - a different report will be generated.

A text file report is fine, a 2D drawing with the distances on it (like in
a
spec) would be great.

--
Sent from: http://forum.openscad.org/


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

You can create a text report with echo() and str() and output it to a .echo file but you need a bit of post processing to make it look pretty. I.e. remove ECHO: and the quotes. You can also generate dimension lines yourself by making a line of length A1-B2 with text of A1-B1 on it placed at A1 going to B1. You can then generate a png with those on. On Wed, 21 Oct 2020 at 07:05, YigalB <yigalb@hotmail.com> wrote: > Is it possible to get an output report of distances between pre-set defined > points (e.g. between A1-A2, B1-B2 etc.) of a parametric design? > > So if I run it with X=10, Y=25, A specific report will be generated, and if > I run with X=22, Y=17 - a different report will be generated. > > A text file report is fine, a 2D drawing with the distances on it (like in > a > spec) would be great. > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
J
jjvbhh
Wed, Oct 21, 2020 7:00 AM

I am working on a 3D-Measure tool, which renders only in in preview, but not
in final render.
Give me one more week or so, you'll be surprised ;-)

--
Sent from: http://forum.openscad.org/

I am working on a 3D-Measure tool, which renders only in in preview, but not in final render. Give me one more week or so, you'll be surprised ;-) -- Sent from: http://forum.openscad.org/
WF
William F. Adams
Wed, Oct 21, 2020 1:16 PM

This is one of the things I was touching on in:
http://www.tug.org/TUGboat/tb40-2/tb125adams-3d.pdf
Basically, given the limitations in OpenSCAD (can't cleanly write out text files, can't generate arbitrary vectors, esp. unclosed paths and curves as curves) the most expedient thing to do seems to be to program in parallel and use a second tool such as METAPOST to address the lacunae.
William

This is one of the things I was touching on in: http://www.tug.org/TUGboat/tb40-2/tb125adams-3d.pdf Basically, given the limitations in OpenSCAD (can't cleanly write out text files, can't generate arbitrary vectors, esp. unclosed paths and curves as curves) the most expedient thing to do seems to be to program in parallel and use a second tool such as METAPOST to address the lacunae. William
YB
Yigal B
Thu, Oct 22, 2020 5:40 AM

I am not sure I follow:

Can I place a virtual line (i.e. it will not be 3D printed), tie the ends of the lines to pre-defined points (such as the cnetr of circle 1 to the center of circle 2  , bith circles are parametric ), and generate the length into echo?

If yes, then it will serve my needs.

<nop head wrote:>

You can create a text report with echo() and str() and output it to a .echo file but you need a bit of post processing to make it look pretty. I.e. remove ECHO: and the quotes.

You can also generate dimension lines yourself by making a line of length A1-B2 with text of A1-B1 on it placed at A1 going to B1. You can then generate a png with those on.

On Wed, 21 Oct 2020 at 07:05, YigalB <yigalb@hotmail.commailto:yigalb@hotmail.com> wrote:
Is it possible to get an output report of distances between pre-set defined
points (e.g. between A1-A2, B1-B2 etc.) of a parametric design?

So if I run it with X=10, Y=25, A specific report will be generated, and if
I run with X=22, Y=17 - a different report will be generated.

A text file report is fine, a 2D drawing with the distances on it (like in a
spec) would be great.

--
Sent from: http://forum.openscad.org/


OpenSCAD mailing list
Discuss@lists.openscad.orgmailto:Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

I am not sure I follow: Can I place a virtual line (i.e. it will not be 3D printed), tie the ends of the lines to pre-defined points (such as the cnetr of circle 1 to the center of circle 2 , bith circles are parametric ), and generate the length into echo? If yes, then it will serve my needs. <nop head wrote:> You can create a text report with echo() and str() and output it to a .echo file but you need a bit of post processing to make it look pretty. I.e. remove ECHO: and the quotes. You can also generate dimension lines yourself by making a line of length A1-B2 with text of A1-B1 on it placed at A1 going to B1. You can then generate a png with those on. On Wed, 21 Oct 2020 at 07:05, YigalB <yigalb@hotmail.com<mailto:yigalb@hotmail.com>> wrote: Is it possible to get an output report of distances between pre-set defined points (e.g. between A1-A2, B1-B2 etc.) of a parametric design? So if I run it with X=10, Y=25, A specific report will be generated, and if I run with X=22, Y=17 - a different report will be generated. A text file report is fine, a 2D drawing with the distances on it (like in a spec) would be great. -- Sent from: http://forum.openscad.org/ _______________________________________________ OpenSCAD mailing list Discuss@lists.openscad.org<mailto:Discuss@lists.openscad.org> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
NH
nop head
Thu, Oct 22, 2020 6:57 AM

If you place two circles then you must have specified the centres of the
circles so you can write an expression for that.

E.g.

c1 = [ some complex expression ];
c2 = [ some complex expression ];

translate(c1) circle();
translate(c2) circle();

echo(c2 - c1);

You can draw a line between centres by translating tiny circles there and
taking the hull. You can use $preview to only show it in the preview and
not appear in the render for STLs.

On Thu, 22 Oct 2020 at 06:41, Yigal B yigalb@hotmail.com wrote:

I am not sure I follow:

Can I place a virtual line (i.e. it will not be 3D printed), tie the ends
of the lines to pre-defined points (such as the cnetr of circle 1 to the
center of circle 2  , bith circles are parametric ), and generate the
length into echo?

If yes, then it will serve my needs.

<nop head wrote:>

You can create a text report with echo() and str() and output it to a
.echo file but you need a bit of post processing to make it look pretty.
I.e. remove ECHO: and the quotes.

You can also generate dimension lines yourself by making a line of length
A1-B2 with text of A1-B1 on it placed at A1 going to B1. You can then
generate a png with those on.

On Wed, 21 Oct 2020 at 07:05, YigalB yigalb@hotmail.com wrote:

Is it possible to get an output report of distances between pre-set defined
points (e.g. between A1-A2, B1-B2 etc.) of a parametric design?

So if I run it with X=10, Y=25, A specific report will be generated, and if
I run with X=22, Y=17 - a different report will be generated.

A text file report is fine, a 2D drawing with the distances on it (like in
a
spec) would be great.

--
Sent from: http://forum.openscad.org/


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

If you place two circles then you must have specified the centres of the circles so you can write an expression for that. E.g. c1 = [ some complex expression ]; c2 = [ some complex expression ]; translate(c1) circle(); translate(c2) circle(); echo(c2 - c1); You can draw a line between centres by translating tiny circles there and taking the hull. You can use $preview to only show it in the preview and not appear in the render for STLs. On Thu, 22 Oct 2020 at 06:41, Yigal B <yigalb@hotmail.com> wrote: > I am not sure I follow: > > Can I place a virtual line (i.e. it will not be 3D printed), tie the ends > of the lines to pre-defined points (such as the cnetr of circle 1 to the > center of circle 2 , bith circles are parametric ), and generate the > length into echo? > > If yes, then it will serve my needs. > > > <nop head wrote:> > > You can create a text report with echo() and str() and output it to a > .echo file but you need a bit of post processing to make it look pretty. > I.e. remove ECHO: and the quotes. > > You can also generate dimension lines yourself by making a line of length > A1-B2 with text of A1-B1 on it placed at A1 going to B1. You can then > generate a png with those on. > > On Wed, 21 Oct 2020 at 07:05, YigalB <yigalb@hotmail.com> wrote: > > Is it possible to get an output report of distances between pre-set defined > points (e.g. between A1-A2, B1-B2 etc.) of a parametric design? > > So if I run it with X=10, Y=25, A specific report will be generated, and if > I run with X=22, Y=17 - a different report will be generated. > > A text file report is fine, a 2D drawing with the distances on it (like in > a > spec) would be great. > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
JB
Jordan Brown
Thu, Oct 22, 2020 4:29 PM

On 10/21/2020 11:57 PM, nop head wrote:

If you place two circles then you must have specified the centres of
the circles so you can write an expression for that.

E.g.

c1 = [ some complex expression ];
c2 = [ some complex expression ];  

translate(c1) circle();
translate(c2) circle();

echo(c2 - c1);

You can draw a line between centres by translating tiny circles there
and taking the hull. You can use $preview to only show it in the
preview and not appear in the render for STLs.

But, to be clear, you have to know where the points are.  OpenSCAD
won't tell you.

For instance:

translate([10,0,0]) sphere(1);
rotate(27) translate([10,0,0]) sphere(1);

You'd have to do your own trigonometry to find the centerpoint of the
second sphere.

More complicated:

module barsphere() {
    translate([0,-.5,-.5]) cube([10,1,1]);
    translate([10,0,0]) sphere(2);
}

barsphere();
rotate(40) barsphere();

You would not only have to do your own trigonometry, but you'd also have
to "know" what barsphere() does; you'd have to "know" that it puts the
sphere at [10,0,0].

On 10/21/2020 11:57 PM, nop head wrote: > If you place two circles then you must have specified the centres of > the circles so you can write an expression for that. > > E.g. > > c1 = [ some complex expression ]; > c2 = [ some complex expression ];   > > translate(c1) circle(); > translate(c2) circle(); > > echo(c2 - c1); > > You can draw a line between centres by translating tiny circles there > and taking the hull. You can use $preview to only show it in the > preview and not appear in the render for STLs. But, to be clear, *you* have to know where the points are.  OpenSCAD won't tell you. For instance: translate([10,0,0]) sphere(1); rotate(27) translate([10,0,0]) sphere(1); You'd have to do your own trigonometry to find the centerpoint of the second sphere. More complicated: module barsphere() { translate([0,-.5,-.5]) cube([10,1,1]); translate([10,0,0]) sphere(2); } barsphere(); rotate(40) barsphere(); You would not only have to do your own trigonometry, but you'd also have to "know" what barsphere() does; you'd have to "know" that it puts the sphere at [10,0,0].
J
jjvbhh
Thu, Oct 22, 2020 4:45 PM

nophead wrote

If you place two circles then you must have specified the centres of the
circles so you can write an expression for that.

E.g.

c1 = [ some complex expression ];
c2 = [ some complex expression ];

translate(c1) circle();
translate(c2) circle();

echo(c2 - c1);

What you want, is norm(c2-c1)

// two random positions
p1=rands(-50,50,3);
p2=rands(-50,50,3);
// spheres at each point
translate(p1)sphere(r=1,$fn=10);
translate(p2)sphere(r=1,$fn=10);
// calculate distance
distance=norm(p2-p1);
echo(p1=p1,p2=p2,distance=distance);

--
Sent from: http://forum.openscad.org/

nophead wrote > If you place two circles then you must have specified the centres of the > circles so you can write an expression for that. > > E.g. > > c1 = [ some complex expression ]; > c2 = [ some complex expression ]; > > translate(c1) circle(); > translate(c2) circle(); > > echo(c2 - c1); What you want, is norm(c2-c1) // two random positions p1=rands(-50,50,3); p2=rands(-50,50,3); // spheres at each point translate(p1)sphere(r=1,$fn=10); translate(p2)sphere(r=1,$fn=10); // calculate distance distance=norm(p2-p1); echo(p1=p1,p2=p2,distance=distance); -- Sent from: http://forum.openscad.org/
NH
nop head
Thu, Oct 22, 2020 5:41 PM

You would not only have to do your own trigonometry, but you'd also have

to "know" what barsphere() does; you'd have to "know" that it puts the
sphere at [10,0,0].

Yes you have to tell OpenSCAD where things are. It doesn't tell you
anything in return. And yes you frequently need to do trig to place things.

If you want to find where things are after transformations you can write
the transformations as functions on matrices and call multmatrix to do the
positioning and use the same matrix to transform a point like the origin.

There is an example here in my library.
https://github.com/nophead/NopSCADlib/blob/master/printed/corner_block.scad#L51

On Thu, 22 Oct 2020 at 17:45, jjvbhh jjvb-openscad@bassklampfe.de wrote:

nophead wrote

If you place two circles then you must have specified the centres of the
circles so you can write an expression for that.

E.g.

c1 = [ some complex expression ];
c2 = [ some complex expression ];

translate(c1) circle();
translate(c2) circle();

echo(c2 - c1);

What you want, is norm(c2-c1)

// two random positions
p1=rands(-50,50,3);
p2=rands(-50,50,3);
// spheres at each point
translate(p1)sphere(r=1,$fn=10);
translate(p2)sphere(r=1,$fn=10);
// calculate distance
distance=norm(p2-p1);
echo(p1=p1,p2=p2,distance=distance);

--
Sent from: http://forum.openscad.org/


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

> You would not only have to do your own trigonometry, but you'd also have to "know" what barsphere() does; you'd have to "know" that it puts the sphere at [10,0,0]. Yes you have to tell OpenSCAD where things are. It doesn't tell you anything in return. And yes you frequently need to do trig to place things. If you want to find where things are after transformations you can write the transformations as functions on matrices and call multmatrix to do the positioning and use the same matrix to transform a point like the origin. There is an example here in my library. https://github.com/nophead/NopSCADlib/blob/master/printed/corner_block.scad#L51 On Thu, 22 Oct 2020 at 17:45, jjvbhh <jjvb-openscad@bassklampfe.de> wrote: > nophead wrote > > If you place two circles then you must have specified the centres of the > > circles so you can write an expression for that. > > > > E.g. > > > > c1 = [ some complex expression ]; > > c2 = [ some complex expression ]; > > > > translate(c1) circle(); > > translate(c2) circle(); > > > > echo(c2 - c1); > > What you want, is norm(c2-c1) > > // two random positions > p1=rands(-50,50,3); > p2=rands(-50,50,3); > // spheres at each point > translate(p1)sphere(r=1,$fn=10); > translate(p2)sphere(r=1,$fn=10); > // calculate distance > distance=norm(p2-p1); > echo(p1=p1,p2=p2,distance=distance); > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >