WebGL export

Info about new implemented features, classes, modules or APIs. Might get technical!
User avatar
yorik
Site Admin
Posts: 8563
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: WebGL export

Postby yorik » Sun Oct 18, 2015 7:00 pm

microelly2 wrote:The cause for this error seems to be print calls in the code when the script is executed from a Qt Gui.

Hm interesting info... Hopefully when we switch to python3 all these problems will be gone because the exchange of text between python and Qt is greatly simplified (all python is unicode <-> all qt is exchanged as utf8)
triplus
Posts: 4857
Joined: Mon Dec 12, 2011 4:45 pm

Re: WebGL export

Postby triplus » Sun Oct 18, 2015 8:45 pm

microelly2 wrote:The cause for this error seems to be print calls in the code when the script is executed from a Qt Gui.
I had the same problem last days.
Go through the code and deactivate all prints.
I still have no idea to redirect print in such cases.


Thanks for confirmation and feedback. Indeed print statements were the issue for me too.

yorik wrote:
microelly2 wrote:The cause for this error seems to be print calls in the code when the script is executed from a Qt Gui.

Hm interesting info... Hopefully when we switch to python3 all these problems will be gone because the exchange of text between python and Qt is greatly simplified (all python is unicode <-> all qt is exchanged as utf8)


Hopefully things will sort itself out indeed but just in case i created this "test case":

Code: Select all

import sys
from PySide.QtCore import *
from PySide.QtGui import *

class Form(QDialog):

    def __init__(self, parent = None):
        super(Form, self).__init__(parent)
        self.setWindowTitle("My Form")
        self.edit = QLineEdit("Write my name here")
        self.button = QPushButton("Show Greetings")
        layout = QVBoxLayout()
        layout.addWidget(self.edit)
        layout.addWidget(self.button)
        self.setLayout(layout)
        self.button.clicked.connect(self.greetings)

    def greetings(self):
        print ("Hello : " + self.edit.text())

if __name__ == '__main__':
    form = Form()
    form.show()


I adapted the code from here. Removing CadQuery module from Mod folder removes that error. Therefore i reported the issue to CadQuery module developer to take a look. And i cross-referenced it here if maybe there is an issue inside FreeCAD to be looked at.

https://github.com/jmwright/cadquery-fr ... /issues/63
User avatar
microelly2
Posts: 2362
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: WebGL export

Postby microelly2 » Sun Oct 18, 2015 9:53 pm

Import/link of community software is necessary but difficult.
Changing the base can cause a lot of problems. Changing to python3 is a big thing, and I thank Yorik to do the hard job to inspect all the code.
To port the 3rd party products will be a task for somebody else ...
I have worked on a lot of php platforms.
In TYPO3 an extensions is killed on a syntax error or a runtime error. There is a good security support
MOODLE (may be it's now better) crashed completely. This was a nightmare for the admin, one error during the time, when a examination of students was running - and you are stoned.
As long as FreeCAD is a standalone program there is no problem.
compile, run the regression tests and when okay you can deliver.
Otherwise debug, make the next test case ..

But Computer Aided Industry is so complex, there cannot be the Singing Ringing Tree.
So how to make the system open and secure?
I think its worth to discuss about this. There should be concepts, how components can communicate in a secure manner. And we should have these concepts running before problems turn up.
I think this is not a specific problem of the cad query module (I have to change my sources too), but in general.
triplus
Posts: 4857
Joined: Mon Dec 12, 2011 4:45 pm

Re: WebGL export

Postby triplus » Sun Oct 18, 2015 10:37 pm

Yes there is always risk of running any code on the computer. Improving this therefore probably can't be done on technical level in FreeCAD but the code would need to be audited by some trustworthy authority.

But that would probably take substantial amount of work for FreeCAD project developers to audit 3rd Party modules. That probably will remain responsibility of individual users unless in the future FreeCAD project would actually become interested in doing this work for whatever reason involved.
User avatar
bill
Posts: 156
Joined: Fri Jan 09, 2015 9:25 pm

Re: WebGL export

Postby bill » Mon Oct 19, 2015 4:20 am

As a minimum, secure hashes should be generated and checked on all macros and WBs.
triplus
Posts: 4857
Joined: Mon Dec 12, 2011 4:45 pm

Re: WebGL export

Postby triplus » Tue Oct 27, 2015 10:46 pm

microelly2 wrote:The cause for this error seems to be print calls in the code when the script is executed from a Qt Gui.
I had the same problem last days.
Go through the code and deactivate all prints.
I still have no idea to redirect print in such cases.


It should now be possible to use latest CadQuery module without mentioned issue.
User avatar
bernd
Posts: 3872
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: WebGL export

Postby bernd » Wed May 18, 2016 2:35 pm

Just tried the webgl export with FreeCAD.

OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.7569 (Git)
Build type: Release
Branch: master
Hash: f6cdf8b4709baa79fc89e8c24cf8cbfa84d55501
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17

Attached the file I tested with. The html file has lots of lines, but the browserwindow of Firefox keeps staying a white board nothing else ?!?
Attachments
test.FCStd
(103.93 KiB) Downloaded 19 times
User avatar
rockn
Posts: 1433
Joined: Wed Sep 28, 2011 10:39 am
Location: Toulouse, France
Contact:

Re: WebGL export

Postby rockn » Wed May 18, 2016 3:11 pm

Hold right click and drag down your mouse, you will see something ;)
I remember having hard time to get the right view directly from a fresh export, something like moving all geometry far from where it is...
Formations et tutoriels FreeCAD en Français, soutenez moi : https://www.tipeee.com/formations-freecad
User avatar
bernd
Posts: 3872
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: WebGL export

Postby bernd » Wed May 18, 2016 4:25 pm

Thanks rockn, Ahh yeah we had this allready. Wasn't it because of the way the viewer (and thus scalling and camera view point) is implemented is not optimized to view something huuuuuge like a building ...
Attachments
webgl.png
webgl.png (76.93 KiB) Viewed 1769 times
triplus
Posts: 4857
Joined: Mon Dec 12, 2011 4:45 pm

Re: WebGL export

Postby triplus » Thu May 19, 2016 8:32 pm