<div dir="ltr">X3DJSAIL has <a href="http://www.web3d.org/x3d/stylesheets/java/src/org/web3d/x3d/jsail/X3DLoaderDOM.java">www.web3d.org/x3d/stylesheets/java/src/org/web3d/x3d/jsail/X3DLoaderDOM.java</a> which supports DOM scenegraphs.<br><div><br></div><div>Examples of usage are here:</div><div><br></div><div><a href="http://www.web3d.org/x3d/stylesheets/java/nashorn/examples/Json.js">www.web3d.org/x3d/stylesheets/java/nashorn/examples/Json.js</a><br><a href="http://www.web3d.org/x3d/stylesheets/java/nashorn/examples/Nashorn.js">www.web3d.org/x3d/stylesheets/java/nashorn/examples/Nashorn.js</a><br><a href="http://www.web3d.org/x3d/stylesheets/java/nashorn/examples/X3d.js">www.web3d.org/x3d/stylesheets/java/nashorn/examples/X3d.js</a><br><br></div><div>Basically, the examples parse JSON into a document using X3DJSONLD.java then convert DOM into a X3DJSAIL scenegraph.</div><div><br></div><div>So to answer your createX3DFromString() question, if you start with JSON, I think you could get a X3DJSAIL scenegraph from a JSON string using the X3DJSAIL-like python API (the one we got to work with Jupyter).</div><div><br></div><div>Otherwise, you probably have to wait for enhancements to x3d.py. It looks like toXML is supported in x3d.py currently. One could use a stylesheet X3dToPython.xslt to convert XML to Python.</div><div><br></div><div>So one could use the stylesheet in a web program (GL with that!) to output python. Then you would have to use something like eval (ugh!).</div><div><br></div><div>John</div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Apr 18, 2020 at 5:20 PM Andreas Plesch <<a href="mailto:andreasplesch@gmail.com">andreasplesch@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Thanks for the interest. I initialized a project at<br>
<br>
<a href="https://github.com/andreasplesch/OCCToX3D" rel="noreferrer" target="_blank">https://github.com/andreasplesch/OCCToX3D</a><br>
<br>
The wiki has some collected info and a short outline. The wiki is<br>
editable by anyone.<br>
<br>
pythonocc has a method to generate X3D xml. It is a simple Shape with<br>
a TriangleSet, nothing sophisticated. If x3d.py would have a<br>
createX3DFromString() function, it would be possible to use x3d.py to<br>
enhance the generated X3D. But I do not think x3d.py has that. But<br>
x3d.py may come in handy in other ways.<br>
<br>
The first goal is to add a simple jupyter notebook to the repo based<br>
on the available pythonocc docker image which demonstrate how to load<br>
step and output X3D.<br>
<br>
Any feedback or ideas welcome, using Issues on the project or here,<br>
<br>
-Andreas<br>
<br>
<br>
<br>
<br>
On Sat, Apr 18, 2020 at 1:27 PM Don Brutzman <<a href="mailto:brutzman@nps.edu" target="_blank">brutzman@nps.edu</a>> wrote:<br>
><br>
> Hi Andreas, sounds like a great idea to me. Here are some peripheral points of support.<br>
><br>
> Last weekend i updated and deployed the x3d.py package (sometimes called X3DPSAIL) at<br>
><br>
> [1] Python Package Index (PyPi) x3d 0.0.25<br>
> Package support for Extensible 3D (X3D) Graphics International Standard (IS)<br>
> <a href="https://pypi.org/project/x3d/" rel="noreferrer" target="_blank">https://pypi.org/project/x3d/</a><br>
><br>
> [2] Python X3D Package x3d.py,X3D Python Scene Access Interface Library (X3DPSAIL)<br>
> <a href="https://www.web3d.org/x3d/stylesheets/python/python.html" rel="noreferrer" target="_blank">https://www.web3d.org/x3d/stylesheets/python/python.html</a><br>
><br>
> "The x3d.py Python X3D Package supports programmers with Python interfaces and objects for standards-based X3D programming, all as open source.<br>
> The presentation *Python X3D Package Implementation* provides an overview and shows examples."<br>
><br>
> [2.1] Python X3D Package Implementation<br>
> <a href="https://www.web3d.org/x3d/stylesheets/python/documents/PythonX3dPackageImplementation.pdf" rel="noreferrer" target="_blank">https://www.web3d.org/x3d/stylesheets/python/documents/PythonX3dPackageImplementation.pdf</a><br>
><br>
> So you would use this library for model creation and data-driven improvement, no need to reinvent X3D data structures or methods.<br>
><br>
> This is autogenerated from X3DUOM so it will always stay in sync with latest/greatest X3D4.<br>
><br>
> We've done some preliminary work with Jupyter notebook, listed there. Lots of potential projects in TODO section.<br>
><br>
> [2.2] X3DPSAIL: Jupyter notebook, TODO<br>
> <a href="https://www.web3d.org/x3d/stylesheets/python/python.html#Jupyter" rel="noreferrer" target="_blank">https://www.web3d.org/x3d/stylesheets/python/python.html#Jupyter</a><br>
> <a href="https://www.web3d.org/x3d/stylesheets/python/python.html#TODO" rel="noreferrer" target="_blank">https://www.web3d.org/x3d/stylesheets/python/python.html#TODO</a><br>
><br>
> For pythonocc conversion efforts, will be happy to ensure that<br>
> a. all improvements to API are applied,<br>
> b. ensure that validation of all scene-graph inputs remains rigorous,<br>
> b. utility methods are added for easy use together,<br>
> d. examplar conversion models are properly saved in X3D Examples Archive,<br>
> e. Whatever else!<br>
><br>
> Looks like there is vast potential here. Hoping folks start picking it up and applying capabilities.<br>
><br>
> Have fun with X3D Python! 8)<br>
><br>
><br>
> On 4/17/2020 5:15 PM, Andreas Plesch wrote:<br>
> > Did somebody put together an x3d converter based on pythonocc ?<br>
> ><br>
> > Here is an example:<br>
> ><br>
> > <a href="https://senties-martinelli.com/software/cad-viewer" rel="noreferrer" target="_blank">https://senties-martinelli.com/software/cad-viewer</a><br>
> ><br>
> > It could convert step, stp, igs, iges, obj and stl formats. Format<br>
> > import and export is only a small subset of pythonocc<br>
> > (<a href="https://github.com/tpaviot/pythonocc-core" rel="noreferrer" target="_blank">https://github.com/tpaviot/pythonocc-core</a>) but I think just making<br>
> > this functionality easy to use with a dedicated converter could be<br>
> > really valuable.<br>
> ><br>
> > In the end, I think a web service just for conversion would be most useful.<br>
> ><br>
> > I played with the Jupyter notebook and could generate with only a few lines x3d.<br>
> ><br>
> > And there are ways to generate a standalone webapp from a notebook:<br>
> > <a href="https://discourse.jupyter.org/t/how-to-transform-a-jupyter-notebook-into-a-webapp/758/6" rel="noreferrer" target="_blank">https://discourse.jupyter.org/t/how-to-transform-a-jupyter-notebook-into-a-webapp/758/6</a><br>
> ><br>
> > That could be quick way to offer a web service.<br>
> ><br>
> > Have there been attempts of this kind ? Would there be interest in a<br>
> > open source github hosted project ?<br>
> ><br>
> > -Andreas<br>
><br>
> all the best, Don<br>
> --<br>
> Don Brutzman Naval Postgraduate School, Code USW/Br <a href="mailto:brutzman@nps.edu" target="_blank">brutzman@nps.edu</a><br>
> Watkins 270, MOVES Institute, Monterey CA 93943-5000 USA +1.831.656.2149<br>
> X3D graphics, virtual worlds, navy robotics <a href="http://faculty.nps.edu/brutzman" rel="noreferrer" target="_blank">http://faculty.nps.edu/brutzman</a><br>
<br>
<br>
<br>
-- <br>
Andreas Plesch<br>
Waltham, MA 02453<br>
<br>
_______________________________________________<br>
x3d-public mailing list<br>
<a href="mailto:x3d-public@web3d.org" target="_blank">x3d-public@web3d.org</a><br>
<a href="http://web3d.org/mailman/listinfo/x3d-public_web3d.org" rel="noreferrer" target="_blank">http://web3d.org/mailman/listinfo/x3d-public_web3d.org</a><br>
</blockquote></div>