kbwbe / A2plus

Another assembly workbench for FreeCAD, following and extending Hamish's Assembly 2 workbench
GNU Lesser General Public License v2.1
178 stars 70 forks source link

Updating A2plus parts by script #341

Open leoheck opened 4 years ago

leoheck commented 4 years ago

Hi, sorry to add this here but I also posted it in Freecad Forum, and it seems that no one is available to help this time.

https://forum.freecadweb.org/viewtopic.php?f=22&t=42532

Can you show me how to update parts from a script? Is it possible? I am not using GUI. In the python console I saw that the update icons on toolbar generate this:

Gui.activateWorkbench("A2plusWorkbench")
Gui.runCommand('a2p_updateImportedParts',0)

However, I don't have this Gui object from the script without Gui. Any idea, reference or help would be nice. Thank you kbwbe

kbwbe commented 4 years ago

Is it possible to do something like here: https://forum.freecadweb.org/viewtopic.php?f=22&t=39470 With this: import FreeCAD, FreeCADGui FreeCADGui.showMainWindow() mw = FreeCADGui.getMainWindow() mw.hide() you can run FC in headless mode and have Gui available.

leoheck commented 4 years ago

I tried that a little bit, I don't like the approach, but it opens the Gui, then suddenly hides it and after that my script breaks.

I saw that I was not importing A2Plus scripts. So I could import import A2Plus by appending the python path to ~/.FreeCAD/Mod/. I think now I can use the A2Plus functions directly but I couldn't verify this yet.

leoheck commented 4 years ago

I posted my question here on the Freecad forum, and I got some insights on how to solve my issue. However, this plugin is a little bit complex for me to understand. Do you have any insight for me to expose this a2p_updateImportedParts method so I can use it from a script and without the GUI?

luzpaz commented 1 year ago

@kbwbe ping