Feature Request: FreeCAD for making presentations.

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
jmaustpc
Posts: 10523
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Feature Request: FreeCAD for making presentations.

Postby jmaustpc » Tue Sep 29, 2020 12:10 pm

If you wanted images to insert into a presentation application document, you could use screen capture and Tools menu...Save Picture.

You can also now (as of a few days ago, thanks Werner!) in FreeCAD 0.19, export to html5 webGL so that a 3d model can be viewed, rotated, zoomed etc. in any modern web browser.
User avatar
jruiz
Posts: 292
Joined: Tue Oct 28, 2014 1:07 pm
Contact:

Re: Feature Request: FreeCAD for making presentations.

Postby jruiz » Wed Sep 30, 2020 12:18 am

jmaustpc wrote:
Tue Sep 29, 2020 12:10 pm
If you wanted images to insert into a presentation application document, you could use screen capture and Tools menu...Save Picture.

You can also now (as of a few days ago, thanks Werner!) in FreeCAD 0.19, export to html5 webGL so that a 3d model can be viewed, rotated, zoomed etc. in any modern web browser.
Thank you very much for your answer.
But it is not what I was requesting.
Thanks again.
I have uploaded some FreeCAD video tutorials to www.youtube.com/yosoyvenezolano
User avatar
easyw-fc
Posts: 2928
Joined: Thu Jul 09, 2015 9:34 am

Re: Feature Request: FreeCAD for making presentations.

Postby easyw-fc » Mon Oct 05, 2020 5:15 am

mfro wrote:
Mon Sep 28, 2020 6:47 pm
jruiz wrote:
Sun Sep 27, 2020 3:13 pm
...
What I think that could be a good feature for FreeCAD is that:
  1. One could select a set of these objects, and sorting a sequence we decide in order for this objects to be shown and/or hidden as we wish.
  2. Then after entering into presentation mode, with just (for example) a mouse click, the objects would be shown and/or hidden in the sequence configured in item 1.
It should be possible to write such a playbook as macro with even minimal Python knowledge.
I tried to simply make some simple operations like toggle visibility of objects and change placement... these will generate some python code in the report panel.
The problem is that if I execute the code, everything is executed immediately, and the result is to show simply last operation result.
I tried to add some delay

Code: Select all

sleep(1)
instruction among the different operations, but the FC freezes until again the last operation result is shown...
So it seems to me that it is not possible ATM to create a simple timed presentation of a 3D operation sequence.
Suggestions would be most welcome.
User avatar
easyw-fc
Posts: 2928
Joined: Thu Jul 09, 2015 9:34 am

Re: Feature Request: FreeCAD for making presentations.

Postby easyw-fc » Tue Oct 06, 2020 3:47 pm

wmayer wrote:ping
Hi Werner,
I'm trying to create a timed sequence of presenting a 3D model using python code...
I've used for the example a simple code generated in the report panel doing some very simple operations.
If I put the code in a macro and execute it (i.e. from the Toolbar) I get simply the last operation displayed on Linux and some step on win, and the last view...

I tried to add some sleep(1) op to obtain a timed sequence but it simply hangs until displaying the last operation result...

Code: Select all

import time
Gui.runCommand('Std_Workbench',11)
Gui.runCommand('Std_ViewStatusBar',1)
### Begin command Std_New
App.newDocument("Unnamed")
# App.setActiveDocument("Unnamed")
# App.ActiveDocument=App.getDocument("Unnamed")
# Gui.ActiveDocument=Gui.getDocument("Unnamed")
Gui.activeDocument().activeView().viewDefaultOrientation()
### End command Std_New
Gui.runCommand('Std_OrthographicCamera',1)
### Begin command Part_Box
App.ActiveDocument.addObject("Part::Box","Box")
App.ActiveDocument.ActiveObject.Label = "Cube"
App.ActiveDocument.recompute()
Gui.SendMsgToActiveView("ViewFit")
### End command Part_Box
# Gui.Selection.addSelection('Unnamed','Box')
### Begin command Std_RandomColor
Gui.getDocument('Unnamed').getObject('Box').ShapeColor=(0.61,0.96,0.07)
time.sleep(1)
### End command Std_RandomColor
### Begin command Part_Cylinder
App.ActiveDocument.addObject("Part::Cylinder","Cylinder")
App.ActiveDocument.ActiveObject.Label = "Cylinder"
App.ActiveDocument.recompute()
Gui.SendMsgToActiveView("ViewFit")
### End command Part_Cylinder
# Gui.Selection.clearSelection()
# Gui.Selection.addSelection('Unnamed','Cylinder')
### Begin command Std_RandomColor
Gui.getDocument('Unnamed').getObject('Cylinder').ShapeColor=(0.88,0.65,0.32)
time.sleep(1)
### End command Std_RandomColor
FreeCAD.getDocument('Unnamed').getObject('Cylinder').Placement = App.Placement(App.Vector(0,0,5),App.Rotation(App.Vector(0,0,1),0))
time.sleep(1)
# Gui.Selection.clearSelection()
### Begin command Std_ViewIsometric
Gui.activeDocument().activeView().viewIsometric()
### End command Std_ViewIsometric
time.sleep(1)
FreeCAD.getDocument('Unnamed').getObject('Box').Placement = App.Placement(App.Vector(0,0,0),App.Rotation(App.Vector(0,0,1),45))
# Gui.Selection.clearSelection()
# Gui.Selection.addSelection('Unnamed','Box')
FreeCADGui.getDocument('Unnamed').getObject('Box').Transparency = 50
time.sleep(1)
# Gui.Selection.clearSelection()
# Gui.Selection.addSelection('Unnamed','Cylinder')
FreeCADGui.getDocument('Unnamed').getObject('Cylinder').Transparency = 70
# Gui.Selection.clearSelection()
Is there a way to create a timed sequence of 3D operation or we would need to create a macro that reads and plays timed some code snippets?
wmayer
Site Admin
Posts: 16852
Joined: Thu Feb 19, 2009 10:32 am

