|
| 1 | +##Copyright 2023 Thomas Paviot (tpaviot@gmail.com) |
| 2 | +## |
| 3 | +##This file is part of pythonOCC. |
| 4 | +## |
| 5 | +##pythonOCC is free software: you can redistribute it and/or modify |
| 6 | +##it under the terms of the GNU Lesser General Public License as published by |
| 7 | +##the Free Software Foundation, either version 3 of the License, or |
| 8 | +##(at your option) any later version. |
| 9 | +## |
| 10 | +##pythonOCC is distributed in the hope that it will be useful, |
| 11 | +##but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | +##GNU Lesser General Public License for more details. |
| 14 | +## |
| 15 | +##You should have received a copy of the GNU Lesser General Public License |
| 16 | +##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>. |
| 17 | + |
| 18 | +from OCC.Core.TDocStd import TDocStd_Document |
| 19 | +from OCC.Core.Message import Message_ProgressRange |
| 20 | +from OCC.Core.RWGltf import RWGltf_CafReader |
| 21 | +from OCC.Core.IFSelect import IFSelect_RetDone |
| 22 | + |
| 23 | +from OCC.Display.SimpleGui import init_display |
| 24 | + |
| 25 | +filename = "../assets/models/2CylinderEngine.glb" |
| 26 | + |
| 27 | +# create an handle to a document |
| 28 | +doc = TDocStd_Document("pythonocc-doc") |
| 29 | + |
| 30 | +gltf_reader = RWGltf_CafReader() |
| 31 | + |
| 32 | +# gltf_reader.SetSystemLengthUnit(aScaleFactorM) |
| 33 | +# gltf_reader.SetSystemCoordinateSystem(RWMesh_CoordinateSystem_Zup) |
| 34 | +gltf_reader.SetDocument(doc) |
| 35 | +# gltf_reader.SetParallel(True) |
| 36 | +# gltf_reader.SetDoublePrecision(True) |
| 37 | +# gltf_reader.SetToSkipLateDataLoading(True) |
| 38 | +# gltf_reader.SetToKeepLateData(True) |
| 39 | +# gltf_reader.SetToPrintDebugMessages(True) |
| 40 | +# gltf_reader.SetLoadAllScenes(True) |
| 41 | +status = gltf_reader.Perform(filename, Message_ProgressRange()) |
| 42 | + |
| 43 | +assert status == IFSelect_RetDone |
| 44 | + |
| 45 | +shp = gltf_reader.SingleShape() |
| 46 | + |
| 47 | +# |
| 48 | +# Display |
| 49 | +# |
| 50 | +display, start_display, add_menu, add_function_to_menu = init_display() |
| 51 | +display.DisplayShape(shp, update=True) |
| 52 | +start_display() |
0 commit comments