-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathocaf_std_doc_srvcs.py
More file actions
41 lines (36 loc) · 1.52 KB
/
ocaf_std_doc_srvcs.py
File metadata and controls
41 lines (36 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
#
# Copyright 2022 Doug Blanding (dblanding@gmail.com)
#
# This file contains the PythonOCC equivalent code for the C++ code
# presented in the Open CASCADE Technology OCAF Documentation at:
# https://dev.opencascade.org/doc/overview/html/occt_user_guides__ocaf.html
#
from OCC.Core.TCollection import (TCollection_AsciiString,
TCollection_ExtendedString)
from OCC.Core.TDocStd import TDocStd_Application, TDocStd_Document
from OCC.Core.XCAFApp import XCAFApp_Application_GetApplication
from OCC.Extend.DataExchange import read_step_file_with_names_colors
from OCC.Core.STEPCAFControl import STEPCAFControl_Reader
from OCC.Core.IFSelect import IFSelect_RetDone
# The Application
# There are several different "flavors" of applications & documents
# Here, XDE (Extended Data Exchange) has been chosen, enabling STEP
title = "Main document"
doc = TDocStd_Document(TCollection_ExtendedString(title))
"""
app = XCAFApp_Application_GetApplication()
app.NewDocument(TCollection_ExtendedString("MDTV-XCAF"), doc)
"""
filename = "/home/doug/step-files/as1-oc-214.stp"
step_reader = STEPCAFControl_Reader()
step_reader.SetColorMode(True)
step_reader.SetLayerMode(True)
step_reader.SetNameMode(True)
step_reader.SetMatMode(True)
step_reader.SetGDTMode(True)
status = step_reader.ReadFile(filename)
if status == IFSelect_RetDone:
step_reader.Transfer(doc)
# see if I can retrieve the app from doc
# app = doc.Application() # gives runtime error: document has not yet been opened by any application