Ejemplo n.º 1
0
    def import_geofile(self, geofile, tol=0.1):
        # msh1, msh2, msh22, msh3, msh4, msh40, msh41, msh,
        # unv, vtk, wrl, mail, stl, p3d, mesh, bdf, cgns, med,
        # diff, ir3, inp, ply2, celum, su2, x3d, dat, neu, m, key
        geo_dir = os.path.dirname(geofile)
        geo_base = os.path.basename(geofile)
        geo_name = create_tempnum(self.rootname, self.tmpdir, ".geo")
        geo_file = os.path.basename(geo_name)
        shutil.copyfile(geofile, geo_name)
        stl_name, _ = os.path.splitext(self.tmpdir + geo_file)
        stl_name += ".stl"
        stl_name = os.path.abspath(stl_name)
        txt_name, _ = os.path.splitext(self.tmpdir + geo_file)
        txt_name += "_gmsh.txt"
        txt_name = os.path.abspath(txt_name)

        gmsh_run = self.gmsh
        gmsh_run += " -tol {:.2f}".format(tol)
        gmsh_run += " " + geo_base
        gmsh_run += " -3 -o"
        gmsh_run += " {} -format stl".format(stl_name)
        gmsh_run += " -log {}".format(txt_name)

        os.chdir(geo_dir)
        gmsh_success = os.system(gmsh_run)
        os.chdir(self.root_dir)
        return stl_name
Ejemplo n.º 2
0
 def export_brep_selected(self):
     comp = self.make_comp_selcted()
     brepname = create_tempnum(self.rootname, self.tmpdir, ".brep")
     breptools_Write(comp, brepname)
Ejemplo n.º 3
0
 def export_igs_selected(self):
     comp = self.make_comp_selcted()
     igsname = create_tempnum(self.rootname, self.tmpdir, ".stl")
     write_iges_file(comp, igsname)
Ejemplo n.º 4
0
 def export_stl_selected(self):
     comp = self.make_comp_selcted()
     stlname = create_tempnum(self.rootname, self.tmpdir, ".stl")
     write_stl_file(comp, stlname)
Ejemplo n.º 5
0
 def export_stp(self, shp):
     stpname = create_tempnum(self.rootname, self.tmpdir, ".stp")
     write_step_file(shp, stpname)
Ejemplo n.º 6
0
 def export_cap(self):
     pngname = create_tempnum(self.rootname, self.tmpdir, ".png")
     self.display.View.Dump(pngname)
Ejemplo n.º 7
0
import time
import os

from OCC.Core.gp import gp_Pnt, gp_Vec, gp_Dir
from OCC.Core.gp import gp_Ax1, gp_Ax2, gp_Ax3
from OCC.Core.gp import gp_XYZ
from OCC.Core.gp import gp_Lin

from src.base import create_tempnum
from src.model import model, model_base
from src.jsonfile import write_json

obj = model(cfgfile="./cfg/model.json")
print(obj.cfg["name"])

md0 = obj.set_model(name="surf0")
md1 = obj.set_model(name="surf1")
md2 = obj.set_model(name="surf")
md2.rim = obj.make_PolyWire(skin=None)
md3 = model_base(meta={"name": "surf3"})
md3.axs.Translate(gp_Pnt(), gp_Pnt(0, 0, 100))

meta = {}
meta["surf1"] = md1.export_dict()
meta["surf2"] = md2.export_dict()
meta["surf3"] = md3.export_dict()
write_json(create_tempnum("model", obj.tmpdir, ext=".json"), meta)

obj.display.DisplayShape(md1.rim)
obj.show()