Problem with combination of body from extrusion and body from step file
Hello, I have made a body by means of extrusion and would like to attach a body from a STEP file. To show the problem, I have made a small Python script. In the first 5 lines, I create a simple STEP file with addBox, which is written to the file box.step.
If useExtrude==False, I create a new box by means of addBox. Next, box.step is read and combined with the new box by means of fragment. This results into a nice conformal mesh.
In reality the new body is made by means of extrude. This concerns a larger project with a rather complex extrusion. In this example, I extrude a simple rectangle to a box by choosing useExtrude==True. This results into
"Error : Could not find extruded node (0, 0, 0) in surface 2"
Do I make a mistake?
Kind regards, Martin Hoeijmakers
extrude_step_file.py
import gmsh
# Create a step file to be used lateron
gmsh.initialize()
gmsh.model.occ.addBox(0.5, 0.5, 0., 1., 1., -0.5)
gmsh.model.occ.synchronize()
gmsh.write('box.step')
gmsh.finalize()
################################################################################
useExtrude = True
useExtrude = False
gmsh.initialize()
gmsh.option.setNumber('Mesh.MeshSizeMax', 0.2)
meshSizeBox1 = 0.1
if not useExtrude:
# Create a box directly
tagBox = gmsh.model.occ.addBox(0.0, 0.0, 0.0, 1., 1., 0.5)
gmsh.model.occ.mesh.setSize(gmsh.model.occ.getEntities(0), meshSizeBox1)
dimTagBox = (3, tagBox)
else:
# Create a box by means of extrude
tagRectangle = gmsh.model.occ.addRectangle(0., 0., 0., 1., 1.)
dimTagsExtrudeOut = gmsh.model.occ.extrude(
[(2, tagRectangle)],
0.0, 0.0, 0.5,
numElements=[1], heights=[1.0],
)
dimTagBox = dimTagsExtrudeOut[1]
# Read the step file created earlier
dimTagsStepFile = gmsh.model.occ.importShapes('box.step')
objectDimTags = [dimTagBox] # the box just created
toolDimTags = dimTagsStepFile # the box corresponding with the step file
outDimTags, outDimTagsMap = gmsh.model.occ.fragment(
objectDimTags, toolDimTags,
)
gmsh.model.occ.synchronize()
gmsh.model.mesh.generate(3)
gmsh.fltk.run()
gmsh.write('boxes.vtk')
gmsh.finalize()