discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

defining the points of the arc.. it doesn't work now..

RW
Raymond West
Tue, Jul 9, 2024 9:59 AM

you are not working with the centre of the svg, afaik

On 09/07/2024 10:08, Gábor Magyar via Discuss wrote:

Gábor Magyar gmagyar6@gmail.com ezt írta (időpont: 2024. júl. 9., K, 10:25):

<<code>>
svg="szimbolum_teli.svg";
svg_=[4.6, 8.67];
//svg__=[svg_[0]/2, svg_[1]/2 ];

$fn=60;

%translate([0,0,-1])
circle(d_+r_);

with_sym();

module with_sym(){
for(i = [-3:0])
rotate(i * 360 /12)
translate([svg_[0]-svg_[0], d_-svg_[1]*2])
rotate(-i *5 / 12)
//scale([1.5, 1.5, 1])
import(svg);

rotate(180)
for(i = [-3:0])
rotate(i * 360 /12)
translate([r_-r_, d_-h_*2])
rotate(-i *360 / 12)
cylinder(h=h_, r=r_);
}
<<code>>

The cylinders remain in exact position even if the diameter (size) changes.

However, the symbol created from svg does not move, not even in the
case of "any" translate.

translate([svg_[0]-svg_[0], d_-svg_[1]*2])

Where svg_variable stores the xy size of the svg image.

It works fine for a cylinder.

translate([r_-r_, d_-h_*2])

The cylinder is placed exactly on the x and y axes.

In the end, it's not a big problem, because there will be a symbol everywhere,
so it won't stand out because of the circle,
but as a problem to be solved, I'm interested in why the svg can't be
positioned exactly.

Jordan Brown openscad@jordan.maileater.net ezt írta (időpont: 2024.
júl. 8., H, 20:00):

On 7/8/2024 5:11 AM, Gábor Magyar via Discuss wrote:

However, I don't understand why the r_-r_ alignment works in the case
of a cylinder,
and why not in the case of symbol?

svg_[0]-svg_[0]

The svg_ variable has the xy size of the symbol.

More context please.  Perhaps an example snippet that demonstrates your question?


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

you are not working with the centre of the svg, afaik On 09/07/2024 10:08, Gábor Magyar via Discuss wrote: > Gábor Magyar <gmagyar6@gmail.com> ezt írta (időpont: 2024. júl. 9., K, 10:25): >> <<code>> >> svg="szimbolum_teli.svg"; >> svg_=[4.6, 8.67]; >> //svg__=[svg_[0]/2, svg_[1]/2 ]; >> >> $fn=60; >> >> %translate([0,0,-1]) >> circle(d_+r_); >> >> >> with_sym(); >> >> module with_sym(){ >> for(i = [-3:0]) >> rotate(i * 360 /12) >> translate([svg_[0]-svg_[0], d_-svg_[1]*2]) >> rotate(-i *5 / 12) >> //scale([1.5, 1.5, 1]) >> import(svg); >> >> >> rotate(180) >> for(i = [-3:0]) >> rotate(i * 360 /12) >> translate([r_-r_, d_-h_*2]) >> rotate(-i *360 / 12) >> cylinder(h=h_, r=r_); >> } >> <<code>> >> >> The cylinders remain in exact position even if the diameter (size) changes. >> >> However, the symbol created from svg does not move, not even in the >> case of "any" translate. >> >> translate([svg_[0]-svg_[0], d_-svg_[1]*2]) >> >> Where svg_variable stores the xy size of the svg image. >> >> It works fine for a cylinder. >> >> translate([r_-r_, d_-h_*2]) >> >> The cylinder is placed exactly on the x and y axes. >> >> In the end, it's not a big problem, because there will be a symbol everywhere, >> so it won't stand out because of the circle, >> but as a problem to be solved, I'm interested in why the svg can't be >> positioned exactly. >> >> Jordan Brown <openscad@jordan.maileater.net> ezt írta (időpont: 2024. >> júl. 8., H, 20:00): >>> On 7/8/2024 5:11 AM, Gábor Magyar via Discuss wrote: >>> >>> However, I don't understand why the r_-r_ alignment works in the case >>> of a cylinder, >>> and why not in the case of symbol? >>> >>> svg_[0]-svg_[0] >>> >>> The svg_ variable has the xy size of the symbol. >>> >>> >>> More context please. Perhaps an example snippet that demonstrates your question? >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org
L
larry
Tue, Jul 9, 2024 7:57 PM

