Invisible project after open and saveas commands

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
wdxu
Posts: 2
Joined: Sun Jan 05, 2020 12:17 pm

Invisible project after open and saveas commands

Post by wdxu »

Briefly, I created a simple cube using the GUI, and then I saved the project in "cube.fcstd" file.

I want to open the fcstd file by Python code, change the parameter (e.g., height), and save the project as (cube_modified.fcstd). However, the generated file is smaller than the original file (2.1k v.s. 3.3k) and the object is not shown in the GUI when I open this file using the App.

Specifically:

I am new to FreeCAD, and I want to achieve the following goal:
1) create an object using GUI and add the length constraints,
2) using commands to open the file, modify the parameters and save the file.

In step 1, I am using the freecad docker and xquartz to install the software on my macos computer:

"""
IP="$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')"
/usr/X11/bin/xhost +$IP

docker run -ti --rm --name FreeCAD \
--net=host \
-e DISPLAY="$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')":0 \
-v /tmp/.X11-unix:/tmp.X11-unix \
-v $HOME/.Xauthority:/root/.Xauthority \
-v $HOME/Workspace/freecad:/mnt \
-w /mnt \
izone/freecad:stable freecad
"""

The freecad software can be open successfully. However, I noticed the error messages and I don't know if it is related to my problem:
"""
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
Coin info in glglue_allow_newer_opengl():

Features of OpenGL version > 1.0 has been
disabled, due to the use of a remote display.

This is so because many common OpenGL drivers
have problems in this regard.

To force full OpenGL use, set the environment
variable COIN_FULL_INDIRECT_RENDERING=1 and re-run the application.

If you don't want this message displayed again,
set the environment variable COIN_DONT_INFORM_INDIRECT_RENDERING=1.
"""

Then I created a default cube and saved it in the "cube.fcstd" file.

In step 2:

I run the following code by the FreeCADcmd toolkit:

"""
# -*- coding: utf-8 -*-

# Macro Begin: /mnt/scripts/cude_reload.FCMacro +++++++++++++++++++++++++++++++++++++++++++++++++
import FreeCAD

FreeCAD.open(u"/mnt/models/cube.fcstd")
#App.setActiveDocument("cube")
#App.ActiveDocument=App.getDocument("cube")
#Gui.ActiveDocument=Gui.getDocument("cube")
#Gui.SendMsgToActiveView("SaveAs")
App.getDocument("cube").saveAs(u"/mnt/models/cube_reload_cmd.fcstd")
App.closeDocument("cube")
#App.setActiveDocument("")
#App.ActiveDocument=None
#Gui.ActiveDocument=None
# Macro End: /mnt/scripts/cude_reload.FCMacro +++++++++++++++++++++++++++++++++++++++++++++++++
"""
which is generated by Macro recorder.

To run the FreeCADcmd, I open another docker container with bash:
"""
IP="$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')"
/usr/X11/bin/xhost +$IP

docker run -ti --rm --name FreeCAD \
--net=host \
-e DISPLAY="$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')":0 \
-v /tmp/.X11-unix:/tmp.X11-unix \
-v $HOME/.Xauthority:/root/.Xauthority \
-v $HOME/Workspace/freecad:/mnt \
-w /mnt \
izone/freecad:stable bash
"""


However the generated file "cube_reload_cmd.fcstd" is not visible on the GUI and the file size is 2.3k rather than 3.3k...

In my opinion, the command script does exactly the same as GUI steps. However, the result is quite strange. Please help me if you have any idea.
Last edited by wdxu on Thu Jan 09, 2020 2:29 am, edited 1 time in total.
wdxu
Posts: 2
Joined: Sun Jan 05, 2020 12:17 pm

Re: Invisible project after open and saveas command

Post by wdxu »

After looking around, I suggest this problem is related to "python generated objects not visible" https://forum.freecadweb.org/viewtopic.php?t=32737

If there is a way to solve this problem?
Post Reply