scale a mesh in draft create invisible object and moving issue

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
ormaa
Posts: 5
Joined: Tue Jul 26, 2022 2:47 pm

scale a mesh in draft create invisible object and moving issue

Post by ormaa »

Hello,

on MACOS, free cad version 0.20-29177
I import a mesh file ( a .stl file attached to that post )

first strange things : I Cannot move the object using transformation.
I can rotate the object using transformation 😬

I found here some infos saying I can use draft mode to move my objects. using that tips, I can move it.
is it a bug ? is it expected to be able to rotate a mesh file, but not to move it ? if yes, why ?

main issue for me, as I have no solution :
I want to scale my mesh file on Z axis only.

I entered on draft mode, select my object, select "scale" from "modifitcation" menu.
I let the point to 0,0,0
enter scale = 2 everywhere to test
check "create a clone"
click ok

an object appear in the Combo view
but the object is not visible. or not create ?
I zoom, unzoom, click on my object then click on "fit selection" button, but the object never displayed.
if I click on te created name, there is a list of parameter in property + value panel.

I uploaded a video to demonstrate my manipulation:
https://youtu.be/IxjqpbYP2kE

I get here a bug listed in 2014, I believe that it was fixed, then I don't know what To do.
if any one could tell me what I am doing wrong, or if it is a bug, please ?

many thanks
Best regards,
Olivier
Attachments
coeur2.stl
(439.96 KiB) Downloaded 27 times
User avatar
Shalmeneser
Veteran
Posts: 9580
Joined: Wed Dec 23, 2020 12:04 am
Location: Fr

Re: scale a mesh in draft create invisible object and moving issue

Post by Shalmeneser »

Std_TransformManip shows no problem for me.
But your object is very small (less than 1 mm), so you have to move a lot the arrows to see something happening (or modify the translation increment to .01 mm).
jeno
Veteran
Posts: 1854
Joined: Sun Jun 29, 2014 10:41 am

Re: scale a mesh in draft create invisible object and moving issue

Post by jeno »

ormaa wrote: Tue Jul 26, 2022 3:42 pm Hello,

on MACOS, free cad version 0.20-29177
I import a mesh file ( a .stl file attached to that post )
...
main issue for me, as I have no solution :
I want to scale my mesh file on Z axis only.
...
Hello Olivier,
uncheck uniform scaling.
X,Y -> 1, Z -> 2
For everything else see previous post of Shalmeneser.

cheers
ormaa
Posts: 5
Joined: Tue Jul 26, 2022 2:47 pm

Re: scale a mesh in draft create invisible object and moving issue

Post by ormaa »

thanks for your feedback.

I tried uniform scaling, without any success. same result, the part disappear.
ormaa
Posts: 5
Joined: Tue Jul 26, 2022 2:47 pm

Re: scale a mesh in draft create invisible object and moving issue

Post by ormaa »

thanks for your feedback.

I tried uniform scaling, without any success. same result, the part disappear.
ormaa
Posts: 5
Joined: Tue Jul 26, 2022 2:47 pm

Re: scale a mesh in draft create invisible object and moving issue

Post by ormaa »

I also tried to scale the object in mesh design, scale factor = 30. then, I have a larger object.

translation are working, then, as expected. thanks for the tips.

go back to draft, in order to scale, uniform , non uniform, none of them are working in my case.

could it be coming from the sty file ?
heda
Veteran
Posts: 1348
Joined: Sat Dec 12, 2015 5:49 pm

Re: scale a mesh in draft create invisible object and moving issue

Post by heda »

no reason why transform (with rotate) should not work.
Snip macro screenshot-97a005.png
Snip macro screenshot-97a005.png (30.29 KiB) Viewed 971 times
for the scaling, it is a "feature" - not a bug, meshes are scaled with mesh wb/scale which only is uniform
draft/scale allows non-uniform scaling, but as you have experienced does not work on meshes
(a bit annoying that the preview works though...)

anyhow, for example meshlab scales non-uniform without breaking a sweat.
(filters/mesh layer/matrix-set translation-rotation-scale)

suppose this is for 3d, if so use meshlab, file is 3x stetched in one dir (as example)

a model like this in fc is best modelled from scratch, can be done in 10 minutes taking the contour from the stl
Attachments
coeur2_ml-scaled.stl
(114.93 KiB) Downloaded 16 times
heda
Veteran
Posts: 1348
Joined: Sat Dec 12, 2015 5:49 pm

Re: scale a mesh in draft create invisible object and moving issue

Post by heda »

now, fc is a darn powerful thing,
so the fact that one cannot do non-uniform scaling of meshes in gui,
does not mean that it cant be done in fc, python to the rescue...

