Hi I am trying to remesh an STL file to create a Tetrahderon.

My code looks like based on info on the web

SaimaSafdar commented on 2 Sep 2019 •
edited by nschloe
I used the gmsh-api for python https://gitlab.onelab.info/gmsh/gmsh/blob/master/README.txt
The code I used is below for the gmsh-api

import math
import gmsh_api
import gmsh_api.gmsh as gmsh

gmsh.initialize()
gmsh.option.setNumber("General.Terminal", 1)
gmsh.option.setNumber("Mesh.Algorithm", 8);
gmsh.option.setNumber("Mesh.CharacteristicLengthMin", 1);
gmsh.option.setNumber("Mesh.CharacteristicLengthMax", 2);
gmsh.option.setNumber("Mesh.Optimize",1)
gmsh.option.setNumber("Mesh.QualityType",2);

gmsh.merge("C:/2_FuzzyClassification/brainmodel/brainModelscriptacvd.stl")
n = gmsh.model.getDimension()
s = gmsh.model.getEntities(n)
l = gmsh.model.geo.addSurfaceLoop([s[i][1] for i in range(len(s))])
gmsh.model.geo.addVolume([l])
print("Volume added")
gmsh.model.geo.synchronize()

gmsh.model.mesh.generate(3)
gmsh.write("C:/2_FuzzyClassification/brainmodel/example.msh")
gmsh.finalize()


My Code

def meshObjSTL(obj, dim) :
    obj.Mesh.write('/tmp/transfer.stl')
    bbox = obj.Mesh.BoundBox
    ml = maxCord(bbox) / 10
    print('Mesh length : '+str(ml))
    gmsh.option.setNumber("Mesh.Algorithm",8)
    gmsh.option.setNumber("Mesh.CharacteristicLengthMax", ml)
gmsh.option.setNumber("Mesh.CharacteristicLengthFromCurvature", ml)
    gmsh.option.setNumber("Mesh.CharacteristicLengthFromPoints", ml)
    gmsh.option.setNumber("Mesh.Optimize",1)
    gmsh.option.setNumber("Mesh.QualityType",2)
    gmsh.merge('/tmp/transfer.stl')
    n = gmsh.model.getDimension()
    s = gmsh.model.getEntities(n)
    l = gmsh.model.geo.addSurfaceLoop([s[i][1] for i in range(len(s))])
    gmsh.model.geo.addVolume([l])
    print("Volume added")
    gmsh.model.geo.synchronize()
    gmsh.model.mesh.generate(dim)
    print('Mesh Generated '+str(dim))
    gmsh.model.mesh.renumberNodes()

But crashes with no output ( Code is part of a FreeCAD workbench )



_______________________________________________
gmsh mailing list
gmsh@onelab.info
http://onelab.info/mailman/listinfo/gmsh

Reply via email to