![]() ![]() POLYHEDRONS_PATH = '/home/user/.FreeCAD/Mod/Pyramids-and-Polyhedrons' I'm launching it in the background before running the updated script with DISPLAY pointing to Xvfb: FREECADPATH = '/usr/local/lib' # path to your FreeCAD.so or FreeCAD.dll file This requires a display, however, and I want to run the script as part of a headless toolchain in a Docker container. I found out that FreeCADGui will only be fully initialized after FreeCADGui.showMainWindow() has been called. Now FreeCADGui could be imported, but it was lacking the required addCommand method that Pyramids-and-Polyhedrons invokes. The first problem was that Pyramids-and-Polyhedrons imports FreeCADGui (in order to install its workbench), which depends on certain native libs that need to be added to LD_LIBRARY_PATH before running the script: export LD_LIBRARY_PATH=$(echo $(find /usr/local/lib/python3.7/site-packages -maxdepth 2 -mindepth 2 -type f -name *.so* | sed -r 's|/+$||' | sort -u) | sed -E 's/ /:/g') The reason was Pyramids-and-Polyhedrons not being imported after all. Print('icosahedron.Radius = '+str(icosahedron.Radius)) Icosahedron = doc.getObjectsByLabel('Icosahedron') Print('radius = ' + str(sheet.get('radius'))) FREECADPATH = '/usr/local/lib' # path to your FreeCAD.so or FreeCAD.dll POLYHEDRONS_PATH = '/home/user/.FreeCAD/Mod/Pyramids-and-Polyhedrons' The path it takes from Document.recompute() to Facebinder.execute() method is not visible in pudb it immediately stops in Facebinder.execute(). When I trace Document.recompute() with pudb, I only see it executing Facebinder.execute() but not Icosahedron.execute(). To my understanding the macro's execute method should get invoked during the recomputation of the document. I was expecting it to change to 15, according to the parameter change. The z coordinate of the vertex at index 11 in the tessellated mesh happens to be equal to the icosahedron's radius. The python script below opens this model, changes the radius cell in the Spreadsheet to 15, call recompute() on the spreadsheet, invokes touch() on the icosahedron, calls recompute() on the document, and finally tessellates the icosahedron. some facebinders which are unimportant for the purpose of this question,.Icosahedron (from the Pyramids-and-Polyhedrons macro) with Radius=parameters.radius.Spreadsheet "parameters" with a cell aliased as "radius" and value 50.
0 Comments
Leave a Reply. |