On Tue, 2024-07-09 at 11:08 +0200, Gábor Magyar via Discuss wrote:

Your attachment shows a figure that has been rotated and placed around
what appears to be an equal radius from the origin.

Is that figure the SVG you are speaking of? If so, what is the problem
with it?

Could you attach a copy of the SVG you are working with?

Gábor Magyar gmagyar6@gmail.com ezt írta (időpont: 2024. júl. 9.,
K, 10:25):

<<code>>
svg="szimbolum_teli.svg";
svg_=[4.6, 8.67];
//svg__=[svg_[0]/2, svg_[1]/2 ];

$fn=60;

%translate([0,0,-1])
  circle(d_+r_);

with_sym();

module with_sym(){
  for(i = [-3:0])
    rotate(i * 360 /12)
      translate([svg_[0]-svg_[0], d_-svg_[1]*2])
        rotate(-i *5 / 12)
          //scale([1.5, 1.5, 1])
          import(svg);

  rotate(180)
  for(i = [-3:0])
    rotate(i * 360 /12)
      translate([r_-r_, d_-h_*2])
        rotate(-i *360 / 12)
          cylinder(h=h_, r=r_);
}
<<code>>

The cylinders remain in exact position even if the diameter (size)
changes.

However, the symbol created from svg does not move, not even in the
case of "any" translate.

translate([svg_[0]-svg_[0], d_-svg_[1]*2])

Where svg_variable stores the xy size of the svg image.

It works fine for a cylinder.

translate([r_-r_, d_-h_*2])

The cylinder is placed exactly on the x and y axes.

In the end, it's not a big problem, because there will be a symbol
everywhere,
so it won't stand out because of the circle,
but as a problem to be solved, I'm interested in why the svg can't
be
positioned exactly.

Jordan Brown openscad@jordan.maileater.net ezt írta (időpont:
2024.
júl. 8., H, 20:00):

On 7/8/2024 5:11 AM, Gábor Magyar via Discuss wrote:

However, I don't understand why the r_-r_ alignment works in the
case
of a cylinder,
and why not in the case of symbol?

svg_[0]-svg_[0]

The svg_ variable has the xy size of the symbol.

More context please.  Perhaps an example snippet that
demonstrates your question?


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

On Tue, 2024-07-09 at 11:08 +0200, Gábor Magyar via Discuss wrote: Your attachment shows a figure that has been rotated and placed around what appears to be an equal radius from the origin. Is that figure the SVG you are speaking of? If so, what is the problem with it? Could you attach a copy of the SVG you are working with? > Gábor Magyar <gmagyar6@gmail.com> ezt írta (időpont: 2024. júl. 9., > K, 10:25): > > > > <<code>> > > svg="szimbolum_teli.svg"; > > svg_=[4.6, 8.67]; > > //svg__=[svg_[0]/2, svg_[1]/2 ]; > > > > $fn=60; > > > > %translate([0,0,-1]) > >   circle(d_+r_); > > > > > > with_sym(); > > > > module with_sym(){ > >   for(i = [-3:0]) > >     rotate(i * 360 /12) > >       translate([svg_[0]-svg_[0], d_-svg_[1]*2]) > >         rotate(-i *5 / 12) > >           //scale([1.5, 1.5, 1]) > >           import(svg); > > > > > >   rotate(180) > >   for(i = [-3:0]) > >     rotate(i * 360 /12) > >       translate([r_-r_, d_-h_*2]) > >         rotate(-i *360 / 12) > >           cylinder(h=h_, r=r_); > > } > > <<code>> > > > > The cylinders remain in exact position even if the diameter (size) > > changes. > > > > However, the symbol created from svg does not move, not even in the > > case of "any" translate. > > > > translate([svg_[0]-svg_[0], d_-svg_[1]*2]) > > > > Where svg_variable stores the xy size of the svg image. > > > > It works fine for a cylinder. > > > > translate([r_-r_, d_-h_*2]) > > > > The cylinder is placed exactly on the x and y axes. > > > > In the end, it's not a big problem, because there will be a symbol > > everywhere, > > so it won't stand out because of the circle, > > but as a problem to be solved, I'm interested in why the svg can't > > be > > positioned exactly. > > > > Jordan Brown <openscad@jordan.maileater.net> ezt írta (időpont: > > 2024. > > júl. 8., H, 20:00): > > > > > > On 7/8/2024 5:11 AM, Gábor Magyar via Discuss wrote: > > > > > > However, I don't understand why the r_-r_ alignment works in the > > > case > > > of a cylinder, > > > and why not in the case of symbol? > > > > > > svg_[0]-svg_[0] > > > > > > The svg_ variable has the xy size of the symbol. > > > > > > > > > More context please.  Perhaps an example snippet that > > > demonstrates your question? > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
L
larry
Tue, Jul 9, 2024 8:41 PM