Re: Feature Request: FreeCAD for making presentations.

Postby wmayer » Tue Oct 06, 2020 4:30 pm

Adding a call of sleep() won't work because it blocks the event loop. In order to get an animated move between camera positions you should enable the animation of the view.

Code: Select all

view=Gui.ActiveDocument.ActiveView
view.setAnimationEnabled(True)
for more advanced things have a look at Qt's animation framework: https://doc.qt.io/qt-5/animation-overview.html
digitalgoose
Posts: 10
Joined: Thu Mar 02, 2017 12:36 am

Re: Feature Request: FreeCAD for making presentations.

Postby digitalgoose » Tue Oct 06, 2020 5:17 pm

easyw-fc wrote:
Tue Oct 06, 2020 3:47 pm
wmayer wrote:ping
Hi Werner,
I'm trying to create a timed sequence of presenting a 3D model using python code...
I've used for the example a simple code generated in the report panel doing some very simple operations.
If I put the code in a macro and execute it (i.e. from the Toolbar) I get simply the last operation displayed on Linux and some step on win, and the last view...

I tried to add some sleep(1) op to obtain a timed sequence but it simply hangs until displaying the last operation result...

Code: Select all

import time
Gui.runCommand('Std_Workbench',11)
Gui.runCommand('Std_ViewStatusBar',1)
### Begin command Std_New
App.newDocument("Unnamed")
# App.setActiveDocument("Unnamed")
# App.ActiveDocument=App.getDocument("Unnamed")
# Gui.ActiveDocument=Gui.getDocument("Unnamed")
Gui.activeDocument().activeView().viewDefaultOrientation()
### End command Std_New
Gui.runCommand('Std_OrthographicCamera',1)
### Begin command Part_Box
App.ActiveDocument.addObject("Part::Box","Box")
App.ActiveDocument.ActiveObject.Label = "Cube"
App.ActiveDocument.recompute()
Gui.SendMsgToActiveView("ViewFit")
### End command Part_Box
# Gui.Selection.addSelection('Unnamed','Box')
### Begin command Std_RandomColor
Gui.getDocument('Unnamed').getObject('Box').ShapeColor=(0.61,0.96,0.07)
time.sleep(1)
### End command Std_RandomColor
### Begin command Part_Cylinder
App.ActiveDocument.addObject("Part::Cylinder","Cylinder")
App.ActiveDocument.ActiveObject.Label = "Cylinder"
App.ActiveDocument.recompute()
Gui.SendMsgToActiveView("ViewFit")
### End command Part_Cylinder
# Gui.Selection.clearSelection()
# Gui.Selection.addSelection('Unnamed','Cylinder')
### Begin command Std_RandomColor
Gui.getDocument('Unnamed').getObject('Cylinder').ShapeColor=(0.88,0.65,0.32)
time.sleep(1)
### End command Std_RandomColor
FreeCAD.getDocument('Unnamed').getObject('Cylinder').Placement = App.Placement(App.Vector(0,0,5),App.Rotation(App.Vector(0,0,1),0))
time.sleep(1)
# Gui.Selection.clearSelection()
### Begin command Std_ViewIsometric
Gui.activeDocument().activeView().viewIsometric()
### End command Std_ViewIsometric
time.sleep(1)
FreeCAD.getDocument('Unnamed').getObject('Box').Placement = App.Placement(App.Vector(0,0,0),App.Rotation(App.Vector(0,0,1),45))
# Gui.Selection.clearSelection()
# Gui.Selection.addSelection('Unnamed','Box')
FreeCADGui.getDocument('Unnamed').getObject('Box').Transparency = 50
time.sleep(1)
# Gui.Selection.clearSelection()
# Gui.Selection.addSelection('Unnamed','Cylinder')
FreeCADGui.getDocument('Unnamed').getObject('Cylinder').Transparency = 70
# Gui.Selection.clearSelection()
Is there a way to create a timed sequence of 3D operation or we would need to create a macro that reads and plays timed some code snippets?

I'm sure there's a much better way, but here is a simple example that doesn't block the main thread:

Code: Select all

def toggle_vis(time_to_wait_secs, object_list):
    for object_to_toggle in object_list:
        object_vis_state = object_to_toggle.Visibility
        new_object_vis_state = not object_vis_state 
        object_to_toggle.Visibility = new_object_vis_state #toggle
        time.sleep(time_to_wait_secs)
        object_to_toggle.Visibility = object_vis_state #toggle back
        time.sleep(time_to_wait_secs) 
time_to_wait_secs = 1
threading.Thread(target=toggle_vis, args=(time_to_wait_secs, object_list)).start()