MeshPart object the same as create Mesh from shape.

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

MeshPart object the same as create Mesh from shape.

Post by keithsloan52 »

I have selected an object GDMLElTube in the attached file and created a Mesh using the Mesh Workbenches "Create Mesh for Shape"
The Meshing Options used are Standard | Surface Deviation 0.10mm | Angular deviation 30 degrees.

If I try and achieve the same from some python with

Code: Select all

if hasattr(obj, "Shape"):
                shape = obj.Shape.copy(False)
                mesh = MeshPart.meshFromShape(
                    Shape=shape,
                    Fineness=2,
                    SecondOrder=0,
                    Optimize=1,
                    AllowQuad=0,
                )
What are the equivalent options? to meshFromShape?
TestMesh.FCStd
(148.26 KiB) Downloaded 16 times
edwilliams16
Veteran
Posts: 3192
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: MeshPart object the same as create Mesh from shape.

Post by edwilliams16 »

Just copying the python console?

Code: Select all

import Mesh, Part, PartGui
import MeshPart
### End command Mesh_FromPartShape
__doc__=FreeCAD.getDocument("TestMesh")
__mesh__=__doc__.addObject("Mesh::Feature","Mesh")
__part__=__doc__.getObject("worldVOL")
__shape__=Part.getShape(__part__,"LV_EllipticalTube.GDMLElTube.")
#default
#__mesh__.Mesh=MeshPart.meshFromShape(Shape=__shape__, LinearDeflection=0.1, AngularDeflection=0.523599, Relative=False)
#your options
__mesh__.Mesh =MeshPart.meshFromShape(Shape=__shape__,Fineness=2,SecondOrder=0,Optimize=1,AllowQuad=0,)
__mesh__.Label="GDMLElTube (Meshed)"
del __doc__, __mesh__, __part__, __shape__
Post Reply