On Tue, 2024-07-09 at 11:08 +0200, Gábor Magyar via Discuss wrote:

Assuming you want to rotate the svg to keep its orientation the same in
all positions, here's a small modification of code you have been
previously given:

<<code>>

include <BOSL2/std.scad>
$fn=60;

cylinder(d=400,h=1);
color("red")
zrot_copies(n=12,sa=90,d=300,subrot=false)
svg();

module svg() {
translate([ -70.426 , -236 , 0 ])
linear_extrude(2) import("/home/larry/Desktop/symbol.svg");
}

<<code>>

Gábor Magyar gmagyar6@gmail.com ezt írta (időpont: 2024. júl. 9.,
K, 10:25):

<<code>>
svg="szimbolum_teli.svg";
svg_=[4.6, 8.67];
//svg__=[svg_[0]/2, svg_[1]/2 ];

$fn=60;

%translate([0,0,-1])
  circle(d_+r_);

with_sym();

module with_sym(){
  for(i = [-3:0])
    rotate(i * 360 /12)
      translate([svg_[0]-svg_[0], d_-svg_[1]*2])
        rotate(-i *5 / 12)
          //scale([1.5, 1.5, 1])
          import(svg);

  rotate(180)
  for(i = [-3:0])
    rotate(i * 360 /12)
      translate([r_-r_, d_-h_*2])
        rotate(-i *360 / 12)
          cylinder(h=h_, r=r_);
}
<<code>>

The cylinders remain in exact position even if the diameter (size)
changes.

However, the symbol created from svg does not move, not even in the
case of "any" translate.

translate([svg_[0]-svg_[0], d_-svg_[1]*2])

Where svg_variable stores the xy size of the svg image.

It works fine for a cylinder.

translate([r_-r_, d_-h_*2])

The cylinder is placed exactly on the x and y axes.

In the end, it's not a big problem, because there will be a symbol
everywhere,
so it won't stand out because of the circle,
but as a problem to be solved, I'm interested in why the svg can't
be
positioned exactly.

Jordan Brown openscad@jordan.maileater.net ezt írta (időpont:
2024.
júl. 8., H, 20:00):

On 7/8/2024 5:11 AM, Gábor Magyar via Discuss wrote:

However, I don't understand why the r_-r_ alignment works in the
case
of a cylinder,
and why not in the case of symbol?

svg_[0]-svg_[0]

The svg_ variable has the xy size of the symbol.

More context please.  Perhaps an example snippet that
demonstrates your question?


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

On Tue, 2024-07-09 at 11:08 +0200, Gábor Magyar via Discuss wrote: Assuming you want to rotate the svg to keep its orientation the same in all positions, here's a small modification of code you have been previously given: <<code>> include <BOSL2/std.scad> $fn=60; cylinder(d=400,h=1); color("red") zrot_copies(n=12,sa=90,d=300,subrot=false) svg(); module svg() { translate([ -70.426 , -236 , 0 ]) linear_extrude(2) import("/home/larry/Desktop/symbol.svg"); } <<code>> > Gábor Magyar <gmagyar6@gmail.com> ezt írta (időpont: 2024. júl. 9., > K, 10:25): > > > > <<code>> > > svg="szimbolum_teli.svg"; > > svg_=[4.6, 8.67]; > > //svg__=[svg_[0]/2, svg_[1]/2 ]; > > > > $fn=60; > > > > %translate([0,0,-1]) > >   circle(d_+r_); > > > > > > with_sym(); > > > > module with_sym(){ > >   for(i = [-3:0]) > >     rotate(i * 360 /12) > >       translate([svg_[0]-svg_[0], d_-svg_[1]*2]) > >         rotate(-i *5 / 12) > >           //scale([1.5, 1.5, 1]) > >           import(svg); > > > > > >   rotate(180) > >   for(i = [-3:0]) > >     rotate(i * 360 /12) > >       translate([r_-r_, d_-h_*2]) > >         rotate(-i *360 / 12) > >           cylinder(h=h_, r=r_); > > } > > <<code>> > > > > The cylinders remain in exact position even if the diameter (size) > > changes. > > > > However, the symbol created from svg does not move, not even in the > > case of "any" translate. > > > > translate([svg_[0]-svg_[0], d_-svg_[1]*2]) > > > > Where svg_variable stores the xy size of the svg image. > > > > It works fine for a cylinder. > > > > translate([r_-r_, d_-h_*2]) > > > > The cylinder is placed exactly on the x and y axes. > > > > In the end, it's not a big problem, because there will be a symbol > > everywhere, > > so it won't stand out because of the circle, > > but as a problem to be solved, I'm interested in why the svg can't > > be > > positioned exactly. > > > > Jordan Brown <openscad@jordan.maileater.net> ezt írta (időpont: > > 2024. > > júl. 8., H, 20:00): > > > > > > On 7/8/2024 5:11 AM, Gábor Magyar via Discuss wrote: > > > > > > However, I don't understand why the r_-r_ alignment works in the > > > case > > > of a cylinder, > > > and why not in the case of symbol? > > > > > > svg_[0]-svg_[0] > > > > > > The svg_ variable has the xy size of the symbol. > > > > > > > > > More context please.  Perhaps an example snippet that > > > demonstrates your question? > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
JB
Jordan Brown
Tue, Jul 9, 2024 11:25 PM

