shadows in the freecad viewport

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
wmayer
Site Admin
Posts: 14640
Joined: Thu Feb 19, 2009 10:32 am

Re: shadows in the freecad viewport

Postby wmayer » Sun Jul 21, 2019 9:51 pm

File "/run/media/paullee/Home_1/paullee/Downloads/FreeCAD_0.19-17360-Linux-Conda_Py3Qt5_glibc2.12-x86_64/squashfs-root/usr/Mod/Arch/OfflineRenderingUtils.py", line 7 <!DOCTYPE html>
It looks like the file was downloaded from GH via browser and instead of the raw version the HTML page was downloaded.
paullee
Posts: 1645
Joined: Wed May 04, 2016 3:58 pm

Re: shadows in the freecad viewport

Postby paullee » Mon Jul 22, 2019 12:15 am

Thanks @werner for the hints - I put in the wrongly downloaded file

Putting back the correct file, it works as indicated :D
Screenshot from 2019-07-22 08-11-59.png
Screenshot from 2019-07-22 08-11-59.png (173.52 KiB) Viewed 550 times
pablogil
Posts: 748
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

Re: shadows in the freecad viewport

Postby pablogil » Mon Jul 22, 2019 3:41 pm

I'm just curious: this works only for BIM projects or any body or part element inside FreeCAD could get the shadows?
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
User avatar
yorik
Site Admin
Posts: 11458
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: shadows in the freecad viewport

Postby yorik » Wed Jul 24, 2019 5:29 pm

Anything. Even meshes, and even wireframes seem to work too!
pablogil
Posts: 748
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

Re: shadows in the freecad viewport

Postby pablogil » Fri Jul 26, 2019 10:42 pm

Working flawlessly here in macOS, it's pretty cool.
How about adding it as a new type of shading? I wish I could load-unload it when I want :D
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
mlampert
Posts: 1279
Joined: Fri Sep 16, 2016 9:28 pm

Re: shadows in the freecad viewport

Postby mlampert » Sat Jul 27, 2019 12:47 am

pablogil wrote:
Fri Jul 26, 2019 10:42 pm
Working flawlessly here in macOS, it's pretty cool.
prove it! :D
pablogil
Posts: 748
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

Re: shadows in the freecad viewport

Postby pablogil » Sun Jul 28, 2019 8:17 am

Here is the prove but, I have realized that it only works with the fist body I have in the hierarchy and anything else... is this normal?:
Captura de pantalla 2019-07-28 a las 10.15.18.png
Captura de pantalla 2019-07-28 a las 10.15.18.png (96.11 KiB) Viewed 320 times
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here
User avatar
bitacovir
Posts: 680
Joined: Sat Apr 19, 2014 6:23 am
Contact:

Re: shadows in the freecad viewport

Postby bitacovir » Sun Jul 28, 2019 7:05 pm

pablogil wrote:
Sun Jul 28, 2019 8:17 am
Here is the prove but, I have realized that it only works with the fist body I have in the hierarchy and anything else... is this normal?:
Maybe you need to put the elements into a group like building part.
::bitacovir::
===================================
One must be absolutely modern.
Arthur Rimbaud (A Season in Hell -1873)

My Blog
Mini Airflow Tunnel Project
User avatar
yorik
Site Admin
Posts: 11458
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: shadows in the freecad viewport

Postby yorik » Mon Jul 29, 2019 2:32 pm

The python snippet that Werner provided above will indeed only grab the first element form the scene. To get them all you need to do this:

Code: Select all

from pivy import coin
root = Gui.ActiveDocument.ActiveView.getSceneGraph()
nodes = [node for node in root.getChildren() if isinstance(node, coin.SoSeparator]
newnode = coin.SoSeparator()
for node in nodes:
    newnode.addChild(node) # pack them all into a separator, for convenience
then you use this newnode in your shadowgroup
pablogil
Posts: 748
Joined: Wed Nov 26, 2014 3:19 pm
Location: Badajoz (Spain)
Contact:

Re: shadows in the freecad viewport

Postby pablogil » Mon Jul 29, 2019 2:46 pm

yorik wrote:
Mon Jul 29, 2019 2:32 pm
The python snippet that Werner provided above will indeed only grab the first element form the scene. To get them all you need to do this:

Code: Select all

from pivy import coin
root = Gui.ActiveDocument.ActiveView.getSceneGraph()
nodes = [node for node in root.getChildren() if isinstance(node, coin.SoSeparator]
newnode = coin.SoSeparator()
for node in nodes:
    newnode.addChild(node) # pack them all into a separator, for convenience
then you use this newnode in your shadowgroup
well, I was actually using your code... could you provide mi a full code to try? I have tried several times to inject your new snippet into the main code and I can't make it work...

Thanks
Dark and Light stylesheets v2.0 to theme your FreeCAD UI, more information here