Code: Select all

doc = App.ActiveDocument
obj = doc.getObject('coeur2')
new_mesh = obj.Mesh.copy()
tms = obj.Mesh.Matrix
new_obj = doc.addObject("Mesh::Feature", 'coeur2_scaled')
tms.scale(App.Vector(2, 3, 0.5)) # x, y, z scale
new_mesh.transform(tms)
new_obj.Mesh = new_mesh
doc.recompute()
Snip macro screenshot-587414.png
Snip macro screenshot-587414.png (33.87 KiB) Viewed 953 times
heda
Veteran
Posts: 1348
Joined: Sat Dec 12, 2015 5:49 pm

Re: scale a mesh in draft create invisible object and moving issue

Post by heda »

using meshes for making proper boundary reps is not a good idea,
for this stl, going the route of mesh to shape and for example refine is largely producing rubbish,
as it often does with meshes (one would need some adaptive recognition algorithm's for it to do any better)
this has little to do with fc, much more that the generating sw spits out rubish
(clearly visible when taking a look at the point-cloud in the attached file)

in your OP you want to scale in z, that means basically extrude one of the planar faces.
in other words, if one can recreate one of the planar faces,
the work to complete the model is trivial after that...

a remodel workflow (not neccesarily the best, but it will always work)...
  • make a copy of the original (mesh)
    - the mesh here is scaled up to not be disapear when doing a fitView
  • cut away all but one planar face (still mesh)
  • make a point-cloud (increasing view/point-size to 5 helps to pick points later on)
    [optional]
  • one could align the point-cloud better to y-axis if one wanted to
    - the original mesh does not align very exact to the symmetry line...
  • cut one half of the point cloud (this is done in example file)
  • one could also duplicate and cut point-cloud once more,
    - then in inner and outer loop, making it easier to separate the two
    [end optional]
  • trace one half of the outer contour with draft/wire
    - draft/snap/endpoint works on point-clouds
    - make sure that draft/snap/workplane is on (gives you a planar surface in zero for free...)
    - the end of the wire should cross the symmetry line
    - 15-20 points in the tracing should be sufficient for this case (**)
    - change setting for points-display of the wire, a different color and size makes it easier to
    have the points approx at same distances on inner/outer trace
  • trace the same half inner contour with draft/wire
  • make a symmetry line with draft/line
  • trim the wires so that upper & lower symmetry divide end exactly at symmetry
    - trimming is best done in steps, since the trim function flips a too long trim
  • convert the wires to splines with draft/Wire2BSpline
  • edit the bsplines so that it follows the trace in a good manner
    - in example-file only one point on upper outer spline was adjusted...
  • draft/mirror the inner & outer bspline
  • select the 4 edges that form the heart and do draft/draft2sketch on them
  • select the sketch and do draft/upgrade - you now have a face that is the heart
  • extrude the face with part/extrude
  • done
Snip macro screenshot-581fb9.png
Snip macro screenshot-581fb9.png (53.68 KiB) Viewed 871 times
one could use part/shapebuilder for making a face out of the bsplines as well, but one will then have to make the outer and inner separate and then cut them (or resort to coding...) before making the extrude.


(**) this is needed since it in v0.19 and onwards is really cumbersome to add points to a draft/spline
it can be done through gui, then one clicks on the ellipse for the "points" property,
then table, mark one row and then the plus, preferably adjust one dimesion so that the points
are not double, makes it easier to adjust position later on (which can be done by double clicking the spline)

it was a lot easier to add/remove points from a draft/spline in v0.18 via gui,
I really wish someone would bring that back!!!
@carlopav - would it be possible for you to bring that back? (I think you were involved in making the change - if not ignore it...)
Think I remember you saying that there was some agreement that they should go, but it is not only me thinking that was the wrong decision...
https://forum.freecadweb.org/viewtopic.php?f=3&t=57385

at last, if anyone wants to contribute to freecad, feel free to make a tutorial out of this and add it to the wiki - it is a quite common scenario often answered on the forum... (would be nice to just point people to existing tutorials)
Attachments
stlremake.FCStd
(79.06 KiB) Downloaded 17 times
ormaa
Posts: 5
Joined: Tue Jul 26, 2022 2:47 pm

Re: scale a mesh in draft create invisible object and moving issue

Post by ormaa »

magnifique 🙃

I just tested the macro, it works well.

I will check in the doc if I have a possibility to detect which object is selected in the combo view, and if I can popup something to enter parameter. then it would be perfect.
if not, not a big deal, I can scale my object as I need.

thanks
Best regards
Post Reply