When supplying an example, please make sure that it is self-contained. 
This one needs the SVG file to work, and does not include definitions
for r_, d_, and h_.

Those missing parts limit how much I can analyze the program.

Are you getting error messages in the console pane or in the error log
pane?  After I supply a dummy module replacing the missing SVG file, I
get 47 errors.

I do see a couple of things.

   translate([svg_[0]-svg_[0], d_-svg_[1]*2])
   translate([r_-r_, d_-h_*2])

x-x is equal to zero, so these are translating by zero in X.

        rotate(-i *360 / 12)
          cylinder(h=h_, r=r_);

A cylinder is a circle in the XY plane, extended vertically in Z. 
You've asked it to rotate around the Z axis... which (mostly) won't do
anything to a circle or cylinder.  (For a low-resolution
circle/cylinder, it will re-orient the edges/faces.  But you don't seem
to be trying to do that.)

for(i = [-3:0])
rotate(i * 360 /12)
translate([svg_[0]-svg_[0], d_-svg_[1]*2])
rotate(-i *5 / 12)
import(svg);

You're placing four copies of the SVG.  The first is rotated -3 times 5
= 15, divided by 12 = +1.25 degrees, or nearly nothing, then translated
a ways out in +Y, then rotated -3 times 360 = 1080, divided by 12 = -90
degrees, for a net of rotating by -88.75 degrees.  The second is rotated
0.833 degrees, translated, and then rotated -60, for a net of -59.167
degrees.  The third is rotated +0.417, then -30, net -29.58.  The fourth
is rotated zero, translated,  and then rotated zero.

If you're trying to position a symbol at points around the circle,
maintaining its rotation, you want the two rotates to be for the same
value, but negated.  You probably want

for(i = [-3:0])
rotate(i * 360 /12)
translate(...)
rotate(-i * 360 /12)
import(svg);

And although it's mathematically equivalent, I think it's more
understandable to describe that rotation using the division first, so
that you calculate a fraction around the circle, and then multiply by
360 to get the number of degrees, so:

rotate(i / 12 * 360)

Going back to the translate for a moment, I think you mean

translate([-svg_[0]/2, d_ - svg_[1]/2])

so as to center the SVG and position it out to "d_".  HOWEVER, I think
that's still not right, because it's happening after the first rotate,
and you probably want to center it before the first rotate so that
you're rotating around the center of the SVG, so you want to split the
centering part away from the "move out d_" part.

Net, I think you probably want:

  for(i = [-3:0])
    rotate(i /12 * 360)
      translate([0, d_])
        rotate(-i /12 * 360)
          translate([-svg_[0]/2, -svg_[1]/2])
            import(svg);

But... SVG positioning is strange for a number of reasons, so that might
not be quite right.  Still, you probably want the translate innermost,
to get the object centered before you start messing with it.  Put an
exclamation point before the translate() so that OpenSCAD displays just
that one object, and play with the translate values until it's centered.

