print "Test Export/Import ...",
+ tmpDir = os.getenv("TEMP")
+ if tmpDir == None:
+ tmpDir = "/tmp"
+
# Files for Export/Import testing
- fileExportImport = "/tmp/testExportImport.brep"
- fileExportImportBREP = "/tmp/testExportImportBREP.brep"
- fileExportImportIGES = "/tmp/testExportImportIGES.iges"
- fileExportImportSTEP = "/tmp/testExportImportSTEP.step"
+ fileExportImport = tmpDir + "/testExportImport.brep"
+ fileExportImportBREP = tmpDir + "/testExportImportBREP.brep"
+ fileExportImportIGES = tmpDir + "/testExportImportIGES.iges"
+ fileExportImportSTEP = tmpDir + "/testExportImportSTEP.step"
if os.access(fileExportImport, os.F_OK):
if os.access(fileExportImport, os.W_OK):
os.remove(fileExportImport)
else:
- fileExportImport = "/tmp/testExportImport1.brep"
+ fileExportImport = tmpDir + "/testExportImport1.brep"
if os.access(fileExportImportBREP, os.W_OK):
os.remove(fileExportImportBREP)
else:
- fileExportImportBREP = "/tmp/testExportImportBREP1.brep"
+ fileExportImportBREP = tmpDir + "/testExportImportBREP1.brep"
if os.access(fileExportImportIGES, os.W_OK):
os.remove(fileExportImportIGES)
else:
- fileExportImportIGES = "/tmp/testExportImportIGES1.iges"
+ fileExportImportIGES = tmpDir + "/testExportImportIGES1.iges"
if os.access(fileExportImportSTEP, os.W_OK):
os.remove(fileExportImportSTEP)
else:
- fileExportImportSTEP = "/tmp/testExportImportSTEP1.step"
+ fileExportImportSTEP = tmpDir + "/testExportImportSTEP1.step"
# Export
geompy.Export(shape, fileExportImport, "BREP")
p100 = geompy.MakeVertex(100, 100, 100)
p300 = geompy.MakeVertex(300, 300, 300)
Box1 = geompy.MakeBoxTwoPnt(p100, p300)
- Partition = geompy.Partition([Box], [Box1], [], [Box])
+ #Partition = geompy.Partition([Box], [Box1], [], [Box])
+ Partition = geompy.Partition([Box], [Box1])
id_Partition = geompy.addToStudy(Partition, "Partition of Box by Box1")
# MakeMultiRotation1D, MakeMultiRotation2D
v_n0p = geompy.MakeVectorDXDYDZ(-1, 0, 1)
v_pp0 = geompy.MakeVectorDXDYDZ( 1, 1, 0)
v_np0 = geompy.MakeVectorDXDYDZ(-1, 1, 0)
+ v_0n0 = geompy.MakeVectorDXDYDZ( 0, -1, 0)
pln_0pp = geompy.MakePlane(p0, v_0pp, 300)
pln_0np = geompy.MakePlane(p0, v_0np, 300)
pln_pp0 = geompy.MakePlane(p0, v_pp0, 300)
pln_np0 = geompy.MakePlane(p0, v_np0, 300)
- part_tool_1 = geompy.MakePartition([b0, pln_0pp, pln_0np, pln_p0p, pln_n0p, pln_pp0, pln_np0],
- [],
- [],
- [b0])
+ #part_tool_1 = geompy.MakePartition([b0, pln_0pp, pln_0np, pln_p0p, pln_n0p, pln_pp0, pln_np0],
+ # [],
+ # [],
+ # [b0])
+ part_tool_1 = geompy.MakePartition([b0, pln_0pp, pln_0np, pln_p0p, pln_n0p, pln_pp0, pln_np0])
+
+ id_part_tool_1 = geompy.addToStudy(part_tool_1, "part_tool_1")
pt_pnt_1 = geompy.MakeVertex( 55, 0, 55)
pt_pnt_2 = geompy.MakeVertex( 0, 55, 55)
pt_face_11 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_11)
pt_face_12 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_12)
- pt_box = geompy.GetBlockNearPoint(part_tool_1, p0)
-
- part_tool = geompy.MakeCompound([pt_face_1, pt_face_4, pt_face_7, pt_face_10,
- pt_face_2, pt_face_5, pt_face_8, pt_face_11,
- pt_face_3, pt_face_6, pt_face_9, pt_face_12, pt_box])
- id_part_tool = geompy.addToStudy(part_tool, "part_tool")
-
- part = geompy.MakePartition([s0], [part_tool])
+ #pt_box = geompy.GetBlockNearPoint(part_tool_1, p0)
+
+ #part_tool = geompy.MakeCompound([pt_face_1, pt_face_4, pt_face_7, pt_face_10,
+ # pt_face_2, pt_face_5, pt_face_8, pt_face_11,
+ # #pt_face_3, pt_face_6, pt_face_9, pt_face_12, pt_box])
+ # pt_face_3, pt_face_6, pt_face_9, pt_face_12)
+ #id_part_tool = geompy.addToStudy(part_tool, "part_tool")
+
+ #part = geompy.MakePartition([s0], [part_tool])
+ #part = geompy.MakePartition([s0], [ pt_face_1, pt_face_4, pt_face_7, pt_face_10,
+ # pt_face_2, pt_face_5, pt_face_8, pt_face_11,
+ # pt_face_3, pt_face_6, pt_face_9, pt_face_12, b0] )
+
+ p1 = geompy.MakeVertex(50, 0, 0)
+ p2 = geompy.MakeVertex(-50, 0, 0)
+ p3 = geompy.MakeVertex(0, 50, 0)
+ p4 = geompy.MakeVertex(0, -50, 0)
+ p5 = geompy.MakeVertex(0, 0, 50)
+ p6 = geompy.MakeVertex(0, 0, -50)
+
+ vx = geompy.MakeVectorDXDYDZ( 1, 0, 0)
+ vy = geompy.MakeVectorDXDYDZ( 0, 1, 0)
+ vz = geompy.MakeVectorDXDYDZ( 0, 0, 1)
+
+ plnX1 = geompy.MakePlane(p1, vx, 300)
+ plnX2 = geompy.MakePlane(p2, vx, 300)
+ plnY1 = geompy.MakePlane(p3, vy, 300)
+ plnY2 = geompy.MakePlane(p4, vy, 300)
+ plnZ1 = geompy.MakePlane(p5, vz, 300)
+ plnZ2 = geompy.MakePlane(p6, vz, 300)
+
+ #part = geompy.MakePartition([s0], [plnX1,plnX2,plnY1,plnY2,plnZ1,plnZ2])
+ part = geompy.MakePartition([s0], [plnX1])
+ part = geompy.MakePartition([part], [plnX2])
+ part = geompy.MakePartition([part], [plnY1])
+ part = geompy.MakePartition([part], [plnY2])
+ part = geompy.MakePartition([part], [plnZ1])
+ part = geompy.MakePartition([part], [plnZ2])
geompy.addToStudy(part, "part")
# GetFreeFacesIDs
geompy.UnionIDs(faces_above, faces_above_pln_ids)
geompy.addToStudy(faces_above, "Group of faces above Plane (N = (0, 1, 1))")
+ # GetShapesOnPlaneWithLocation
+ Loc = geompy.MakeVertex(0, -50, 0)
+ edges_on_pln = geompy.GetShapesOnPlaneWithLocation(blocksComp, geompy.ShapeType["EDGE"],
+ v_0n0, Loc, geompy.GEOM.ST_ON)
+ for edge_i in edges_on_pln:
+ geompy.addToStudy(edge_i, "Edge on Plane (N = (0, -1, 0) & Location = (0, -50, 0)")
+
+ # GetShapesOnPlaneWithLocationIDs
+ edges_on_pln_ids = geompy.GetShapesOnPlaneWithLocationIDs(blocksComp, geompy.ShapeType["EDGE"],
+ v_0n0, Loc, geompy.GEOM.ST_ON)
+ group_edges_on_pln = geompy.CreateGroup(blocksComp, geompy.ShapeType["EDGE"])
+ geompy.UnionIDs(group_edges_on_pln, edges_on_pln_ids)
+ geompy.addToStudy(group_edges_on_pln, "Group of edges on Plane (N = (0, -1, 0) & Location = (0, -50, 0))")
+
# GetShapesOnCylinder
edges_out_cyl = geompy.GetShapesOnCylinder(blocksComp, geompy.ShapeType["EDGE"],
vy, 55, geompy.GEOM.ST_OUT)
geompy.UnionIDs(vertices_on_quad, vertices_on_quad_ids)
geompy.addToStudy(vertices_on_quad, "Group of vertices on Quadrangle F12")
- # GetInPlace(theShapeWhere, theShapeWhat)
+ # Prepare arguments for GetInPlace and GetInPlaceByHistory
box5 = geompy.MakeBoxDXDYDZ(100, 100, 100)
box6 = geompy.MakeTranslation(box5, 50, 50, 0)
+ geompy.addToStudy(box5, "Box 5")
+ geompy.addToStudy(box6, "Box 6")
+
+ part = geompy.MakePartition([box5], [box6])
+ geompy.addToStudy(part, "Partitioned")
+
+ box5_faces = geompy.SubShapeAll(box5, geompy.ShapeType["FACE"])
+ box6_faces = geompy.SubShapeAll(box6, geompy.ShapeType["FACE"])
+
+ ifa = 1
+ for aface in box5_faces:
+ geompy.addToStudyInFather(box5, aface, "Face" + `ifa`)
+ ifa = ifa + 1
+
+ ifa = 1
+ for aface in box6_faces:
+ geompy.addToStudyInFather(box6, aface, "Face" + `ifa`)
+ ifa = ifa + 1
+
+ # GetInPlace(theShapeWhere, theShapeWhat)
+ ibb = 5
+ faces_list = [box5_faces, box6_faces]
+ for afaces in faces_list:
+ ifa = 1
+ for aface in afaces:
+ if ibb == 6 and (ifa == 2 or ifa == 4):
+ # use IDL interface directly to avoid error message appearence in Python console
+ refl_box_face = geompy.ShapesOp.GetInPlace(part, aface)
+ if refl_box_face is not None:
+ geompy.addToStudyInFather(part, refl_box_face,
+ "Reflection of face " + `ifa` + " of box " + `ibb`)
+ error = "Result of GetInPlace must be NULL for face " + `ifa` + " of box " + `ibb`
+ raise RuntimeError, error
+ else:
+ # use geompy interface
+ refl_box_face = geompy.GetInPlace(part, aface)
+ geompy.addToStudyInFather(part, refl_box_face,
+ "Reflection of face " + `ifa` + " of box " + `ibb`)
+ ifa = ifa + 1
+ ibb = ibb + 1
+
+ # GetInPlaceByHistory(theShapeWhere, theShapeWhat)
part = geompy.MakePartition([box5], [box6])
geompy.addToStudy(part, "Partitioned")
ibb = 5
- box_list = [box5, box6]
- for abox in box_list:
- geompy.addToStudy(abox, "Box " + `ibb`)
- box_faces = geompy.SubShapeAll(abox, geompy.ShapeType["FACE"])
+ faces_list = [box5_faces, box6_faces]
+ for afaces in faces_list:
ifa = 1
- for aface in box_faces:
- geompy.addToStudyInFather(abox, aface, "Face" + `ifa`)
- refl_box_face = geompy.GetInPlace(part, aface)
- if refl_box_face is not None:
+ for aface in afaces:
+ if ibb == 6 and (ifa == 2 or ifa == 4):
+ # use IDL interface directly to avoid error message appearence in Python console
+ refl_box_face = geompy.ShapesOp.GetInPlaceByHistory(part, aface)
+ if refl_box_face is not None:
+ geompy.addToStudyInFather(part, refl_box_face,
+ "Reflection of face " + `ifa` + " of box " + `ibb` + " (by history)")
+ error = "Result of GetInPlaceByHistory must be NULL for face " + `ifa` + " of box " + `ibb`
+ raise RuntimeError, error
+ else:
+ # use geompy interface
+ refl_box_face = geompy.GetInPlaceByHistory(part, aface)
geompy.addToStudyInFather(part, refl_box_face,
- "Reflection of Face " + `ifa` + " of box " + `ibb`)
+ "Reflection of face " + `ifa` + " of box " + `ibb` + " (by history)")
ifa = ifa + 1
ibb = ibb + 1