[Solved] How to use A2Plus solve constraints programatically

Need help, or want to share a macro? Post here!
User avatar
daaan
Posts: 15
Joined: Fri Oct 18, 2019 10:43 pm

[Solved] How to use A2Plus solve constraints programatically

Postby daaan » Tue Nov 05, 2019 4:34 am

I need to do some animations using the A2plus (V0.4.27a) constraints.
I'm thinking about rotating some parts stated as fixed, and then solve the constraints, and repeat.
What is the correct command that does the rubic cube button (Solve constraints) in python?
Also I need to take a snapshot image of the result to make a gif animation, because I'm aware that the solve constraints will take some time to compute.

Code: Select all

OS: Ubuntu 18.04.3 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.3.
Build type: Release
Python version: 3.6.8
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedKingdom (en_GB)
Last edited by daaan on Thu Nov 07, 2019 10:04 pm, edited 2 times in total.
User avatar
daaan
Posts: 15
Joined: Fri Oct 18, 2019 10:43 pm

Re: How to use A2Plus solve constraints programatically

Postby daaan » Thu Nov 07, 2019 9:54 pm

Here is how you do it:

Code: Select all

	doc = App.getDocument("document_name");
	solveConstraints(doc)
	doc.recompute()
	FreeCAD.ActiveDocument.recompute()				#Recompute
	FreeCADGui.updateGui()							#Update the graphics.}