Comments (7)
this might be relevant? https://pybind11.readthedocs.io/en/stable/advanced/pycpp/utilities.html#capturing-standard-output-from-ostream
and
https://www.opencascade.com/doc/occt-7.4.0/refman/html/_standard___o_stream_8hxx.html
from pyocct.
Thanks for the links, looks like Standard_OStream is just a typedef and pybind has a pythonbuf class for this.
I have two ideas, not sure which is best (or if they'll work):
- Change any
std::ostream
functions to be lambdas that take a pyobject instead of the ostream, then wrap the object in a pythonbuf. This way would allow just usingt.DumpJson(some_file_like_obj)
- Make
Standard_OStream
apy::class
that creates a pythonbuf, so you have to create a Standard_OStream passing the python file like object, then pass the Standard_OStream to the function.
Any preferences? I can try to make a patch.
from pyocct.
hmm....my first thought is 2....i think at the moment Standard_OStream is just skipped in the binder https://github.com/LaughlinResearch/pyOCCT/blob/1c354c2ffb92f5c49d0a4f1c7a26a6483c8b2b9f/binder/config.txt#L118
so, seems like if we just bind Standard_OStream...then we just create one in python and existing functions just work? and it follows the OCCT api. otherwise, #1 seems like a case that will require special logic in the binding generator to handle that type and writing the lambdas. which, we could do, but seems like 2 is worth a shot?
from pyocct.
In some cases these methods can write to a file so as a workaround I've created a temporary file, used OCCT to write to the file, and then read the file
from pyocct.
Did anything happen related to this issue since it was raised? I get similar issues.
from pyocct.
Seems that this gist provides a smooth and easy to integrate solution to this problem via custom type casting.
from pyocct.
I can confirm that the gist was the way to go, though for me it required some modifications: https://github.com/CadQuery/OCP/blob/master/pystreambuf.h
from pyocct.
Related Issues (20)
- Module Not Found Error
- Are you willing to continue maintenance? Can't build normally. HOT 30
- Pass by reference of the immutable types?
- OpenGl_GraphicDriver.ChangeOptions Runtime Error HOT 1
- Example for writing STEP file? HOT 1
- Error running examples/import_step.py HOT 2
- How to call specific function signatures? HOT 7
- Add AIS_CustomObject that can be implemented in python HOT 3
- Need unit test for AIS_CustomObject
- Can't call AIS_InteractiveContext::EntityOwners method, no SelectMgr_IndexedMapOfOwner type HOT 3
- Retrieving weights of a rational BSpline surface causes crashing HOT 5
- Sweeping profile along helical path failing on pyOCCT HOT 1
- [Packaging] Mostly empty "setup.py" makes pyOCCT mostly impossible to package HOT 5
- Will SMESH be back in the future? HOT 1
- Is XSDRAWSTLVRML or anything under TKXSDRAW available in pyocct? HOT 3
- Setting referenced based class attributes HOT 3
- Support for OCCT 7.6.0 HOT 4
- Failed to build due to unnamed enums HOT 3
- RWGltf package
- How to Access STEP Instance ID's? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyocct.