6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New()
10 from salome.smesh import smeshBuilder
11 smesh = smeshBuilder.New()
13 # create an empty mesh
17 mesh.AddNode( 0.,0.,0. )
19 # extrude a node into a line of 10 segments along the X axis
20 ids = mesh.GetNodesId()
21 stepVector = [1.,0.,0.]
23 mesh.ExtrusionSweep( ids, stepVector, nbSteps, IsNodes=True )
26 lastNode = mesh.GetNodesId()[-1]
27 lastNodeGroup = mesh.MakeGroupByIds( "node %s"% lastNode, SMESH.NODE, [lastNode])
28 lineGroup = mesh.MakeGroupByIds( "line", SMESH.EDGE, mesh.GetElementsId() )
30 # rotate the segments around the first node to get a mesh of a disk quarter
31 axisZ = [0.,0.,0., 0.,0.,1.]
32 groups = mesh.RotationSweepObject( lineGroup, axisZ, math.pi/2., 10, 1e-3, MakeGroups=True, TotalAngle=True )
34 # extrude all faces into volumes
36 stepVector = [0.,0.,-1.]
38 groups = mesh.ExtrusionSweepObject2D( obj, stepVector, nbSteps, MakeGroups=True )
40 # remove all segments created by the last command
42 if g.GetType() == SMESH.EDGE:
43 mesh.RemoveGroupWithContents( g )
45 # extrude all segments into faces along Z
47 stepVector = [0.,0.,1.]
48 mesh.ExtrusionSweepObject1D( obj, stepVector, nbSteps )
52 for g in mesh.GetGroups( SMESH.FACE ):
53 if g.GetName() == "line_extruded":
57 stepVector = [0,-5.,0.]
59 mesh.ExtrusionSweepObject( obj, stepVector, nbSteps )
61 # extrude all nodes and triangle faces of the disk quarter, applying a scale factor
63 for g in mesh.GetGroups( SMESH.FACE ):
64 if g.GetName() == "line_rotated":
67 crit = [ smesh.GetCriterion( SMESH.FACE, SMESH.FT_ElemGeomType,'=',SMESH.Geom_TRIANGLE ),
68 smesh.GetCriterion( SMESH.FACE, SMESH.FT_BelongToMeshGroup,'=', diskGroup )]
69 trianglesFilter = smesh.GetFilterFromCriteria( crit )
73 faces = [ trianglesFilter ]
76 mesh.ExtrusionSweepObjects( nodes, edges, faces, stepVector, nbSteps, scaleFactors=[0.5], linearVariation=True )
78 # extrude a cylindrical group of faces by normal
80 for g in mesh.GetGroups( SMESH.FACE ):
81 if g.GetName().startswith("node "):
88 mesh.ExtrusionByNormal( elements, stepSize, nbSteps )
90 salome.sg.updateObjBrowser()