New Tool - TD View from 3D View

Discussions about the development of the TechDraw workbench
User avatar
wandererfan
Posts: 3341
Joined: Tue Nov 06, 2012 5:42 pm

New Tool - TD View from 3D View

Postby wandererfan » Fri Aug 30, 2019 11:56 am

git commit 13676bfe57 adds a new tool to TechDraw. TechDraw_ActiveView copies the active 3D view to a new TD View.

This tool is still somewhat experimental. You can not do anything with the result at present (except look at it) and the result is a "snapshot" and does not update with changes to the model.

ActiveView is very fast as no calculations are performed.
casa_pela_via_SVG.png
casa_pela_via_SVG.png (24.29 KiB) Viewed 1019 times
triplus
Posts: 8864
Joined: Mon Dec 12, 2011 4:45 pm

Re: New Tool - TD View from 3D View

Postby triplus » Fri Aug 30, 2019 12:03 pm

Nice!
User avatar
bitacovir
Posts: 785
Joined: Sat Apr 19, 2014 6:23 am
Contact:

Re: New Tool - TD View from 3D View

Postby bitacovir » Fri Aug 30, 2019 1:19 pm

Good!
It could be useful to print 3D views of Textures, or the last Yorik's shadows script.
::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: 11618
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: New Tool - TD View from 3D View

Postby yorik » Tue Sep 03, 2019 1:11 am

Amazing!! I like much that we are both trying to go the same way each in our own manner. This is very rich for FreeCAD.
Your implementation does everything under the hood without actually displaying a viewer, that's much better and more solid than mine...
User avatar
wandererfan
Posts: 3341
Joined: Tue Nov 06, 2012 5:42 pm

Re: New Tool - TD View from 3D View

Postby wandererfan » Tue Sep 03, 2019 12:02 pm

yorik wrote:
Tue Sep 03, 2019 1:11 am
Amazing!! I like much that we are both trying to go the same way each in our own manner. This is very rich for FreeCAD.
Your implementation does everything under the hood without actually displaying a viewer, that's much better and more solid than mine...
If it is useful to you:

in TechDrawGui:

Code: Select all

copyActiveViewToSvgFile(document, filePath, (options))

Description: save a copy of the active view for "document" to file "filePath"

Returns: double (estimated scale)  ** not correct yet

Options:
    width - float - width of generated svg in mm
    height - float - height of generated svg in mm
    paintBackground - bool - paint/do not paint background
    backgroundColor - tuple - (r,g,b,a)
    lineWidth - float - weight of lines
    border - float - empty space around image
    mode - int - rendering mode (AS_IS, WIREFRAME, POINTS, WIREFRAME_OVERLAY, HIDDEN_LINE, BOUNDING_BOX)
User avatar
yorik
Site Admin
Posts: 11618
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: New Tool - TD View from 3D View

Postby yorik » Tue Sep 03, 2019 2:43 pm

Definitely! Is it okay to you if we extend it a bit so we can provide our own list of objects/viewproviders/nodes, and maybe set the camera orientation too? :mrgreen:

The easiest way would be to provide a list of object names, so in your function it would be just a matter of filtering out SoGroups by name, but I haven't found a way to find out which SoGroup relates to which object...
User avatar
wandererfan
Posts: 3341
Joined: Tue Nov 06, 2012 5:42 pm

Re: New Tool - TD View from 3D View

Postby wandererfan » Tue Sep 03, 2019 7:28 pm

yorik wrote:
Tue Sep 03, 2019 2:43 pm
Definitely! Is it okay to you if we extend it a bit so we can provide our own list of objects/viewproviders/nodes, and maybe set the camera orientation too? :mrgreen:
Something like this note to myself in the code? :D

Code: Select all

using namespace TechDraw;
using namespace Gui;

    //notes for selection view
    //SoSeparator* newSG;
    //for obj in objList: 
    //    vProv = obj.ViewObject
    //    sg = vProv.getSG(obj);
    //    for child in sg:
    //       newSG->addChild();
    //

//creates Svg file and returns estimate of scale
double Grabber3d::copyActiveViewToSvgFile(App::Document* appDoc, 
                                        std::string fileSpec,
                                        double outWidth, double outHeight,
                                        bool paintBackground, const QColor& bgColor,
                                        double lineWidth, double border,
                                        int renderMode)
{
Mind you, I don't actually know how to do it yet!
User avatar
bitacovir
Posts: 785
Joined: Sat Apr 19, 2014 6:23 am
Contact:

Re: New Tool - TD View from 3D View

Postby bitacovir » Mon Sep 09, 2019 1:27 pm

In the ActiveView panel, is the render mode options working?
Because in my case, with the FreeCAD example file, the generated image is always the same (no wireframe, no points).
FreeCAD_2019-09-09_10-27-54.png
FreeCAD_2019-09-09_10-27-54.png (115.86 KiB) Viewed 599 times
OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.18024 (Git)
Build type: Release
Branch: master
Hash: 9cc8f6eb666b0a0ae2dc256f7bc0beb8c987710c
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/Australia (en_AU)
::bitacovir::
===================================
One must be absolutely modern.
Arthur Rimbaud (A Season in Hell -1873)

My Blog
Mini Airflow Tunnel Project
User avatar
wandererfan
Posts: 3341
Joined: Tue Nov 06, 2012 5:42 pm

Re: New Tool - TD View from 3D View

Postby wandererfan » Mon Sep 09, 2019 7:27 pm

bitacovir wrote:
Mon Sep 09, 2019 1:27 pm
In the ActiveView panel, is the render mode options working?
Apparently not. It works if I send the output to the screen(a debugging mode), but not if I send it to a file. Will have to learn some more Coin.
User avatar
PatTropos
Posts: 5
Joined: Tue Apr 30, 2019 1:20 pm

Re: New Tool - TD View from 3D View

Postby PatTropos » Fri Nov 29, 2019 11:27 am

Hi People,
is this Tool really comming in the offical release 0.19 in March?

I tried to install some Developers versions 0.1917352 in 64bit but I could not found the camera - icon in TD.
I need something like this to mark single objects in a template with a position number and an explanation.

But in general, How can I get and .svg -file out of my actual view ?
At the Moment I press print on the keyboard and cut it out from the screenshot --> horrible but I have no other Idea at the moment.

This Active View tool will really help me to get documents done and to extend a technicial drawing into printable documentation of a designed System.

Thanks for Help and for your work already!

normally used

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16131 (Git)
Build type: Release
Branch: releases/FreeCAD-0-18
Hash: 3129ae4296e40ed20e7b3d460b86e6969acbe1c3
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: German/Germany (de_DE)

for tests

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.17352 (Git)
Build type: Release
Branch: master
Hash: ec0049921b813ee78c1fd4ea304e70904a3208f7
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: German/Germany (de_DE)