Create spline from list of points, revolve, and save CAD model using Python API
I've looked over the tutorials and searched issues here while trying to convert my .geo script to the API. Apologies if this is the wrong place, but this seems to have replaced the mailing list?
As outlined in the title, my goal is to create a spline from a list of points, revolve it around a centerline, and save the resulting solid geometry (in the GUI I had issues saving as brep, only step working for me. My script is below, right now it is running into an error with the definition of line1 using a list of the known length. I tried using getEntities
instead and could not figure it out.
gmsh.initialize()
for idx,pt in enumerate(pts):
if idx == 0:
firstPt = gmsh.model.occ.addPoint(pt[0],pt[1],pt[2], h)
if idx == numPts-1:
lastPt = gmsh.model.occ.addPoint(pt[0],pt[1],pt[2], h)
gmsh.model.occ.addPoint(pt[0],pt[1],pt[2], h)
line1 = gmsh.model.occ.addSpline([np.arange(1,numPts+1)])
firstCoord = pts[0,:]
lastCoord = pts[-1,:]
endPt = gmsh.model.occ.addPoint(lastCoord[0],0,0, h)
startPt = gmsh.model.occ.addPoint(0,0,0, h)
line2 = gmsh.model.occ.addLine(lastPt,endPt)
line3 = gmsh.model.occ.addLine(startPt,firstPt)
rev = gmsh.model.occ.revolve(gmsh.model.getEntities(1), 1,0,0, 0,0,0, 2*np.pi )
b = [s[1] for s in rev]
surfLoop = gmsh.model.occ.addSurfaceLoop(b)
vol = gmsh.model.occ.addVolume([surfLoop])
gmsh.model.occ.synchronize()
gmsh.write(savePath)
gmsh.finalize()
Edited by Elizabeth