Skip to content

Commit 8a62091

Browse files
committed
Starting to add content for data framework
1 parent 6906537 commit 8a62091

3 files changed

Lines changed: 72 additions & 0 deletions

File tree

docs/std_doc_services.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright 2022 Doug Blanding (dblanding@gmail.com)
4+
#
5+
# This file contains the PythonOCC equivalent code for the C++ code
6+
# presented in the Open CASCADE Technology OCAF Documentation at:
7+
# https://dev.opencascade.org/doc/overview/html/occt_user_guides__ocaf.html
8+
# It has lots of extra snippets of code and print() functions
9+
# sprinkled in to allow a student to explore the details of OCAF
10+
# labels and attributes while using PythonOCC rather than C++.
11+
# :-)
12+
13+
from OCC.Core.TCollection import (TCollection_AsciiString,
14+
TCollection_ExtendedString)
15+
from OCC.Core.TDataStd import TDataStd_Integer
16+
from OCC.Core.TDocStd import TDocStd_Document
17+
from OCC.Core.TDF import (TDF_Tool, TDF_TagSource,
18+
TDF_ChildIterator,)
19+
20+
21+
def get_entry(label):
22+
"""Return entry of label"""
23+
entry_str = TCollection_AsciiString()
24+
TDF_Tool.Entry(label, entry_str)
25+
entry = entry_str.ToCString()
26+
return entry
27+
28+
# Create a document
29+
title = "Main document"
30+
doc = TDocStd_Document(TCollection_ExtendedString(title))
31+
root = doc.Main()
File renamed without changes.

ocaf_std_doc_srvcs.py

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

0 commit comments

Comments
 (0)