When supplying an example, please make sure that it is self-contained.  This one needs the SVG file to work, and does not include definitions for r_, d_, and h_. Those missing parts limit how much I can analyze the program. Are you getting error messages in the console pane or in the error log pane?  After I supply a dummy module replacing the missing SVG file, I get 47 errors. I do see a couple of things. > translate([svg_[0]-svg_[0], d_-svg_[1]*2]) > translate([r_-r_, d_-h_*2]) x-x is equal to zero, so these are translating by zero in X. >         rotate(-i *360 / 12) >           cylinder(h=h_, r=r_); A cylinder is a circle in the XY plane, extended vertically in Z.  You've asked it to rotate around the Z axis... which (mostly) won't do anything to a circle or cylinder.  (For a low-resolution circle/cylinder, it will re-orient the edges/faces.  But you don't seem to be trying to do that.) > for(i = [-3:0]) > rotate(i * 360 /12) > translate([svg_[0]-svg_[0], d_-svg_[1]*2]) > rotate(-i *5 / 12) > import(svg); You're placing four copies of the SVG.  The first is rotated -3 times 5 = 15, divided by 12 = +1.25 degrees, or nearly nothing, then translated a ways out in +Y, then rotated -3 times 360 = 1080, divided by 12 = -90 degrees, for a net of rotating by -88.75 degrees.  The second is rotated 0.833 degrees, translated, and then rotated -60, for a net of -59.167 degrees.  The third is rotated +0.417, then -30, net -29.58.  The fourth is rotated zero, translated,  and then rotated zero. If you're trying to position a symbol at points around the circle, maintaining its rotation, you want the two rotates to be for the same value, but negated.  You probably want for(i = [-3:0]) rotate(i * 360 /12) translate(...) rotate(-i * 360 /12) import(svg); And although it's mathematically equivalent, I think it's more understandable to describe that rotation using the division first, so that you calculate a fraction around the circle, and then multiply by 360 to get the number of degrees, so: rotate(i / 12 * 360) Going back to the translate for a moment, I think you mean translate([-svg_[0]/2, d_ - svg_[1]/2]) so as to center the SVG and position it out to "d_".  HOWEVER, I think that's still not right, because it's happening after the first rotate, and you probably want to center it *before* the first rotate so that you're rotating around the center of the SVG, so you want to split the centering part away from the "move out d_" part. Net, I think you probably want: for(i = [-3:0]) rotate(i /12 * 360) translate([0, d_]) rotate(-i /12 * 360) translate([-svg_[0]/2, -svg_[1]/2]) import(svg); But... SVG positioning is strange for a number of reasons, so that might not be quite right.  Still, you probably want the translate innermost, to get the object centered before you start messing with it.  Put an exclamation point before the translate() so that OpenSCAD displays just that one object, and play with the translate values until it's centered.
L
larry
Wed, Jul 10, 2024 1:18 AM

On Tue, 2024-07-09 at 23:25 +0000, Jordan Brown via Discuss wrote:

 When supplying an example, please make sure that it is self-
contained.  This one needs the SVG file to work, and does not include
definitions for r_, d_, and h_.

I suppose I too should have provided the svg example in my response,
but it's just an svg I whipped up in Inkscape. Its only reason for
being sit that it's easy to see the rotations.

But... SVG positioning is strange for a number of reasons, so that
might not be quite right.  Still, you probably want the translate
innermost, to get the object centered before you start messing with
it.  Put an exclamation point before the translate() so that OpenSCAD
displays just that one object, and play with the translate values
until it's centered.

If I were doing it, I'd impport the svg, render it, and export it as an
stl. I would then use stlplace, available on github.

https://github.com/lar3ry/OpenSCAD---Move-STL-to-origin

That will centre it, and BOSL2 makes short work of it.

On Tue, 2024-07-09 at 23:25 +0000, Jordan Brown via Discuss wrote: >  When supplying an example, please make sure that it is self- > contained.  This one needs the SVG file to work, and does not include > definitions for r_, d_, and h_. I suppose I too should have provided the svg example in my response, but it's just an svg I whipped up in Inkscape. Its only reason for being sit that it's easy to see the rotations. > But... SVG positioning is strange for a number of reasons, so that > might not be quite right.  Still, you probably want the translate > innermost, to get the object centered before you start messing with > it.  Put an exclamation point before the translate() so that OpenSCAD > displays just that one object, and play with the translate values > until it's centered. If I were doing it, I'd impport the svg, render it, and export it as an stl. I would then use stlplace, available on github. https://github.com/lar3ry/OpenSCAD---Move-STL-to-origin That will centre it, and BOSL2 makes short work of it.