Centering for import

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Centering for import

ptolonen
This post has NOT been accepted by the mailing list yet.
Hi,

I think Open Scad is currently missing and important feature: centering imported models.
When importing a model, model can be far away from origo depending how it's designed.
Currently there is no way to measure and calculate translation to center the imported  3D-model or drawing.

- PT


Reply | Threaded
Open this post in threaded view
|

Re: Centering for import

jpmendes
This post was updated on .
I agree partially. KisSlicer for instance does it automatically. The pro version allows to export the STLs centered and sometimes I use this feature. However one can export the STLs having in mind, for future use, their original locations. Imagine that you want to export some objects and then import them for processing speed reasons. Maybe this is not a good practice but is possible to occur. Backward compatibility is an issue. So my proposal would be to create an import option like the one already available for cubes an cylinders "center=true". Calculating the center of an irregular object may not be trivial, and probably in the end we will need to perform some translations and rotations on it to fulfill our initial conditions. Although handy,  I think this may be not a priority feature.

jpmendes
Reply | Threaded
Open this post in threaded view
|

Re: Centering for import

doug.moen
There is an old feature request that discusses adding a centre= option to import(): 
https://github.com/openscad/openscad/issues/586

There is a new feature request under construction for a more general align() operator: 

For example,
    align("centre") import("foo.scad")
will centre the model on all axes, like a sphere.

    align(x="centre", y="centre", z="above") import()
will centre on the X and Y axes, above Z=0, like a cylinder.

    align("above") import()
will place the model in the +X,+Y,+Z octant, like a cube.

The centre is considered to be the centre of the bounding box: no fancy heuristics.

Doug.

On Saturday, 2 April 2016, jpmendes <[hidden email]> wrote:
I agree partially. KisSlicer for instance does it automatically. The pro
version allows to export the STLs centered and sometimes I use this feature.
However one can export the STLs having in mind, for future use, their
original locations. Imagine that you want to export some objects and then
import them for processing speed reasons. Maybe this is not a good practice
but is possible to occur. Backward compatibility is an issue. So my proposal
would be to create an import option like the one already available for cubes
an cylinders "center=true". Calculating calculating the center of an
irregular object may not be trivial, and probably in the end we will need to
perform some translations and rotations on it to fulfill our initial
conditions. Although handy,  I think this may be not a priority feature.

jpmendes




--
View this message in context: http://forum.openscad.org/Centering-for-import-tp16901p16906.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
<a href="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;Discuss@lists.openscad.org&#39;)">Discuss@...
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Centering for import

MichaelAtOz
Administrator
In reply to this post by ptolonen
ptolonen wrote
Currently there is no way to measure and calculate translation to center
the imported  3D-model or drawing.
To help manually do this you use View/View_All and turn on View/Show_Scale_Markers.
Admin - email* me if you need anything,
or if I've done something stupid...
* click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.


The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out!
Reply | Threaded
Open this post in threaded view
|

Re: Centering for import

Parkinbot
In reply to this post by doug.moen
It might be also a good idea to automatically fit it into a given boundingbox. This would be as good as querying the size (which is currently not possible for fomal reasons).

align(x=100, y=100, z=100, center = true) import();

Reply | Threaded
Open this post in threaded view
|

Re: Centering for import

clothbot
See the existing ‘resize()’ operator:


Very handy for things like fitting a piece of text() to a given x-size, independent of ‘size=10’ parameter value, for example:

resize([20,0,0],auto=[true,true,false]) linear_extrude(height=1) text("Hello, World!",halign="center",valign="center");
#cube([20,4,1],center=true);

…which amusingly enough highlights a case where align() would be useful. The “centered” text appears to be shifted slightly to the left, as it doesn’t overlap the 20x4x1 cube exactly at the x=[-10,10] bounds.  (Mac OSX build version 2016.03.26 (git 8308bd7))

Andrew.

On Apr 2, 2016, at 10:59 PM, Parkinbot <[hidden email]> wrote:

It might be also a good idea to automatically fit it into a given
boundingbox. This would be as good as querying the size (which is currently
not possible for fomal reasons).


align(x=100, y=100, z=100, center = true) import();






--
View this message in context: http://forum.openscad.org/Centering-for-import-tp16901p16921.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

--

"The future is already here.  It's just not very evenly distributed" -- William Gibson

Me: http://clothbot.com/wiki/




_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org