def charge_et_genere_3d(self,fichier,exportstl=None): #print marshal.version f = open(fichier,'rb') self.section_catalogue=marshal.load(f) obj=marshal.load(f) f.close() formecentre=self.__salome_genere_section_catalogue() newvolume=[] repereglobal= geompy.MakeMarker(0,0,0, 1,0,0,0,1,0) for a in obj: #impression du nom de la forme debug #print a[4] ori=geompy.MakeVertex(a[0][0],a[0][1],a[0][2]) fin=geompy.MakeVertex(a[1][0],a[1][1],a[1][2]) nouveaurepere= geompy.MakeMarker(a[0][0],a[0][1],a[0][2], a[2][0],a[2][1],a[2][2],a[3][0],a[3][1],a[3][2]) basesurface=geompy.MakePosition(formecentre[a[4]],repereglobal,nouveaurepere) newvolume.append(geompy.MakePrism(basesurface,ori,fin)) #for k,v in formecentre.iteritems(): # geompy.addToStudy(v,k) #for v in newvolume: # geompy.addToStudy(v,"Volumique") outshape=geompy.MakeCompound(newvolume) geompy.addToStudy(outshape,"Volumique") if exportstl!=None: geompy.Export(outshape, exportstl, "STL_Bin") salome.sg.updateObjBrowser(1)
def charge_et_genere_3d(self,fichier): #print marshal.version f = open(fichier,'rb') self.section_catalogue=marshal.load(f) obj=marshal.load(f) f.close() formecentre=self.__salome_genere_section_catalogue() newvolume=[] repereglobal= geompy.MakeMarker(0,0,0, 1,0,0,0,1,0) for a in obj: ori=geompy.MakeVertex(a[0][0],a[0][1],a[0][2]) fin=geompy.MakeVertex(a[1][0],a[1][1],a[1][2]) nouveaurepere= geompy.MakeMarker(a[0][0],a[0][1],a[0][2], a[2][0],a[2][1],a[2][2],a[3][0],a[3][1],a[3][2]) basesurface=geompy.MakePosition(formecentre[a[4]],repereglobal,nouveaurepere) newvolume.append(geompy.MakePrism(basesurface,ori,fin)) #for k,v in formecentre.iteritems(): # geompy.addToStudy(v,k) #for v in newvolume: # geompy.addToStudy(v,"Volumique") outshape=geompy.MakeCompound(newvolume) geompy.addToStudy(outshape,"Volumique") #geompy.Export(outshape, "/home/fred/asteretude/kuwait/toto.stp", "STEP") salome.sg.updateObjBrowser(1)
def charge_et_genere_3d(self, fichier): #print marshal.version f = open(fichier, 'rb') self.section_catalogue = marshal.load(f) obj = marshal.load(f) f.close() formecentre = self.__salome_genere_section_catalogue() newvolume = [] repereglobal = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0) for a in obj: ori = geompy.MakeVertex(a[0][0], a[0][1], a[0][2]) fin = geompy.MakeVertex(a[1][0], a[1][1], a[1][2]) nouveaurepere = geompy.MakeMarker(a[0][0], a[0][1], a[0][2], a[2][0], a[2][1], a[2][2], a[3][0], a[3][1], a[3][2]) basesurface = geompy.MakePosition(formecentre[a[4]], repereglobal, nouveaurepere) newvolume.append(geompy.MakePrism(basesurface, ori, fin)) #for k,v in formecentre.iteritems(): # geompy.addToStudy(v,k) #for v in newvolume: # geompy.addToStudy(v,"Volumique") outshape = geompy.MakeCompound(newvolume) geompy.addToStudy(outshape, "Volumique") #geompy.Export(outshape, "/home/fred/asteretude/kuwait/toto.stp", "STEP") salome.sg.updateObjBrowser(1)
def charge_et_genere_2d(self,fichier,SANS_RECALAGE=None): #print marshal.version f = open(fichier,'rb') self.section_catalogue=marshal.load(f) f.close() formecentre=self.__salome_genere_section_catalogue(SANS_RECALAGE) for k,v in formecentre.iteritems(): geompy.addToStudy(v,k) salome.sg.updateObjBrowser(1)
def charge_et_genere_2d(self, fichier, SANS_RECALAGE=None): #print marshal.version f = open(fichier, 'rb') self.section_catalogue = marshal.load(f) f.close() formecentre = self.__salome_genere_section_catalogue(SANS_RECALAGE) for k, v in formecentre.iteritems(): geompy.addToStudy(v, k) salome.sg.updateObjBrowser(1)
def doGeometry(self,params): # First, create the wire which we will get our vertex info from. # Create the command string. For now, the path starts at 0,0 # The cylinder will be centered at 0,0 for now. command = "Sketcher: F 0 0" for point in self.points: command += ":TT "+str(point[0])+" 0" print "The command path is:",command # This list with the 0,0,0,... is the origin, and the dz,dx coordinates self.extruWire = geompy.MakeSketcher(command, [0, 0, 0, 0, 0, 1, 1, 0, -0]) # Now get the vertices of this wire and the edges. We use the vertices # as the center of the circles. centres = geompy.SubShapeAll(self.extruWire, geompy.ShapeType["VERTEX"]) normal = geompy.MakeVectorDXDYDZ(0.001, 0, 0) # Build the circles for extrusion circles = [] face_circles = [] self.points.insert(0,(0,self.baseRadius)) for i in xrange(len(centres)): circles.append(geompy.MakeCircle(centres[i],normal,self.points[i][1])) face_circles.append(geompy.MakeFace(circles[i],1)) print("Just added these many circles:",len(face_circles)) # Make the pipe!! self.pipeGeom = geompy.MakePipeWithDifferentSections(circles, centres, self.extruWire, 0, 0) # Now add them to the study for i in xrange(len(circles)): geompy.addToStudy(circles[i],"circle"+str(i)) geompy.addToStudy(self.extruWire,"ExtrusionPath") for i in xrange(len(face_circles)): geompy.addToStudy(face_circles[i],"face:"+str(i)) geompy.addToStudy(self.pipeGeom,"PipeGeom") # Make a shell self.pipeShell = geompy.MakeShell([self.pipeGeom,face_circles[0],face_circles[-1]]) self.pipeSolid = geompy.MakeSolid([self.pipeShell]) geompy.addToStudy(self.pipeSolid,"PipeSolid") self.pipeGeom = self.pipeSolid
def charge_et_genere_3d(self, fichier, exportstl=None): #print marshal.version f = open(fichier, 'rb') self.section_catalogue = marshal.load(f) obj = marshal.load(f) f.close() formecentre = self.__salome_genere_section_catalogue() newvolume = [] repereglobal = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0) for a in obj: #impression du nom de la forme debug #print a[4] ori = geompy.MakeVertex(a[0][0], a[0][1], a[0][2]) fin = geompy.MakeVertex(a[1][0], a[1][1], a[1][2]) nouveaurepere = geompy.MakeMarker(a[0][0], a[0][1], a[0][2], a[2][0], a[2][1], a[2][2], a[3][0], a[3][1], a[3][2]) basesurface = geompy.MakePosition(formecentre[a[4]], repereglobal, nouveaurepere) newvolume.append(geompy.MakePrism(basesurface, ori, fin)) #for k,v in formecentre.iteritems(): # geompy.addToStudy(v,k) #for v in newvolume: # geompy.addToStudy(v,"Volumique") outshape = geompy.MakeCompound(newvolume) geompy.addToStudy(outshape, "Volumique") if exportstl != None: geompy.Export(outshape, exportstl, "STL_Bin") salome.sg.updateObjBrowser(1)
def CreateSalomeGeom(newnode, newline, groupline=[], groupnode=[]): """creation a la volle d une geometrie dans salome n'est disponible que depuis salome""" liennoeudsalome = [] for i in range(0, newnode.shape[0]): liennoeudsalome.append( geompy.MakeVertex(newnode[i, 0], newnode[i, 1], newnode[i, 2])) lienlinesalome = [] for i in range(0, len(newline)): lienlinesalome.append( geompy.MakeLineTwoPnt(liennoeudsalome[newline[i][0]], liennoeudsalome[newline[i][1]])) complist = [] complist.extend(liennoeudsalome) complist.extend(lienlinesalome) outshape = geompy.MakeCompound(complist) sortie = geompy.addToStudy(outshape, "treilli") sortiegr = [] #creation des groupes for groupe in groupline: if (len(groupe[1]) > 0): newgr = geompy.CreateGroup(outshape, geompy.ShapeType["EDGE"]) for a in groupe[1]: lineid = geompy.GetSubShapeID(outshape, lienlinesalome[a]) geompy.AddObject(newgr, lineid) sortiegr.append( geompy.addToStudyInFather(outshape, newgr, groupe[0])) #creation des groupes for groupe in groupnode: if (len(groupe[1]) > 0): newgr = geompy.CreateGroup(outshape, geompy.ShapeType["VERTEX"]) for a in groupe[1]: noeudid = geompy.GetSubShapeID(outshape, liennoeudsalome[a]) geompy.AddObject(newgr, noeudid) sortiegr.append( geompy.addToStudyInFather(outshape, newgr, groupe[0])) #gg = salome.ImportComponentGUI("GEOM") # #gg.createAndDisplayGO(sortie) #for a in sortiegr: # gg.createAndDisplayGO(a) salome.sg.updateObjBrowser(1) print "salome geom done"
def CreateSalomeGeom(newnode,newline,groupline=[],groupnode=[]): """creation a la volle d une geometrie dans salome n'est disponible que depuis salome""" liennoeudsalome=[] for i in range(0,newnode.shape[0]): liennoeudsalome.append(geompy.MakeVertex(newnode[i,0],newnode[i,1],newnode[i,2])) lienlinesalome=[] for i in range(0,len(newline)): lienlinesalome.append(geompy.MakeLineTwoPnt(liennoeudsalome[newline[i][0]],liennoeudsalome[newline[i][1]])) complist=[]; complist.extend(liennoeudsalome) complist.extend(lienlinesalome) outshape=geompy.MakeCompound(complist) sortie= geompy.addToStudy(outshape,"treilli") sortiegr=[] #creation des groupes for groupe in groupline: if (len(groupe[1])>0): newgr=geompy.CreateGroup(outshape,geompy.ShapeType["EDGE"]) for a in groupe[1]: lineid=geompy.GetSubShapeID(outshape,lienlinesalome[a]) geompy.AddObject(newgr,lineid) sortiegr.append(geompy.addToStudyInFather( outshape, newgr, groupe[0] )) #creation des groupes for groupe in groupnode: if (len(groupe[1])>0): newgr=geompy.CreateGroup(outshape,geompy.ShapeType["VERTEX"]) for a in groupe[1]: noeudid=geompy.GetSubShapeID(outshape,liennoeudsalome[a]) geompy.AddObject(newgr,noeudid) sortiegr.append(geompy.addToStudyInFather( outshape, newgr, groupe[0] )) #gg = salome.ImportComponentGUI("GEOM") # #gg.createAndDisplayGO(sortie) #for a in sortiegr: # gg.createAndDisplayGO(a) salome.sg.updateObjBrowser(1) print "salome geom done"
import GEOM import geompy import math import SALOMEDS geompy.init_geom(theStudy) O = geompy.MakeVertex(0, 0, 0) OX = geompy.MakeVectorDXDYDZ(1, 0, 0) OY = geompy.MakeVectorDXDYDZ(0, 1, 0) OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) Sommet_1 = geompy.MakeVertex(0, 0, 0) Sommet_2 = geompy.MakeVertex(0, 1, 0) Ligne_1 = geompy.MakeLineTwoPnt(Sommet_1, Sommet_2) geompy.addToStudy( O, 'O' ) geompy.addToStudy( OX, 'OX' ) geompy.addToStudy( OY, 'OY' ) geompy.addToStudy( OZ, 'OZ' ) geompy.addToStudy( Sommet_1, 'Sommet_1' ) geompy.addToStudy( Sommet_2, 'Sommet_2' ) geompy.addToStudy( Ligne_1, 'Ligne_1' ) ### ### SMESH component ### import smesh, SMESH, SALOMEDS smesh.SetCurrentStudy(theStudy) import StdMeshers
def BuildFloor (floor_index, z0, a_width, a_height, nb_segm_vert, nb_segm_hori): # 1. Build arc points in global coordinate system nb_arc = nb_segm_vert + nb_segm_hori [arcs, w_arc, h_arc, ra] = MakeArcs(a_width, a_height, nb_arc) w_mid = w_arc + size_arc # start point for wall between arc and corner width = w_mid + size_corner # tower half width at floor basement height = (h_arc + size_arc + size_corner) * sin_betta # height of tower floor dxy = height/nb_segm_vert * ctg_betta # 2. Create local CS for arc arc_CS = geompy.MakeMarker(0,-width,z0, 1,0,0, 0,1,tg_betta) # OO, Ox, Oy geompy.addToStudy(arc_CS, "arc_" + `floor_index` + "_CS" ) # 3. Build faces arc_faces = [] f_ind = 1 for arc in arcs: # 2.2. Position arc on its real place arc_real = geompy.MakePosition(arc, global_CS, arc_CS) # 2.3. Build face face_arc = geompy.MakePrismVecH(arc_real, Oy, thickness) arc_faces.append(face_arc) f_ind += 1 pass # 4. Build corner and middle points pc1 = geompy.MakeVertex(width, -width, z0) pc1_inside = geompy.MakeTranslation(pc1, -thickness, thickness, 0) pm1 = geompy.MakeVertex(w_mid, -width, z0) pm1_inside = geompy.MakeTranslation(pm1, 0, thickness, 0) corner_pts = [pc1] corner_pts_inside = [pc1_inside] middle_pts = [pm1] middle_pts_inside = [pm1_inside] dh = height/nb_segm_vert for ii in range(nb_segm_vert): pc_ii_1 = geompy.MakeTranslation(corner_pts[ii] , -dxy, dxy, dh) pm_ii_1 = geompy.MakeTranslation(middle_pts[ii] , -dxy, dxy, dh) pc_ii_1_inside = geompy.MakeTranslation(corner_pts_inside[ii], -dxy, dxy, dh) pm_ii_1_inside = geompy.MakeTranslation(middle_pts_inside[ii], -dxy, dxy, dh) corner_pts.append(pc_ii_1) middle_pts.append(pm_ii_1) corner_pts_inside.append(pc_ii_1_inside) middle_pts_inside.append(pm_ii_1_inside) pass xy_corner_top = width - nb_segm_vert*dxy xy_corner_top_inside = xy_corner_top - thickness xy_mid_top = xy_corner_top - size_corner xy_arc_top = xy_mid_top - size_arc he_glob = z0 + height dw = xy_arc_top/(nb_segm_hori - 1) xx = xy_arc_top for ii in range(nb_segm_hori): pm = geompy.MakeVertex(xx, -xy_corner_top , he_glob) pm_inside = geompy.MakeVertex(xx, -xy_corner_top_inside, he_glob) middle_pts.append(pm) middle_pts_inside.append(pm_inside) xx -= dw pass # 5. Build corner and middle faces fcs = [] for ii in range(nb_segm_vert): fc_ii = geompy.MakeQuad4Vertices(corner_pts[ii] , corner_pts_inside[ii], corner_pts[ii+1], corner_pts_inside[ii+1]) fcs.append(fc_ii) pass fms = [] for ii in range(nb_arc): fm_ii = geompy.MakeQuad4Vertices(middle_pts[ii] , middle_pts_inside[ii], middle_pts[ii+1], middle_pts_inside[ii+1]) fms.append(fm_ii) pass # 6. Build blocks bcms = [] for ii in range(nb_segm_vert): bcm_ii = geompy.MakeHexa2Faces(fms[ii], fcs[ii]) bcms.append(bcm_ii) pass bmas = [] for ii in range(nb_arc): bma_ii = geompy.MakeHexa2Faces(fms[ii], arc_faces[ii]) bmas.append(bma_ii) pass # gather blocks floor_blocks = bcms + bmas # fill top faces xy_corner_top_center = xy_corner_top - thickness/2.0 p_corner_top_center = geompy.MakeVertex(xy_corner_top_center - size_corner/2.0, - xy_corner_top_center, he_glob) top_corner_face = geompy.GetFaceNearPoint(bcms[nb_segm_vert - 1], p_corner_top_center) top_faces = [top_corner_face, fms[nb_segm_vert]] return [w_arc, w_mid, width, height, floor_blocks, top_faces]
import geompy import salome gg=salome.ImportComponentGUI("GEOM") #Creamos los Cilindros %cilindro1=geompy.MakeCylinderRH(23,56) cili?ndro2=geompy.MakeCylinderRH(300,100) #Agregamos el objeto al estudio id_cilindro1=geompy.addToStudy(cilindro1,"cilindro1") id_cilindro2=geompy.addToStudy(cilindro2,"cilindro2") #mostramos los cilindros gg.createAndDisplayGO(id_cilindro1) gg.setDisplayMode(id_cilindro1,1) gg.createAndDisplayGO(id_cilindro2) gg.setDisplayMode(id_cilindro2,1)
Direction = geompy.MakeLineTwoPnt(Sommet_1, Sommet_2) Barre_sup = geompy.MakeLineTwoPnt(Sommet_1, Sommet_3) Barre_inf = geompy.MakeLineTwoPnt(Sommet_2, Sommet_4) Barre_selle = geompy.MakeLineTwoPnt(Sommet_3, Sommet_4) Arriere_bas_1 = geompy.MakeLineTwoPnt(Sommet_4, Sommet_5) Arriere_bas_2 = geompy.MakeLineTwoPnt(Sommet_4, Sommet_6) Arriere_bas_3 = geompy.MakeLineTwoPnt(Sommet_6, Sommet_10) Arriere_bas_4 = geompy.MakeLineTwoPnt(Sommet_5, Sommet_9) Arriere_haut_1 = geompy.MakeLineTwoPnt(Sommet_3, Sommet_7) Arriere_haut_2 = geompy.MakeLineTwoPnt(Sommet_3, Sommet_8) Arriere_haut_3 = geompy.MakeLineTwoPnt(Sommet_8, Sommet_10) Arriere_haut_4 = geompy.MakeLineTwoPnt(Sommet_7, Sommet_9) Fourche = geompy.MakeLineTwoPnt(Sommet_2, Sommet_11) Cadre = geompy.MakeCompound([Direction, Barre_sup, Barre_inf, Barre_selle, Fourche, Arriere_bas_1, Arriere_bas_2, Arriere_bas_3, Arriere_bas_4, Arriere_haut_1, Arriere_haut_2, Arriere_haut_3, Arriere_haut_4]) geompy.addToStudy( Sommet_1, 'Sommet_1' ) geompy.addToStudy( Sommet_2, 'Sommet_2' ) geompy.addToStudy( Sommet_3, 'Sommet_3' ) geompy.addToStudy( Sommet_4, 'Sommet_4' ) geompy.addToStudy( Sommet_5, 'Sommet_5' ) geompy.addToStudy( Sommet_6, 'Sommet_6' ) geompy.addToStudy( Sommet_7, 'Sommet_7' ) geompy.addToStudy( Sommet_8, 'Sommet_8' ) geompy.addToStudy( Sommet_9, 'Sommet_9' ) geompy.addToStudy( Sommet_10, 'Sommet_10' ) geompy.addToStudy( Sommet_11, 'Sommet_11' ) geompy.addToStudy( Direction, 'Direction' ) geompy.addToStudy( Barre_sup, 'Barre_sup' ) geompy.addToStudy( Barre_inf, 'Barre_inf' ) geompy.addToStudy( Barre_selle, 'Barre_selle' ) geompy.addToStudy( Arriere_bas_1, 'Arriere_bas_1' )
Appui = geompy.CreateGroup(Bidon, geompy.ShapeType["EDGE"]) geompy.UnionIDs(Appui, [66]) Fonds_1 = geompy.CreateGroup(Bidon, geompy.ShapeType["FACE"]) geompy.UnionIDs(Fonds_1, [3, 10]) Virole_1 = geompy.CreateGroup(Bidon, geompy.ShapeType["FACE"]) geompy.UnionIDs(Virole_1, [37]) Bride_1 = geompy.CreateGroup(Bidon, geompy.ShapeType["FACE"]) geompy.UnionIDs(Bride_1, [18]) Piquage_2 = geompy.CreateGroup(Bidon, geompy.ShapeType["FACE"]) geompy.UnionIDs(Piquage_2, [25]) Supports_1 = geompy.CreateGroup(Bidon, geompy.ShapeType["FACE"]) geompy.UnionIDs(Supports_1, [55, 62]) geompy.addToStudy( Sommet_1, 'Sommet_1' ) geompy.addToStudy( Sommet_2, 'Sommet_2' ) geompy.addToStudy( Sommet_3, 'Sommet_3' ) geompy.addToStudy( Sommet_4, 'Sommet_4' ) geompy.addToStudy( Sommet_5, 'Sommet_5' ) geompy.addToStudy( Sommet_6, 'Sommet_6' ) geompy.addToStudy( Sommet_7, 'Sommet_7' ) geompy.addToStudy( Sommet_8, 'Sommet_8' ) geompy.addToStudy( Sommet_9, 'Sommet_9' ) geompy.addToStudy( Sommet_10, 'Sommet_10' ) geompy.addToStudy( Sommet_11, 'Sommet_11' ) geompy.addToStudy( Sommet_12, 'Sommet_12' ) geompy.addToStudy( Arc_1, 'Arc_1' ) geompy.addToStudy( Ligne_1, 'Ligne_1' ) geompy.addToStudy( Arc_2, 'Arc_2' )
Ligne_2 = geompy.MakeLineTwoPnt(Sommet_2, Sommet_3) Ligne_3 = geompy.MakeLineTwoPnt(Sommet_3, Sommet_4) Ligne_4 = geompy.MakeLineTwoPnt(Sommet_4, Sommet_5) Ligne_5 = geompy.MakeLineTwoPnt(Sommet_5, Sommet_6) Ligne_6 = geompy.MakeLineTwoPnt(Sommet_6, Sommet_7) Ligne_7 = geompy.MakeLineTwoPnt(Sommet_7, Sommet_8) Ligne_8 = geompy.MakeLineTwoPnt(Sommet_8, Sommet_9) Ligne_9 = geompy.MakeLineTwoPnt(Sommet_9, Sommet_1) Ligne_10 = geompy.MakeLineTwoPnt(Sommet_2, Sommet_9) Ligne_11 = geompy.MakeLineTwoPnt(Sommet_8, Sommet_3) Ligne_12 = geompy.MakeLineTwoPnt(Sommet_7, Sommet_4) Assemblage_1 = geompy.MakeCompound([ Ligne_1, Ligne_2, Ligne_3, Ligne_4, Ligne_5, Ligne_6, Ligne_7, Ligne_8, Ligne_9, Ligne_10, Ligne_11, Ligne_12 ]) geompy.addToStudy(O, 'O') geompy.addToStudy(OX, 'OX') geompy.addToStudy(OY, 'OY') geompy.addToStudy(OZ, 'OZ') geompy.addToStudy(O_1, 'O') geompy.addToStudy(OX_1, 'OX') geompy.addToStudy(OY_1, 'OY') geompy.addToStudy(OZ_1, 'OZ') geompy.addToStudy(Sommet_1, 'Sommet_1') geompy.addToStudy(Sommet_2, 'Sommet_2') geompy.addToStudy(Sommet_3, 'Sommet_3') geompy.addToStudy(Sommet_4, 'Sommet_4') geompy.addToStudy(Sommet_5, 'Sommet_5') geompy.addToStudy(Sommet_6, 'Sommet_6') geompy.addToStudy(Sommet_7, 'Sommet_7') geompy.addToStudy(Sommet_8, 'Sommet_8')
injRads.append(Rout) # R0 #injRads.append(100.00) # R0 #injRads.append( 25.00) # R1 injRads.append( 25.00) # R1 injRads.append( 4.75) # R2 injRads.append( 39.50) # R3 injRads.append( 75.00) # R4 # injAngs.append( 45.00) # A1 # wallS = 1.0 # wall thikness # # # injGeom = injector_GEOM.CreateGEOM (injLens, injRads, injAngs, wallS) id_injGEOM = geompy.addToStudy(injGeom,"injGeom") # # To Select Geometry From Tree # #id_selObj = salome.sg.getSelected(0) #print id_selObj #injGeom = salome.IDToObject(id_selObj) # faceTol = 1.0E-3 edgeTol = 1.0E-3 print "Face Groups (BC)" faceGroups = injector_GROUPS.injectorFaceGroups(injGeom, injLens, injRads, wallS ,faceTol) print "Edge Groups (Mesh Options)" edgeGroups = injector_GROUPS.injectorEdgeGroups(injGeom, injLens, injRads, wallS ,edgeTol) print "Geometry done."
Ligne_4_vertex_2 = geompy.GetSubShape(Ligne_4, [2]) Cercle_3 = geompy.MakeCircle(Ligne_4_vertex_2, Ligne_4, 50) Contour_1 = geompy.MakeWire([Ligne_1, Ligne_2, Ligne_3], 1e-07) Tuyau_1 = geompy.MakePipe(Cercle_1, Contour_1) Tuyau_2 = geompy.MakePipe(Cercle_2, Ligne_5) Tuyau_3 = geompy.MakePipe(Cercle_3, Ligne_4) Partition_1 = geompy.MakePartition([Tuyau_1], [Tuyau_2, Tuyau_3], [], [], geompy.ShapeType["SHELL"], 0, [], 0) [joint, Partition_2, Face_2, Face_1, Face_5, Face_6, Face_7] = geompy.ExtractShapes(Partition_1, geompy.ShapeType["FACE"], True) Partition_2 = geompy.MakePartition([Tuyau_2, Tuyau_3], [Partition_1], [], [], geompy.ShapeType["SHELL"], 0, [], 0) [Face_1, Face_2, joint, geomObj_1] = geompy.ExtractShapes(Partition_2, geompy.ShapeType["FACE"], True) joint = geompy.MakeCompound([Face_5, Face_6, Face_7, Face_1, Face_2]) geompy.addToStudy(O, 'O') geompy.addToStudy(OX, 'OX') geompy.addToStudy(OY, 'OY') geompy.addToStudy(OZ, 'OZ') geompy.addToStudy(Sommet_1, 'Sommet_1') geompy.addToStudy(Sommet_2, 'Sommet_2') geompy.addToStudy(Sommet_3, 'Sommet_3') geompy.addToStudy(Sommet_4, 'Sommet_4') geompy.addToStudy(Sommet_5, 'Sommet_5') geompy.addToStudy(Sommet_6, 'Sommet_6') geompy.addToStudy(Ligne_1, 'Ligne_1') geompy.addToStudy(Ligne_2, 'Ligne_2') geompy.addToStudy(Ligne_3, 'Ligne_3') geompy.addToStudy(Ligne_4, 'Ligne_4') geompy.addToStudy(Ligne_5, 'Ligne_5') geompy.addToStudyInFather(Ligne_1, Ligne_1_vertex_2, 'Ligne_1:vertex_2')
Sommet_8 = geompy.MakeVertex(4000, 1000, 0) Sommet_9 = geompy.MakeVertex(2000, 500, 0) Ligne_1 = geompy.MakeLineTwoPnt(Sommet_1, Sommet_2) Ligne_2 = geompy.MakeLineTwoPnt(Sommet_2, Sommet_3) Ligne_3 = geompy.MakeLineTwoPnt(Sommet_3, Sommet_4) Ligne_4 = geompy.MakeLineTwoPnt(Sommet_4, Sommet_5) Ligne_5 = geompy.MakeLineTwoPnt(Sommet_5, Sommet_6) Ligne_6 = geompy.MakeLineTwoPnt(Sommet_6, Sommet_7) Ligne_7 = geompy.MakeLineTwoPnt(Sommet_7, Sommet_8) Ligne_8 = geompy.MakeLineTwoPnt(Sommet_8, Sommet_9) Ligne_9 = geompy.MakeLineTwoPnt(Sommet_9, Sommet_1) Ligne_10 = geompy.MakeLineTwoPnt(Sommet_2, Sommet_9) Ligne_11 = geompy.MakeLineTwoPnt(Sommet_8, Sommet_3) Ligne_12 = geompy.MakeLineTwoPnt(Sommet_7, Sommet_4) Assemblage_1 = geompy.MakeCompound([Ligne_1, Ligne_2, Ligne_3, Ligne_4, Ligne_5, Ligne_6, Ligne_7, Ligne_8, Ligne_9, Ligne_10, Ligne_11, Ligne_12]) geompy.addToStudy( O, 'O' ) geompy.addToStudy( OX, 'OX' ) geompy.addToStudy( OY, 'OY' ) geompy.addToStudy( OZ, 'OZ' ) geompy.addToStudy( O_1, 'O' ) geompy.addToStudy( OX_1, 'OX' ) geompy.addToStudy( OY_1, 'OY' ) geompy.addToStudy( OZ_1, 'OZ' ) geompy.addToStudy( Sommet_1, 'Sommet_1' ) geompy.addToStudy( Sommet_2, 'Sommet_2' ) geompy.addToStudy( Sommet_3, 'Sommet_3' ) geompy.addToStudy( Sommet_4, 'Sommet_4' ) geompy.addToStudy( Sommet_5, 'Sommet_5' ) geompy.addToStudy( Sommet_6, 'Sommet_6' ) geompy.addToStudy( Sommet_7, 'Sommet_7' ) geompy.addToStudy( Sommet_8, 'Sommet_8' )
def draw_airfoil_section(name,verts): wire = geompy.MakePolyline(verts,theIsClosed=0) geompy.addToStudy(wire,name) return wire
OY = geompy.MakeVectorDXDYDZ(0, 1, 0) OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) Sommet_1 = geompy.MakeVertex(0, 0, 0) Sommet_2 = geompy.MakeVertex(1, 0, 0) Sommet_3 = geompy.MakeVertex(1, 1, 0) Sommet_4 = geompy.MakeVertex(0, 1, 0) Ligne_1 = geompy.MakeLineTwoPnt(Sommet_1, Sommet_2) Ligne_2 = geompy.MakeLineTwoPnt(Sommet_2, Sommet_3) Ligne_3 = geompy.MakeLineTwoPnt(Sommet_3, Sommet_4) Ligne_4 = geompy.MakeLineTwoPnt(Sommet_4, Sommet_1) Plaque = geompy.MakeFaceWires([Ligne_1, Ligne_2, Ligne_3, Ligne_4], 1) listSubShapeIDs = geompy.SubShapeAllIDs(Plaque, geompy.ShapeType["EDGE"]) BORD = geompy.CreateGroup(Plaque, geompy.ShapeType["EDGE"]) geompy.UnionIDs(BORD, [3, 6, 8, 10]) geomObj_1 = geompy.GetSubShape(Plaque, [3]) geompy.addToStudy(O, 'O') geompy.addToStudy(OX, 'OX') geompy.addToStudy(OY, 'OY') geompy.addToStudy(OZ, 'OZ') geompy.addToStudy(Sommet_1, 'Sommet_1') geompy.addToStudy(Sommet_2, 'Sommet_2') geompy.addToStudy(Sommet_3, 'Sommet_3') geompy.addToStudy(Sommet_4, 'Sommet_4') geompy.addToStudy(Ligne_1, 'Ligne_1') geompy.addToStudy(Ligne_2, 'Ligne_2') geompy.addToStudy(Ligne_3, 'Ligne_3') geompy.addToStudy(Ligne_4, 'Ligne_4') geompy.addToStudy(Plaque, 'Plaque') geompy.addToStudyInFather(Plaque, BORD, 'BORD') ###
import geompy import salome gg = salome.ImportComponentGUI("GEOM") #creamos dos vertices y un vector a partir de los vertices #p1 = geompy.MakeVertex(35, 35, 0) #p2 = geompy.MakeVertex(35, 35, 70) #v = geompy.MakeVector(p1, p2) #creamos los conos #cone1 = geompy.MakeCone(p1, v, 17, 1, 20) cone = geompy.MakeConeR1R2H(30, 10, 30) #agregamos objetos al estudio id_cone1 = geompy.addToStudy(cone1, "Cone1") id_cone2 = geompy.addToStudy(cone2, "Cone2") #Dibujamos los conos gg.createAndDisplayGO(id_cone1) gg.setDisplayMode(id_cone1, 1) gg.createAndDisplayGO(id_cone2) gg.setDisplayMode(id_cone2, 1)
if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(True) ## Geometry part ## salome.salome_init() geompy.init_geom(salome.myStudy) cyl_rad = 10 cyl_height = 40 box_final_coords = [ 100, 30, 100 ] points_offset = 35 vectorOY = geompy.MakeVector(geompy.MakeVertex(0,0,0), geompy.MakeVertex(0,100,0)) box = geompy.MakeBoxDXDYDZ(box_final_coords[0], box_final_coords[1],box_final_coords[2]) box = geompy.MakeRotation(box, vectorOY, 45) geompy.addToStudy ( box, 'box' ) diagons = [ geompy.MakeLineTwoPnt(geompy.MakeVertex( 0,box_final_coords[1], 0 ), geompy.MakeVertex( box_final_coords[0],box_final_coords[1], box_final_coords[2])), geompy.MakeLineTwoPnt(geompy.MakeVertex( box_final_coords[0], box_final_coords[1], 0 ), geompy.MakeVertex( 0, box_final_coords[1], box_final_coords[2]))] for counter in range(1,3): diagons[counter-1] = geompy.MakeRotation(diagons[counter-1], vectorOY, 45) geompy.addToStudy( diagons[counter-1], 'diagon_' + str(counter) ) central_point = geompy.MakeVertexOnLinesIntersection(diagons[0], diagons[1]) points = [ geompy.MakeVertexWithRef(central_point, -points_offset, 0, 0), geompy.MakeVertexWithRef(central_point, points_offset, 0, 0) ] for each_point,counter in zip(points, range(1,3)): geompy.addToStudy ( each_point, 'point_' + str(counter) ) cyls = [] for each_point,counter in zip(points, range(0,2)): cyls.append( geompy.MakeCylinder(each_point, vectorOY, cyl_rad, cyl_height) )
Ligne_2 = geompy.MakeLineTwoPnt(Sommet_2, Sommet_3) Ligne_3 = geompy.MakeLineTwoPnt(Sommet_3, Sommet_4) Ligne_4 = geompy.MakeLineTwoPnt(Sommet_4, Sommet_7) Ligne_5 = geompy.MakeLineTwoPnt(Sommet_7, Sommet_3) Ligne_6 = geompy.MakeLineTwoPnt(Sommet_3, Sommet_6) Ligne_7 = geompy.MakeLineTwoPnt(Sommet_6, Sommet_2) Ligne_8 = geompy.MakeLineTwoPnt(Sommet_2, Sommet_5) Ligne_1_vertex_2 = geompy.GetSubShape(Ligne_1, [2]) Ligne_9 = geompy.MakeLineTwoPnt(Sommet_5, Ligne_1_vertex_2) Ligne_8_vertex_3 = geompy.GetSubShape(Ligne_8, [3]) Ligne_10 = geompy.MakeLineTwoPnt(Ligne_8_vertex_3, Sommet_6) Ligne_11 = geompy.MakeLineTwoPnt(Sommet_6, Sommet_7) Treillis = geompy.MakeCompound([Ligne_1, Ligne_2, Ligne_3, Ligne_4, Ligne_5, Ligne_6, Ligne_7, Ligne_8, Ligne_9, Ligne_10, Ligne_11]) listSubShapeIDs = geompy.SubShapeAllIDs(Treillis, geompy.ShapeType["SHAPE"]) geomObj_1 = geompy.GetSubShape(Treillis, [2]) geompy.addToStudy( O, 'O' ) geompy.addToStudy( OX, 'OX' ) geompy.addToStudy( OY, 'OY' ) geompy.addToStudy( OZ, 'OZ' ) geompy.addToStudy( Sommet_1, 'Sommet_1' ) geompy.addToStudy( Sommet_2, 'Sommet_2' ) geompy.addToStudy( Sommet_3, 'Sommet_3' ) geompy.addToStudy( Sommet_4, 'Sommet_4' ) geompy.addToStudy( Sommet_5, 'Sommet_5' ) geompy.addToStudy( Sommet_6, 'Sommet_6' ) geompy.addToStudy( Sommet_7, 'Sommet_7' ) geompy.addToStudy( Ligne_1, 'Ligne_1' ) geompy.addToStudy( Ligne_2, 'Ligne_2' ) geompy.addToStudy( Ligne_3, 'Ligne_3' ) geompy.addToStudy( Ligne_4, 'Ligne_4' ) geompy.addToStudy( Ligne_5, 'Ligne_5' )
Face_2 = geompy.MakeFaceWires([Ligne_3, Ligne_5, Ligne_6, Ligne_7], 1) Plaque = geompy.MakeCompound([Face_1, Face_2]) Sym = geompy.CreateGroup(Plaque, geompy.ShapeType["EDGE"]) geompy.UnionIDs(Sym, [4]) gauche = geompy.CreateGroup(Plaque, geompy.ShapeType["EDGE"]) geompy.UnionIDs(gauche, [7]) droite = geompy.CreateGroup(Plaque, geompy.ShapeType["EDGE"]) geompy.UnionIDs(droite, [11]) Fin = geompy.CreateGroup(Plaque, geompy.ShapeType["FACE"]) geompy.UnionIDs(Fin, [2]) centre = geompy.CreateGroup(Plaque, geompy.ShapeType["EDGE"]) geompy.UnionIDs(centre, [4, 9]) ext = geompy.CreateGroup(Plaque, geompy.ShapeType["EDGE"]) geompy.UnionIDs(ext, [19]) geompy.addToStudy( O, 'O' ) geompy.addToStudy( OX, 'OX' ) geompy.addToStudy( OY, 'OY' ) geompy.addToStudy( OZ, 'OZ' ) geompy.addToStudy( Sommet_1, 'Sommet_1' ) geompy.addToStudy( Sommet_2, 'Sommet_2' ) geompy.addToStudy( Sommet_3, 'Sommet_3' ) geompy.addToStudy( Sommet_4, 'Sommet_4' ) geompy.addToStudy( Sommet_5, 'Sommet_5' ) geompy.addToStudy( Sommet_6, 'Sommet_6' ) geompy.addToStudy( Ligne_1, 'Ligne_1' ) geompy.addToStudy( Ligne_2, 'Ligne_2' ) geompy.addToStudy( Ligne_3, 'Ligne_3' ) geompy.addToStudy( Ligne_4, 'Ligne_4' ) geompy.addToStudy( Ligne_5, 'Ligne_5' )
mesh_nb_segments = 10 mesh_nb_segments_local = int(mesh_nb_segments * h_thin / h_thick) nb_cogs = 6 nb_blocks = 2 * nb_cogs ######################################### # # Gear Wheel Geometry # ######################################### OO = geompy.MakeVertex(0, 0, 0) Oz = geompy.MakeVectorDXDYDZ(0, 0, 200) geompy.addToStudy(OO, "OO") geompy.addToStudy(Oz, "Oz") alpha = 360.0/nb_blocks/2.0 betta = alpha*2.0/3.0 radiuces = [21., 39., 57., 75., 100.] angles = [alpha, alpha, alpha, alpha, betta] points = [[], [], [], [], []] arcs = [] blocks = [] multis_thick = [] multis_thin = [] pp_local_hyp_1 = None
A = 3.1926 H = 200 # [m] a = H * AR # [m] x = linspace(0, a, N) # [m] y = -H * 1 / 6.04844 * (sp.j0(A) * sp.i0(A * x / a) - sp.i0(A) * sp.j0(A * x / a)) nPts = len(x) x = append(x, max(a * 200, 3600)) y = append(y, 0) nPts = nPts + 1 ptList = [] print "Creating %s points" % nPts for i in range(nPts): v = geompy.MakeVertex(x[i], 0, y[i]) geompy.addToStudy(v, "Vertex_%d" % (i + 1)) ptList.append(v) print str([i, x[i], y[i], 0]) print "creating polyLine" polyline = geompy.MakePolyline(ptList) #interpol = geompy.MakeInterpol(ptList) geompy.addToStudy(polyline, "polyline") #geompy.addToStudy(interpol, "interpol" ) print "creating revolution" Vertex_a = geompy.MakeVertex(0, 0, 0) Vertex_b = geompy.MakeVertex(0, 0, H) Line_1 = geompy.MakeLineTwoPnt(Vertex_a, Vertex_b) Revolution_1 = geompy.MakeRevolution(polyline, Line_1, 360 * math.pi / 180.0) newName = "Martinez3D_h_" + str(H) + "_AR_" + str(AR)
#geompy.addToStudy( inf, 'inf' ) #groupe des faces qui ont un interet grface=[] grface.append(infbase) for a in facenodeup: for b in a: grface.append(b) grfaceCompound = geompy.MakeCompound(grface) #geompy.addToStudy( grfaceCompound, 'grfaceCompound' ) #solide final globalsolid=geompy.MakePartition([Box_1], [grfaceCompound], [], [], geompy.ShapeType["SOLID"], 0, [], 1) geompy.addToStudy( globalsolid, 'globalsolid' ) #generation des groupes groupe=[] #EDGE #Rien #FACE #infbase groupe de face qui represente le pied de la structure grinfbase=geompy.CreateGroup(globalsolid,geompy.ShapeType["FACE"]) [geomObj_248] = geompy.SubShapeAll(infbase, geompy.ShapeType["FACE"]) geomObj_temp = geompy.GetSame(globalsolid, geomObj_248) tempid=geompy.GetSubShapeID(globalsolid,geomObj_temp) geompy.AddObject(grinfbase,tempid) geompy.addToStudyInFather( globalsolid, grinfbase, "infbase" )
geompy.init_geom(theStudy) Box_1 = geompy.MakeBoxDXDYDZ(18, 18, 6) listSubShapeIDs = geompy.SubShapeAllIDs(Box_1, geompy.ShapeType["FACE"]) listSubShapeIDs = geompy.SubShapeAllIDs(Box_1, geompy.ShapeType["FACE"]) listSubShapeIDs = geompy.SubShapeAllIDs(Box_1, geompy.ShapeType["SOLID"]) forc = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) geompy.UnionIDs(forc, [33]) toutface = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) geompy.UnionIDs(toutface, [3, 13, 23, 27, 31, 33]) tout = geompy.CreateGroup(Box_1, geompy.ShapeType["SOLID"]) geompy.UnionIDs(tout, [1]) geomObj_1 = geompy.GetSubShape(Box_1, [3]) geompy.addToStudy( Box_1, 'Box_1' ) geompy.addToStudyInFather( Box_1, forc, 'forc' ) geompy.addToStudyInFather( Box_1, toutface, 'toutface' ) geompy.addToStudyInFather( Box_1, tout, 'tout' ) ### Store presentation parameters of displayed objects import iparameters ipar = iparameters.IParameters(theStudy.GetModuleParameters("Interface Applicative", "GEOM", 1)) #Set up entries: # set up entry GEOM_1 (Box_1) parameters objId = geompy.getObjectID(Box_1) ipar.setParameter(objId, "OCCViewer_0_Visibility", "On") ipar.setParameter(objId, "OCCViewer_0_Color", "1:1:0") # set up entry GEOM_1:1 (forc) parameters objId = geompy.getObjectID(forc)
O = geompy.MakeVertex(0, 0, 0) OX = geompy.MakeVectorDXDYDZ(1, 0, 0) OY = geompy.MakeVectorDXDYDZ(0, 1, 0) OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) Corps_principal = geompy.ImportSTEP("/home/bordreuil/Enseignement/elementsFiNimes/Examples/3D/G_RepMart/piedRepMart.stp") [Esquisse_1] = geompy.SubShapes(Corps_principal, [56]) geomObj_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0) geomObj_2 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0) Corps_principal_1 = geompy.GetSubShape(Corps_principal, [261]) Esquisse_1 = geompy.MakeSketcherOnPlane("Sketcher:F -0.050000 0.000000:TT 0.050000 0.000000:TT 0.050000 -0.050000:TT -0.050000 -0.050000:WW", Corps_principal_1 ) Enl_vement_extrud__1 = geompy.MakeExtrudedCut(Corps_principal, Esquisse_1, 90, 0) [Appui1] = geompy.SubShapes(Enl_vement_extrud__1, [278]) [Appui2] = geompy.SubShapes(Enl_vement_extrud__1, [309]) [Tige] = geompy.SubShapes(Enl_vement_extrud__1, [349]) geompy.addToStudy( O, 'O' ) geompy.addToStudy( OX, 'OX' ) geompy.addToStudy( OY, 'OY' ) geompy.addToStudy( OZ, 'OZ' ) geompy.addToStudy( Corps_principal, 'Corps principal' ) geompy.addToStudy( Esquisse_1, 'Esquisse_1' ) geompy.addToStudyInFather( Corps_principal, Corps_principal_1, 'Corps principal' ) geompy.addToStudy( Enl_vement_extrud__1, 'Enlèvement_extrudé_1' ) geompy.addToStudyInFather( Enl_vement_extrud__1, Appui1, 'Appui1' ) geompy.addToStudyInFather( Enl_vement_extrud__1, Appui2, 'Appui2' ) geompy.addToStudyInFather( Enl_vement_extrud__1, Tige, 'Tige' ) if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(1)
def draw_airfoil_section(name, verts): wire = geompy.MakePolyline(verts, theIsClosed=0) geompy.addToStudy(wire, name) return wire
baseOY = geompy.MakeVectorDXDYDZ(0,1,0) baseOZ = geompy.MakeVectorDXDYDZ(0,0,1) # startingPoint = geompy.MakeVertex(startX, startY, startZ) endingPoint = geompy.MakeVertexWithRef(startingPoint, normalSDX*spiralLength, normalSDY*spiralLength, normalSDZ*spiralLength) endingPoint0 = geompy.MakeVertexWithRef(startingPoint, 0, 0, spiralLength) baseDirectionVector = geompy.MakeVectorDXDYDZ(normalSDX*spiralLength, normalSDY*spiralLength, normalSDZ*spiralLength) realStartingPoint = geompy.MakeVertex(startX+spiralRadius, startY, startZ) startingVector = geompy.MakeVectorDXDYDZ(0,1,0) tubeCircle = geompy.MakeCircle(realStartingPoint, startingVector, tubeRadius) #id_sVector = geompy.addToStudy(startingVector, "Starting Vector") #id_rsPoint = geompy.addToStudy(realStartingPoint, "Starting Point") # id_sPoint = geompy.addToStudy(startingPoint, "Start Center Point") id_bVector = geompy.addToStudy(baseDirectionVector, "Base Vector") # iVertices = [] id_iVertices = [] hStep = 0 I = 0 x = [None]*(nStepPoints) y = [None]*(nStepPoints) z = [None]*(nStepPoints) hamma = 2.0*math.pi/nStepPoints # radians in one segment of spiral step #creating points for spiral skeleton while (hStep < spiralLength): M = nStepPoints for J in range (0, M): x[J] = startX + math.cos(hamma*J)*spiralRadius
#creamos vertices #p0 = geompy.MakeVertex(0.,0.,0.) #px = geompy.MakeVertex(100.,0.,0.) #py = geompy.MakeVertex(0.,100.,0.) #pz = geompy.MakeVertex(0., 0., 100.) #creamos un vector dados dos puntos #vxy = geompy.MakeVector(px, py) #creamos un disco sobre el plano XY disk1 = geompy.MakeDiskR(100, 1) # creamos un disco desde un punto,un vector y un radio #disk2 = geompy.MakeDiskPntVecR(pz, vxy, 30) #creamos un disco desde un punto #disk3 = geompy.MakeDiskThreePnt(p0, px, py) #Agregamos objetos al estudio id_vxy = geompy.addToStudy(vxy, "Vector") id_disk1 = geompy.addToStudy(disk1,"Disk1") id_disk2 = geompy.addToStudy(disk2,"Disk2") id_disk3 = geompy.addToStudy(disk3,"Disk3") #Dibujamos los discos gg.createAndDisplayGO(id_vxy) gg.createAndDisplayGO(id_disk1) gg.createAndDisplayGO(id_diks2) gg.createAndDisplayGO(id_diks3)
def RebuildData(theStudy): geompy.init_geom(theStudy) global Edge_1, Edge_2, Vertex_3, Revolution_1, Vertex_5, Vertex_4, Vertex_6, Face_1, Cone_1, Edge_5, Edge_3, Cylinder_1, Edge_4, Translation_1, Y, Vertex_2, Common_1, Cut_1, Compound_1, Vector_1, Fillet_1, X, Box_1, Rotation_1, Partition_1, Cone_1_edge_7, Torus_1, Vertex_1, Circle_1 Vertex_1 = geompy.MakeVertex(200, 200, 0) Vertex_2 = geompy.MakeVertexWithRef(Vertex_1, 0, 0, 200) Vector_1 = geompy.MakeVector(Vertex_1, Vertex_2) Cone_1 = geompy.MakeConeR1R2H(100, 0, 300) Cylinder_1 = geompy.MakeCylinder(Vertex_2, Vector_1, 100, 100) geomObj_1 = geompy.GetSubShape(Cone_1, [7]) Circle_1 = geompy.MakeCircle(Vertex_1, Vector_1, 100) Cone_1_edge_7 = geompy.GetSubShape(Cone_1, [7]) Revolution_1 = geompy.MakeRevolution2Ways(Circle_1, Cone_1_edge_7, 45*math.pi/180.0) Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) Torus_1 = geompy.MakeTorusRR(200, 75) Common_1 = geompy.MakeCommon(Torus_1, Box_1) Cut_1 = geompy.MakeCut(Torus_1, Box_1) Translation_1 = geompy.MakeTranslation(Torus_1, 190, 190, 0) Y = geompy.MakeVectorDXDYDZ(0, 100, 0) X = geompy.MakeVectorDXDYDZ(100, 0, 0) Rotation_1 = geompy.MakeRotation(Translation_1, Y, -90*math.pi/180.0) Compound_1 = geompy.MakeCompound([Translation_1, Torus_1, Rotation_1]) Fillet_1 = geompy.MakeFilletAll(Box_1, 35) Vertex_3 = geompy.MakeVertex(0, 0, 0) Vertex_4 = geompy.MakeVertex(0, 0, 200) Vertex_5 = geompy.MakeVertex(200, 0, 200) Vertex_6 = geompy.MakeVertex(200, 0, 0) Edge_1 = geompy.MakeEdge(Vertex_3, Vertex_4) Edge_2 = geompy.MakeEdge(Vertex_4, Vertex_5) Edge_3 = geompy.MakeEdge(Vertex_5, Vertex_6) Edge_4 = geompy.MakeEdge(Vertex_6, Vertex_3) Face_1 = geompy.MakeFaceWires([Edge_1, Edge_2, Edge_3, Edge_4], 1) Edge_5 = geompy.MakeEdge(Vertex_3, Vertex_5) Partition_1 = geompy.MakePartition([Face_1], [Edge_5], [], [], geompy.ShapeType["FACE"], 0, [], 0) geompy.addToStudy( Vertex_1, "Vertex_1" ) geompy.addToStudy( Vertex_2, "Vertex_2" ) geompy.addToStudy( Vector_1, "Vector_1" ) geompy.addToStudy( Cone_1, "Cone_1" ) geompy.addToStudy( Cylinder_1, "Cylinder_1" ) geompy.addToStudy( Circle_1, "Circle_1" ) geompy.addToStudyInFather( Cone_1, Cone_1_edge_7, "Cone_1:edge_7" ) geompy.addToStudy( Revolution_1, "Revolution_1" ) geompy.addToStudy( Box_1, "Box_1" ) geompy.addToStudy( Torus_1, "Torus_1" ) geompy.addToStudy( Common_1, "Common_1" ) geompy.addToStudy( Cut_1, "Cut_1" ) geompy.addToStudy( Translation_1, "Translation_1" ) geompy.addToStudy( Y, "Y" ) geompy.addToStudy( X, "X" ) geompy.addToStudy( Rotation_1, "Rotation_1" ) geompy.addToStudy( Compound_1, "Compound_1" ) geompy.addToStudy( Fillet_1, "Fillet_1" ) geompy.addToStudy( Vertex_3, "Vertex_3" ) geompy.addToStudy( Vertex_4, "Vertex_4" ) geompy.addToStudy( Vertex_5, "Vertex_5" ) geompy.addToStudy( Vertex_6, "Vertex_6" ) geompy.addToStudy( Edge_1, "Edge_1" ) geompy.addToStudy( Edge_2, "Edge_2" ) geompy.addToStudy( Edge_3, "Edge_3" ) geompy.addToStudy( Edge_4, "Edge_4" ) geompy.addToStudy( Face_1, "Face_1" ) geompy.addToStudy( Edge_5, "Edge_5" ) geompy.addToStudy( Partition_1, "Partition_1" ) ### Store presentation parameters of displayed objects import iparameters ipar = iparameters.IParameters(theStudy.GetModuleParameters("Interface Applicative", "GEOM", 1)) #Set up entries: # set up entry GEOM_11 (Cut_1) parameters ipar.setParameter("GEOM_11", "OCCViewer_0_Visibility", "On") ipar.setParameter("GEOM_11", "OCCViewer_0_DisplayMode", "1") ipar.setParameter("GEOM_11", "OCCViewer_0_Transparency", "0") ipar.setParameter("GEOM_11", "OCCViewer_0_Isos", "1:1") pass
OY = geompy.MakeVectorDXDYDZ(0, 1, 0) OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) Sommet_1 = geompy.MakeVertex(0, 0, 0) Sommet_2 = geompy.MakeVertex(1, 0, 0) Sommet_3 = geompy.MakeVertex(1, 1, 0) Sommet_4 = geompy.MakeVertex(0, 1, 0) Ligne_1 = geompy.MakeLineTwoPnt(Sommet_1, Sommet_2) Ligne_2 = geompy.MakeLineTwoPnt(Sommet_2, Sommet_3) Ligne_3 = geompy.MakeLineTwoPnt(Sommet_3, Sommet_4) Ligne_4 = geompy.MakeLineTwoPnt(Sommet_4, Sommet_1) Plaque = geompy.MakeFaceWires([Ligne_1, Ligne_2, Ligne_3, Ligne_4], 1) listSubShapeIDs = geompy.SubShapeAllIDs(Plaque, geompy.ShapeType["EDGE"]) BORD = geompy.CreateGroup(Plaque, geompy.ShapeType["EDGE"]) geompy.UnionIDs(BORD, [3, 6, 8, 10]) geomObj_1 = geompy.GetSubShape(Plaque, [3]) geompy.addToStudy( O, 'O' ) geompy.addToStudy( OX, 'OX' ) geompy.addToStudy( OY, 'OY' ) geompy.addToStudy( OZ, 'OZ' ) geompy.addToStudy( Sommet_1, 'Sommet_1' ) geompy.addToStudy( Sommet_2, 'Sommet_2' ) geompy.addToStudy( Sommet_3, 'Sommet_3' ) geompy.addToStudy( Sommet_4, 'Sommet_4' ) geompy.addToStudy( Ligne_1, 'Ligne_1' ) geompy.addToStudy( Ligne_2, 'Ligne_2' ) geompy.addToStudy( Ligne_3, 'Ligne_3' ) geompy.addToStudy( Ligne_4, 'Ligne_4' ) geompy.addToStudy( Plaque, 'Plaque' ) geompy.addToStudyInFather( Plaque, BORD, 'BORD' ) ###
Vertex_9 = geompy.MakeVertex(C_GDL_h+C_MPL_h+C_CL_h+Mem_h, 0, 0) Vertex_10 = geompy.MakeVertex(C_GDL_h+C_MPL_h+C_CL_h+Mem_h, width, 0) Vertex_11 = geompy.MakeVertex(C_GDL_h+C_MPL_h+C_CL_h+Mem_h+A_CL_h, width, 0) Vertex_12 = geompy.MakeVertex(C_GDL_h+C_MPL_h+C_CL_h+Mem_h+A_CL_h, 0, 0) Vertex_13 = geompy.MakeVertex(C_GDL_h+C_MPL_h+C_CL_h+Mem_h+A_CL_h+A_MPL_h, 0, 0) Vertex_14 = geompy.MakeVertex(C_GDL_h+C_MPL_h+C_CL_h+Mem_h+A_CL_h+A_MPL_h, width, 0) Vertex_15 = geompy.MakeVertex(C_GDL_h+C_MPL_h+C_CL_h+Mem_h+A_CL_h+A_MPL_h+A_GDL_h, width, 0) Vertex_16 = geompy.MakeVertex(C_GDL_h+C_MPL_h+C_CL_h+Mem_h+A_CL_h+A_MPL_h+A_GDL_h, 0, 0) Quadrangle_Face_1 = geompy.MakeQuad4Vertices(Vertex_1, Vertex_2, Vertex_3, Vertex_4) Quadrangle_Face_2 = geompy.MakeQuad4Vertices(Vertex_3, Vertex_4, Vertex_5, Vertex_6) Quadrangle_Face_3 = geompy.MakeQuad4Vertices(Vertex_5, Vertex_6, Vertex_7, Vertex_8) Quadrangle_Face_4 = geompy.MakeQuad4Vertices(Vertex_7, Vertex_8, Vertex_9, Vertex_10) Quadrangle_Face_5 = geompy.MakeQuad4Vertices(Vertex_9, Vertex_10, Vertex_11, Vertex_12) Quadrangle_Face_6 = geompy.MakeQuad4Vertices(Vertex_11, Vertex_12, Vertex_13, Vertex_14) Quadrangle_Face_7 = geompy.MakeQuad4Vertices(Vertex_13, Vertex_14, Vertex_15, Vertex_16) geompy.addToStudy( Vertex_1, 'Vertex_1' ) geompy.addToStudy( Vertex_2, 'Vertex_2' ) geompy.addToStudy( Vertex_3, 'Vertex_3' ) geompy.addToStudy( Vertex_4, 'Vertex_4' ) geompy.addToStudy( Vertex_5, 'Vertex_5' ) geompy.addToStudy( Vertex_6, 'Vertex_6' ) geompy.addToStudy( Vertex_7, 'Vertex_7' ) geompy.addToStudy( Vertex_8, 'Vertex_8' ) geompy.addToStudy( Vertex_9, 'Vertex_9' ) geompy.addToStudy( Vertex_10, 'Vertex_10' ) geompy.addToStudy( Vertex_11, 'Vertex_11' ) geompy.addToStudy( Vertex_12, 'Vertex_12' ) geompy.addToStudy( Vertex_13, 'Vertex_13' ) geompy.addToStudy( Vertex_14, 'Vertex_14' ) geompy.addToStudy( Vertex_15, 'Vertex_15' ) geompy.addToStudy( Vertex_16, 'Vertex_16' )
# Script for computational geometry processing in the programme Salome # Open file "geometrySalome.hdf", then "File->Load Script" import geompy import salome import smesh gg = salome.ImportComponentGUI("GEOM") box = salome.myStudy.FindObjectByPath("/Geometry/box_tmp").GetObject() air = salome.myStudy.FindObjectByPath("/Geometry/air_tmp").GetObject() # cuts "air" from "box" box = geompy.MakeCut(box, air) # add objects in the study id_box = geompy.addToStudy(box, "box") # display the results gg.createAndDisplayGO(id_box) gg.setDisplayMode(id_box, 2) solids = [ 'substrate', 'container', 'target', 'wire', 'space', 'magnet1', 'magnet2', 'ring' ] # function cuts all objects from from "air" for solid in solids: object0 = salome.myStudy.FindObjectByPath("/Geometry/" + solid).GetObject() air = geompy.MakeCut(air, object0) id_air = geompy.addToStudy(air, "air")
import geompy import math # global coordinate system OO = geompy.MakeVertex(0, 0, 0) Ox = geompy.MakeVectorDXDYDZ(1, 0, 0) Oy = geompy.MakeVectorDXDYDZ(0, 1, 0) Oz = geompy.MakeVectorDXDYDZ(0, 0, 1) global_CS = geompy.MakeMarker(0,0,0, 1,0,0, 0,1,0) # OO, Ox, Oy Oxy = geompy.MakeVectorDXDYDZ(1, 1, 0) pln_YOZ = geompy.MakePlane(OO, Ox, 200.0) pln_Oxy = geompy.MakePlane(OO, Oxy, 200.0) geompy.addToStudy(OO, "OO" ) geompy.addToStudy(Ox, "Ox" ) geompy.addToStudy(Oy, "Oy" ) geompy.addToStudy(Oz, "Oz" ) geompy.addToStudy(global_CS, "global_CS" ) geompy.addToStudy(Oxy, "Oxy" ) geompy.addToStudy(pln_YOZ, "pln_YOZ" ) geompy.addToStudy(pln_Oxy, "pln_Oxy" ) # tower parameters thickness = 10.0 # thickness of tower walls size_arc = 30.0 # size of lower arc block along front size_corner = 40.0 # size of corner block along front # tower wall angle
# Script for computational geometry processing in the programme Salome # Open file "geometrySalome.hdf", then "File->Load Script" import geompy import salome import smesh gg = salome.ImportComponentGUI("GEOM") box = salome.myStudy.FindObjectByPath("/Geometry/box_tmp").GetObject() air = salome.myStudy.FindObjectByPath("/Geometry/air_tmp").GetObject() # cuts "air" from "box" box = geompy.MakeCut(box, air) # add objects in the study id_box = geompy.addToStudy(box, "box") # display the results gg.createAndDisplayGO(id_box) gg.setDisplayMode(id_box,2) solids = ['substrate', 'container', 'target', 'wire', 'space', 'magnet1', 'magnet2', 'ring'] # function cuts all objects from from "air" for solid in solids: object0 = salome.myStudy.FindObjectByPath("/Geometry/"+solid).GetObject() air = geompy.MakeCut(air, object0) id_air = geompy.addToStudy(air, "air") # display the results gg.createAndDisplayGO(id_air)
Ligne_4 = geompy.MakeLineTwoPnt(Sommet_12, Sommet_13) Arc_1 = geompy.MakeArcCenter(Sommet_9, Sommet_8, Sommet_15,False) Arc_2 = geompy.MakeArcCenter(Sommet_9, Sommet_15, Sommet_10,False) Arc_3 = geompy.MakeArcCenter(Sommet_10, Sommet_11, Sommet_16,False) Arc_4 = geompy.MakeArcCenter(Sommet_10, Sommet_16, Sommet_12,False) Arc_5 = geompy.MakeArcCenter(Sommet_1, Sommet_3, Sommet_4,False) Arc_6 = geompy.MakeArcCenter(Sommet_1, Sommet_4, Sommet_5,False) Arc_7 = geompy.MakeArcCenter(Sommet_1, Sommet_5, Sommet_6,False) Arc_8 = geompy.MakeArcCenter(Sommet_1, Sommet_6, Sommet_3,False) Arc_9 = geompy.MakeArcCenter(Sommet_1, Sommet_13, Sommet_14,False) Arc_10 = geompy.MakeArcCenter(Sommet_1, Sommet_14, Sommet_2,False) Crochet = geompy.MakeFaceWires([Ligne_1, Ligne_2, Ligne_3, Ligne_4, Arc_1, Arc_2, Arc_3, Arc_4, Arc_5, Arc_6, Arc_7, Arc_8, Arc_9, Arc_10], 1) geompy.addToStudy( O, 'O' ) geompy.addToStudy( OX, 'OX' ) geompy.addToStudy( OY, 'OY' ) geompy.addToStudy( OZ, 'OZ' ) geompy.addToStudy( Sommet_1, 'Sommet_1' ) geompy.addToStudy( Sommet_2, 'Sommet_2' ) geompy.addToStudy( Sommet_3, 'Sommet_3' ) geompy.addToStudy( Sommet_4, 'Sommet_4' ) geompy.addToStudy( Sommet_5, 'Sommet_5' ) geompy.addToStudy( Sommet_6, 'Sommet_6' ) geompy.addToStudy( Sommet_7, 'Sommet_7' ) geompy.addToStudy( Sommet_8, 'Sommet_8' ) geompy.addToStudy( Sommet_9, 'Sommet_9' ) geompy.addToStudy( Sommet_10, 'Sommet_10' ) geompy.addToStudy( Sommet_11, 'Sommet_11' ) geompy.addToStudy( Sommet_12, 'Sommet_12' )
merge_quads(doc, grille_cyl_quart, grille_cyl_demi, 8 - ni1, 2, nr2, ni1, OPT_QUAD_IK) pass merge_quads(doc, grille_cyl_quart, grille_cyl_demi, 3, 1, nr2, 6) merge_quads(doc, grille_cyl_quart, grille_cyl_demi, 3, 0, nr2, 7) # temporaire : sauvegarde du modele de blocs : save_schema(doc) # fin temporaire ########### # Geometry ########### bride_geom = geompy.ImportFile(BREP_PATH, "BREP") geompy.addToStudy(bride_geom, "bride_geom") # parametres de la geometrie : r1 = 12.0 r1_t = 7.88 r2 = 20.0 r2_t = 2.0 ############## # Association ############## # association vertex/points de la grille 1 # (tous les vertex qui ne sont pas fusionnes avec ceux de la grille #
import geompy import salome gg = salome.ImportComponentGUI("GEOM") #creamos dos vertices y un vector #p1 = geompy.MakeVertex(35, 40, 45) #p2 = geompy.MakeVertex(35, 45, 70) #v = geompy.MakeVector(p1, p2) #creamos los toroides #torus1 = geompy.MakeTorus(p1, v, 20, 10) torus2 = geompy.MakeTorusRR(300, 150) #agregamos los objetos al estudio id_torus1 = geompy.addToStudy(torus1, "Torus1") id_torus2 = geompy.addToStudy(torus2, "Torus2") #dibujamos los toroides gg.createAndDisplayGO(id_torus1) gg.setDisplayMode(id_torus1, 1) gg.createAndDisplayGO(id_torus2) gg.setDisplayMode(id_torus2, 1)
XYZ_Frame_point=[XYZ_Frame_1, XYZ_Frame_2,XYZ_Frame_3, XYZ_Frame_4, XYZ_Frame_5, XYZ_Frame_6, XYZ_Frame_7, XYZ_Frame_8, XYZ_Frame_9, XYZ_Frame_10, XYZ_Frame_11, XYZ_Frame_12, XYZ_Frame_13, XYZ_Frame_14, XYZ_Frame_15] Vertex=[] num_vertex=0 for i in range(len(XYZ_Frame_point)): list_curve=[] j_max= len(XYZ_Frame_point[i]) for j in range(j_max): #Build j-th vertex for i-th frame Vertex_j = geompy.MakeVertex(XYZ_Frame_point [i][j][0], XYZ_Frame_point [i][j][1], XYZ_Frame_point [i][j][2]) Vertex.append(Vertex_j) list_curve.append(Vertex[j+num_vertex]) #Build i-th frame curve curve_i = geompy.MakeInterpol(list_curve) Curve.append(curve_i) num_vertex=num_vertex+j_max geompy.addToStudy( Curve[i], "Curve") Curve.append(Aft) #Build shell for a half of the ship hull shell = geompy.MakeThruSections(Curve, theModeSolid=0, thePreci = 0.0001, theRuled=1) Vector_1 = geompy.MakeVectorDXDYDZ(0, 1, 0) Plane_1 = geompy.MakePlane(Vertex_Aft2, Vector_1, 300) #Build symmetry shell to model the full ship hull using mirror through plane Oxz Mirror_1 = geompy.MakeMirrorByPlane(shell, Plane_1) Full_shell = geompy.MakeCompound([shell, Mirror_1]) geompy.addToStudy( shell, " shell") geompy.addToStudy(Full_shell, "Full_shell") if geompy.salome.sg.hasDesktop(): geompy.salome.sg.updateObjBrowser(1) #Mesh creation: #Wire discretisation; Nb.Segments=14
Ligne_1_vertex_2 = geompy.GetSubShape(Ligne_1, [2]) Cercle_1 = geompy.MakeCircle(Ligne_1_vertex_2, Ligne_1, 70) Ligne_5_vertex_2 = geompy.GetSubShape(Ligne_5, [2]) Cercle_2 = geompy.MakeCircle(Ligne_5_vertex_2, Ligne_5, 40) Ligne_4_vertex_2 = geompy.GetSubShape(Ligne_4, [2]) Cercle_3 = geompy.MakeCircle(Ligne_4_vertex_2, Ligne_4, 50) Contour_1 = geompy.MakeWire([Ligne_1, Ligne_2, Ligne_3], 1e-07) Tuyau_1 = geompy.MakePipe(Cercle_1, Contour_1) Tuyau_2 = geompy.MakePipe(Cercle_2, Ligne_5) Tuyau_3 = geompy.MakePipe(Cercle_3, Ligne_4) Partition_1 = geompy.MakePartition([Tuyau_1], [Tuyau_2, Tuyau_3], [], [], geompy.ShapeType["SHELL"], 0, [], 0) [joint,Partition_2,Face_2,Face_1,Face_5,Face_6,Face_7] = geompy.ExtractShapes(Partition_1, geompy.ShapeType["FACE"], True) Partition_2 = geompy.MakePartition([Tuyau_2, Tuyau_3], [Partition_1], [], [], geompy.ShapeType["SHELL"], 0, [], 0) [Face_1,Face_2,joint,geomObj_1] = geompy.ExtractShapes(Partition_2, geompy.ShapeType["FACE"], True) joint = geompy.MakeCompound([Face_5, Face_6, Face_7, Face_1, Face_2]) geompy.addToStudy( O, 'O' ) geompy.addToStudy( OX, 'OX' ) geompy.addToStudy( OY, 'OY' ) geompy.addToStudy( OZ, 'OZ' ) geompy.addToStudy( Sommet_1, 'Sommet_1' ) geompy.addToStudy( Sommet_2, 'Sommet_2' ) geompy.addToStudy( Sommet_3, 'Sommet_3' ) geompy.addToStudy( Sommet_4, 'Sommet_4' ) geompy.addToStudy( Sommet_5, 'Sommet_5' ) geompy.addToStudy( Sommet_6, 'Sommet_6' ) geompy.addToStudy( Ligne_1, 'Ligne_1' ) geompy.addToStudy( Ligne_2, 'Ligne_2' ) geompy.addToStudy( Ligne_3, 'Ligne_3' ) geompy.addToStudy( Ligne_4, 'Ligne_4' ) geompy.addToStudy( Ligne_5, 'Ligne_5' ) geompy.addToStudyInFather( Ligne_1, Ligne_1_vertex_2, 'Ligne_1:vertex_2' )
[geomObj_10] = geompy.SubShapeAll(Edge_4, geompy.ShapeType["EDGE"]) listSameIDs = geompy.GetSameIDs(Plaque, geomObj_3) listSameIDs = geompy.GetSameIDs(Plaque, geomObj_4) listSameIDs = geompy.GetSameIDs(Plaque, geomObj_5) listSameIDs = geompy.GetSameIDs(Plaque, geomObj_6) listSameIDs = geompy.GetSameIDs(Plaque, geomObj_9) listSameIDs = geompy.GetSameIDs(Plaque, geomObj_10) Encastre = geompy.CreateGroup(Plaque, geompy.ShapeType["EDGE"]) geompy.UnionIDs(Encastre, [9]) geomObj_11 = geompy.CreateGroup(Plaque, geompy.ShapeType["EDGE"]) geompy.UnionIDs(geomObj_11, [3]) listSameIDs = geompy.GetSameIDs(Plaque, geomObj_7) Moment = geompy.CreateGroup(Plaque, geompy.ShapeType["EDGE"]) geompy.UnionIDs(Moment, [10]) listSameIDs = geompy.GetSameIDs(Plaque, geomObj_8) geompy.addToStudy(Centre, 'Centre') geompy.addToStudy(Vertex_droite, 'Vertex_droite') geompy.addToStudy(Vertex_gauche, 'Vertex_gauche') geompy.addToStudy(Arc_1, 'Arc_1') geompy.addToStudy(centre_loin, 'centre_loin') geompy.addToStudy(Line_extrusion, 'Line_extrusion') geompy.addToStudy(Plaque, 'Plaque') geompy.addToStudyInFather(Plaque, Edge_2, 'Edge_2') geompy.addToStudyInFather(Plaque, Edge_3, 'Edge_3') geompy.addToStudyInFather(Plaque, Edge_4, 'Edge_4') geompy.addToStudyInFather(Plaque, Encastre, 'Encastre') geompy.addToStudyInFather(Plaque, Moment, 'Moment') ### Store presentation parameters of displayed objects import iparameters ipar = iparameters.IParameters(
Arriere_bas_4 = geompy.MakeLineTwoPnt(Sommet_5, Sommet_9) Arriere_haut_1 = geompy.MakeLineTwoPnt(Sommet_3, Sommet_7) Arriere_haut_2 = geompy.MakeLineTwoPnt(Sommet_3, Sommet_8) Arriere_haut_3 = geompy.MakeLineTwoPnt(Sommet_8, Sommet_10) Arriere_haut_4 = geompy.MakeLineTwoPnt(Sommet_7, Sommet_9) Renfort = geompy.MakeLineTwoPnt(Sommet_7, Sommet_8) Fourche = geompy.MakeLineTwoPnt(Sommet_2, Sommet_11) Cadre = geompy.MakeCompound([ Direction, Barre_sup, Barre_inf, Barre_selle, Fourche, Arriere_bas_1, Arriere_bas_2, Arriere_bas_3, Arriere_bas_4, Arriere_haut_1, Arriere_haut_2, Arriere_haut_3, Arriere_haut_4, Renfort ]) geompy.addToStudy(Sommet_1, 'Sommet_1') geompy.addToStudy(Sommet_2, 'Sommet_2') geompy.addToStudy(Sommet_3, 'Sommet_3') geompy.addToStudy(Sommet_4, 'Sommet_4') geompy.addToStudy(Sommet_5, 'Sommet_5') geompy.addToStudy(Sommet_6, 'Sommet_6') geompy.addToStudy(Sommet_7, 'Sommet_7') geompy.addToStudy(Sommet_8, 'Sommet_8') geompy.addToStudy(Sommet_9, 'Sommet_9') geompy.addToStudy(Sommet_10, 'Sommet_10') geompy.addToStudy(Sommet_11, 'Sommet_11') geompy.addToStudy(Direction, 'Direction') geompy.addToStudy(Barre_sup, 'Barre_sup') geompy.addToStudy(Barre_inf, 'Barre_inf') geompy.addToStudy(Barre_selle, 'Barre_selle') geompy.addToStudy(Arriere_bas_1, 'Arriere_bas_1')
## GROUP (SOLID) ################################################# # Get ID (solid) id_p1_solids = [] #initialize the array for aSolid in range(0,len(p1_solids)): id_p1_solids.append(geompy.GetSubShapeID(p1, p1_solids[aSolid])) #get the ID of the solid and add it to the array # make groups (solid) g = [] for aGroup in range(0,len(p1_solids)): g.append(geompy.CreateGroup(p1, geompy.ShapeType["SOLID"])) for aGroup in range(0,len(p1_solids)): geompy.AddObject(g[aGroup], id_p1_solids[aGroup]) # add objects in the study id_p1 = geompy.addToStudy(p1,"Part1") for aGroup in range(0,len(p1_solids)): geompy.addToStudyInFather(p1, g[aGroup], 'body{0}'.format(aGroup+1) ) ################################################# ## GROUP (FACE) # Ref : http://docs.salome-platform.org/latest/gui/GEOM/tui_working_with_groups_page.html ################################################# for aSolid in range(0,len(p1_solids)): # Get ID (surface) p1_sufaces = geompy.ExtractShapes(p1_solids[aSolid], geompy.ShapeType["FACE"],False) id_p1_sufaces = [] for aSurface in range(0,len(p1_solids)): id_p1_sufaces.append(geompy.GetSubShapeID(p1, p1_sufaces[aSurface])) # make groups (surface) gf = []
#geompy.addToStudy( inf, 'inf' ) #groupe des faces qui ont un interet grface = [] grface.append(infbase) for a in facenodeup: for b in a: grface.append(b) grfaceCompound = geompy.MakeCompound(grface) #geompy.addToStudy( grfaceCompound, 'grfaceCompound' ) #solide final globalsolid = geompy.MakePartition([Box_1], [grfaceCompound], [], [], geompy.ShapeType["SOLID"], 0, [], 1) geompy.addToStudy(globalsolid, 'globalsolid') #generation des groupes groupe = [] #EDGE #Rien #FACE #infbase groupe de face qui represente le pied de la structure grinfbase = geompy.CreateGroup(globalsolid, geompy.ShapeType["FACE"]) [geomObj_248] = geompy.SubShapeAll(infbase, geompy.ShapeType["FACE"]) geomObj_temp = geompy.GetSame(globalsolid, geomObj_248) tempid = geompy.GetSubShapeID(globalsolid, geomObj_temp) geompy.AddObject(grinfbase, tempid) geompy.addToStudyInFather(globalsolid, grinfbase, "infbase") groupe.append(grinfbase)
elif self.percentageCoverage == 100: circleCentre = geompy.MakeVertex(self.position[0],self.position[1], self.position[2] ) circle1 = geompy.MakeCircle(circleCentre, None, self.radius) circle2 = geompy.MakeCircle(circleCentre, None, self.radius + self.filmThickness) face1 = geompy.MakeFaceWires([circle1, circle2], 1) vector1 = geompy.MakeVectorDXDYDZ(0, 1, 0) circle3 = geompy.MakeCircle(circleCentre, vector1, 1) self.__ionomerPipe = geompy.MakePipe(face1, circle3) from random import randint particle = AgglomerateParticle( [randint(-5,+5),randint(-5,+5),randint(-5,+5),] , randint(1,5), 1, [randint(-5,+5),randint(-5,+5),randint(-5,+5)], randint(0,100)) particle.generateCarbonPlatinumGeometry() particle.generateFilmGeometry() geompy.addToStudy(particle.getCarbonParticle(), 'Particle') geompy.addToStudy(particle.getIonomerPipe(), 'Film') """from time import time start = time() filmOrient = [(math.pi)/2, 0, 0] radius = 1 position = [0, 0 , 0] filmThickness = 1 theta = float(math.pi/5) zetha = theta/2 +filmOrient[0] -(math.pi)/2 gamma = theta - zetha print theta ,zetha, gamma
N = 500 A = 3.1926 H = 200 # [m] a = H*AR # [m] x = linspace(0,a,N) # [m] y = - H * 1/6.04844 * ( sp.j0(A)*sp.i0(A*x/a) - sp.i0(A)*sp.j0(A*x/a) ) nPts = len(x) x = append(x,max(a*200,3600)) y = append(y,0) nPts = nPts + 1 ptList = [] print "Creating %s points"%nPts for i in range(nPts): v = geompy.MakeVertex(x[i], 0, y[i]) geompy.addToStudy(v, "Vertex_%d"%(i+1) ) ptList.append(v) print str([i,x[i],y[i],0]) print "creating polyLine" polyline = geompy.MakePolyline(ptList) #interpol = geompy.MakeInterpol(ptList) geompy.addToStudy(polyline, "polyline" ) #geompy.addToStudy(interpol, "interpol" ) print "creating revolution" Vertex_a = geompy.MakeVertex(0, 0, 0) Vertex_b = geompy.MakeVertex(0, 0, H) Line_1 = geompy.MakeLineTwoPnt(Vertex_a, Vertex_b) Revolution_1 = geompy.MakeRevolution(polyline, Line_1, 360*math.pi/180.0) newName = "Martinez3D_h_" + str(H) + "_AR_" + str(AR)
Arc_2 = geompy.MakeArcCenter(Sommet_9, Sommet_15, Sommet_10, False) Arc_3 = geompy.MakeArcCenter(Sommet_10, Sommet_11, Sommet_16, False) Arc_4 = geompy.MakeArcCenter(Sommet_10, Sommet_16, Sommet_12, False) Arc_5 = geompy.MakeArcCenter(Sommet_1, Sommet_3, Sommet_4, False) Arc_6 = geompy.MakeArcCenter(Sommet_1, Sommet_4, Sommet_5, False) Arc_7 = geompy.MakeArcCenter(Sommet_1, Sommet_5, Sommet_6, False) Arc_8 = geompy.MakeArcCenter(Sommet_1, Sommet_6, Sommet_3, False) Arc_9 = geompy.MakeArcCenter(Sommet_1, Sommet_13, Sommet_14, False) Arc_10 = geompy.MakeArcCenter(Sommet_1, Sommet_14, Sommet_2, False) Crochet = geompy.MakeFaceWires([ Ligne_1, Ligne_2, Ligne_3, Ligne_4, Arc_1, Arc_2, Arc_3, Arc_4, Arc_5, Arc_6, Arc_7, Arc_8, Arc_9, Arc_10 ], 1) geompy.addToStudy(O, 'O') geompy.addToStudy(OX, 'OX') geompy.addToStudy(OY, 'OY') geompy.addToStudy(OZ, 'OZ') geompy.addToStudy(Sommet_1, 'Sommet_1') geompy.addToStudy(Sommet_2, 'Sommet_2') geompy.addToStudy(Sommet_3, 'Sommet_3') geompy.addToStudy(Sommet_4, 'Sommet_4') geompy.addToStudy(Sommet_5, 'Sommet_5') geompy.addToStudy(Sommet_6, 'Sommet_6') geompy.addToStudy(Sommet_7, 'Sommet_7') geompy.addToStudy(Sommet_8, 'Sommet_8') geompy.addToStudy(Sommet_9, 'Sommet_9') geompy.addToStudy(Sommet_10, 'Sommet_10') geompy.addToStudy(Sommet_11, 'Sommet_11') geompy.addToStudy(Sommet_12, 'Sommet_12')
def createMesh(): L=0.1 H=0.08 T=0.006 R=0.048 R1=0.0385 Vertex_1 = geompy.MakeVertex(0, -L, 0) Vertex_2 = geompy.MakeVertex(0, 0, 0) Vector_y = geompy.MakeVectorDXDYDZ(0, 1, 0) Vector_z = geompy.MakeVectorDXDYDZ(0, 0, 1) Cylinder_1 = geompy.MakeCylinder(Vertex_1, Vector_y, R, 2*L) Cylinder_2 = geompy.MakeCylinder(Vertex_2, Vector_z, R1, H) Fuse_1 = geompy.MakeFuse(Cylinder_1, Cylinder_2) [Face_1,Face_2,Face_3,Face_4,Face_5] = geompy.SubShapeAllSorted(Fuse_1, geompy.ShapeType["FACE"]) #[Edge_1,Edge_2,Edge_3,Edge_4,Edge_5,Edge_6,Edge_7,Edge_8,Edge_9,Edge_10] = geompy.SubShapeAllSorted(Fuse_1, geompy.ShapeType["EDGE"]) geompy.addToStudy( Vertex_1, "Vertex_1" ) geompy.addToStudy( Vertex_2, "Vertex_2" ) geompy.addToStudy( Vector_y, "Vector_y" ) geompy.addToStudy( Vector_z, "Vector_z" ) geompy.addToStudy( Cylinder_1, "Cylinder_1" ) geompy.addToStudy( Cylinder_2, "Cylinder_2" ) geompy.addToStudy( Fuse_1, "Fuse_1" ) geompy.addToStudyInFather( Fuse_1, Face_1, "Face_1" ) geompy.addToStudyInFather( Fuse_1, Face_2, "Face_2" ) geompy.addToStudyInFather( Fuse_1, Face_3, "Face_3" ) geompy.addToStudyInFather( Fuse_1, Face_4, "Face_4" ) geompy.addToStudyInFather( Fuse_1, Face_5, "Face_5" ) NETGEN_3D_Parameters = smesh.smesh.CreateHypothesis('NETGEN_Parameters', 'NETGENEngine') NETGEN_3D_Parameters.SetMaxSize( 0.005 ) NETGEN_3D_Parameters.SetSecondOrder( 0 ) NETGEN_3D_Parameters.SetOptimize( 1 ) NETGEN_3D_Parameters.SetFineness( 3 ) Mesh_1 = smesh.Mesh(Fuse_1) status = Mesh_1.AddHypothesis(NETGEN_3D_Parameters) Netgen_1D_2D_3D = smesh.smesh.CreateHypothesis('NETGEN_2D3D', 'NETGENEngine') status = Mesh_1.AddHypothesis(Netgen_1D_2D_3D) isDone = Mesh_1.Compute() # create groups for boundaries Faces=[Face_1] inlet_F = group_create(Mesh_1.GetMesh(),Faces,"inlet_F") Faces=[Face_5] outlet_F1 = group_create(Mesh_1.GetMesh(),Faces,"outlet_F1") Faces=[Face_3] outlet_F2 = group_create(Mesh_1.GetMesh(),Faces,"outlet_F2") Faces=[ Face_2, Face_4] pipe = group_create(Mesh_1.GetMesh(),Faces,"pipe") return [Mesh_1,[inlet_F,outlet_F1,outlet_F2,pipe]]
# definition du point haut pour encastrement listSubShapeIDs = geompy.SubShapeAllIDs(Anneau, geompy.ShapeType["VERTEX"]) listSubShapeIDs = geompy.SubShapeAllIDs(Anneau, geompy.ShapeType["VERTEX"]) listSameIDs = geompy.GetSameIDs(Anneau, geomObj_1) Haut = geompy.CreateGroup(Anneau, geompy.ShapeType["VERTEX"]) geompy.UnionIDs(Haut, [3]) # definition du point bas pour application de la force listSameIDs = geompy.GetSameIDs(Anneau, geomObj_2) listSameIDs = geompy.GetSameIDs(Anneau, geomObj_3) Bas = geompy.CreateGroup(Anneau, geompy.ShapeType["VERTEX"]) geompy.UnionIDs(Bas, [6]) listSameIDs = geompy.GetSameIDs(Anneau, geomObj_4) geompy.addToStudy(Sommet_1, 'Sommet_1') geompy.addToStudy(Sommet_2, 'Sommet_2') geompy.addToStudy(Sommet_3, 'Sommet_3') geompy.addToStudy(Sommet_4, 'Sommet_4') geompy.addToStudy(Arc_1, 'Arc_1') geompy.addToStudy(Ligne_1, 'Ligne_1') geompy.addToStudy(Anneau, 'Anneau') geompy.addToStudyInFather(Anneau, Haut, 'Haut') geompy.addToStudyInFather(Anneau, Bas, 'Bas') ### Store presentation parameters of displayed objects import iparameters ipar = iparameters.IParameters( theStudy.GetModuleParameters("Interface Applicative", "GEOM", 1)) #Set up entries:
Face_2 = geompy.MakeFaceWires([Ligne_3, Ligne_5, Ligne_6, Ligne_7], 1) Plaque = geompy.MakeCompound([Face_1, Face_2]) Sym = geompy.CreateGroup(Plaque, geompy.ShapeType["EDGE"]) geompy.UnionIDs(Sym, [4]) gauche = geompy.CreateGroup(Plaque, geompy.ShapeType["EDGE"]) geompy.UnionIDs(gauche, [7]) droite = geompy.CreateGroup(Plaque, geompy.ShapeType["EDGE"]) geompy.UnionIDs(droite, [11]) Fin = geompy.CreateGroup(Plaque, geompy.ShapeType["FACE"]) geompy.UnionIDs(Fin, [2]) centre = geompy.CreateGroup(Plaque, geompy.ShapeType["EDGE"]) geompy.UnionIDs(centre, [4, 9]) ext = geompy.CreateGroup(Plaque, geompy.ShapeType["EDGE"]) geompy.UnionIDs(ext, [19]) geompy.addToStudy(O, 'O') geompy.addToStudy(OX, 'OX') geompy.addToStudy(OY, 'OY') geompy.addToStudy(OZ, 'OZ') geompy.addToStudy(Sommet_1, 'Sommet_1') geompy.addToStudy(Sommet_2, 'Sommet_2') geompy.addToStudy(Sommet_3, 'Sommet_3') geompy.addToStudy(Sommet_4, 'Sommet_4') geompy.addToStudy(Sommet_5, 'Sommet_5') geompy.addToStudy(Sommet_6, 'Sommet_6') geompy.addToStudy(Ligne_1, 'Ligne_1') geompy.addToStudy(Ligne_2, 'Ligne_2') geompy.addToStudy(Ligne_3, 'Ligne_3') geompy.addToStudy(Ligne_4, 'Ligne_4') geompy.addToStudy(Ligne_5, 'Ligne_5')
import geompy import smesh, SMESH def update_screen(): if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(True) ## Geometry part ## salome.salome_init() geompy.init_geom(salome.myStudy) cooler = geompy.MakeBoxDXDYDZ(30, 20, 70) group = geompy.CreateGroup(cooler, geompy.ShapeType["FACE"]) geompy.addToStudy(cooler, 'cooler') groups = [] counter = 0 for each_face in geompy.SubShapeAllSortedCentres(cooler, geompy.ShapeType["FACE"]): groups.append(geompy.CreateGroup(cooler, geompy.ShapeType["FACE"])) geompy.AddObject(groups[counter], geompy.GetSubShapeID(cooler, each_face)) geompy.addToStudyInFather(cooler, groups[counter], 'face_' + str(counter + 1)) counter += 1 update_screen() ## Mesh part ## smesh.SetCurrentStudy(salome.myStudy)
Sommets += Sp Lignes += Lp #p1.addEvenlySpacedJoint(100.,10,50.) #p1.addJoint(0.05) #p1.build() O = geompy.MakeVertex(0, 0, 0) OX = geompy.MakeVectorDXDYDZ(1, 0, 0) OY = geompy.MakeVectorDXDYDZ(0, 1, 0) OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) for i,somm in enumerate(Sommets): geompy.addToStudy( Sommets[i], 'Sommet_'+str(i+1) ) for i,ligne in enumerate(Lignes): geompy.addToStudy(Lignes[i],'Ligne_'+str(i+1)) # On definit des assemblages a partir des lignes # pour affecter chacune des caracteristiques elementaires # aux poutres PoutreSW=geompy.MakeCompound(p1.entities()[1]) PoutreSE=geompy.MakeCompound(p2.entities()[1]) PoutreNE=geompy.MakeCompound(p3.entities()[1]) PoutreNW=geompy.MakeCompound(p4.entities()[1]) tirs=[] for t in tir11+tir12+tir21+tir22+tir31+tir32+tir41+tir42: tirs+=t.entities()[1]
# Get ID (solid) id_p1_solids = [] #initialize the array for aSolid in range(0, len(p1_solids)): id_p1_solids.append(geompy.GetSubShapeID( p1, p1_solids[aSolid])) #get the ID of the solid and add it to the array # make groups (solid) g = [] for aGroup in range(0, len(p1_solids)): g.append(geompy.CreateGroup(p1, geompy.ShapeType["SOLID"])) for aGroup in range(0, len(p1_solids)): geompy.AddObject(g[aGroup], id_p1_solids[aGroup]) # add objects in the study id_p1 = geompy.addToStudy(p1, "Part1") for aGroup in range(0, len(p1_solids)): geompy.addToStudyInFather(p1, g[aGroup], 'body{0}'.format(aGroup + 1)) ################################################# ## GROUP (FACE) # Ref : http://docs.salome-platform.org/latest/gui/GEOM/tui_working_with_groups_page.html ################################################# for aSolid in range(0, len(p1_solids)): # Get ID (surface) p1_sufaces = geompy.ExtractShapes(p1_solids[aSolid], geompy.ShapeType["FACE"], False) id_p1_sufaces = [] for aSurface in range(0, len(p1_solids)): id_p1_sufaces.append(geompy.GetSubShapeID(p1, p1_sufaces[aSurface])) # make groups (surface)