@@ -474,7 +474,7 @@ def render(self, wait_for_completion=False, skip_meshing=False):
474
474
475
475
# Build a default camera, to be used if no camera is present in the
476
476
# scene
477
- defaultcam = _get_default_cam (renderer , self . fpo )
477
+ defaultcam = self . _get_default_cam (renderer )
478
478
479
479
# Get objects rendering strings (including lights, cameras...)
480
480
objstrings = self ._get_objstrings (renderer )
@@ -659,26 +659,27 @@ def _get_rendering_params(self):
659
659
660
660
return Params (prefix , output , width , height , batch , spp , denoise )
661
661
662
+ def _get_default_cam (self , renderer ):
663
+ """Build a default camera for rendering.
662
664
663
- def _get_default_cam (renderer , project ):
664
- """Build a default camera for rendering.
665
-
666
- This function is a (private) subroutine of `render` method.
667
- If GUI is up, the default camera is built from the ActiveView camera, ie
668
- the camera from which objects are seen in FreeCAD viewport. Otherwise
669
- (console mode), the camera is built from a hardcoded value, hosted in
670
- DEFAULT_CAMERA_STRING constant.
671
- """
672
- camstr = (
673
- Gui .ActiveDocument .ActiveView .getCamera ()
674
- if App .GuiUp
675
- else DEFAULT_CAMERA_STRING
676
- )
677
- try :
678
- camsource = get_cam_from_coin_string (camstr )
679
- except ValueError :
680
- camsource = get_cam_from_coin_string (DEFAULT_CAMERA_STRING )
681
- return renderer .get_camsource_string (camsource , project )
665
+ This function is a (private) subroutine of `render` method.
666
+ If GUI is up, the default camera is built from the ActiveView camera, ie
667
+ the camera from which objects are seen in FreeCAD viewport. Otherwise
668
+ (console mode), the camera is built from a hardcoded value, hosted in
669
+ DEFAULT_CAMERA_STRING constant.
670
+ """
671
+ project = self .fpo
672
+ docname = project .Document .Name
673
+ if App .GuiUp :
674
+ App .setActiveDocument (docname )
675
+ camstr = Gui .ActiveDocument .ActiveView .getCamera ()
676
+ else :
677
+ camstr = DEFAULT_CAMERA_STRING
678
+ try :
679
+ camsource = get_cam_from_coin_string (camstr )
680
+ except ValueError :
681
+ camsource = get_cam_from_coin_string (DEFAULT_CAMERA_STRING )
682
+ return renderer .get_camsource_string (camsource , project )
682
683
683
684
684
685
def _instantiate_template (template , objstrings , defaultcam ):
0 commit comments