Talk:Python scripting tutorial: Difference between revisions

From FreeCAD Documentation
(Created page with "Roy 043: thanks for the corrections and formatting! The one thing I would request is that one does need to either have a document already open, or do doc = App.newDocument (). Otherwise it can be quite mysterious to click the Execute button and have nothing happen. The code I would suggest to cover both cases is: doc = App.ActiveDocument if not doc: doc = App.newDocument ()")
 
No edit summary
Line 8: Line 8:
if not doc:
if not doc:
doc = App.newDocument ()
doc = App.newDocument ()

--[[User:Dan kirshner|Dan kirshner]] ([[User talk:Dan kirshner|talk]]) 16:08, 28 May 2023 (UTC)

Revision as of 16:08, 28 May 2023

Roy 043: thanks for the corrections and formatting!

The one thing I would request is that one does need to either have a document already open, or do doc = App.newDocument (). Otherwise it can be quite mysterious to click the Execute button and have nothing happen.

The code I would suggest to cover both cases is:

doc = App.ActiveDocument
if not doc:
    doc = App.newDocument ()

--Dan kirshner (talk) 16:08, 28 May 2023 (UTC)