Expression Placement (solved)

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
user1234
Veteran
Posts: 3319
Joined: Mon Jul 11, 2016 5:08 pm

Expression Placement (solved)

Post by user1234 »

Hello!

Is there a way to get the expression from the placement like this pseudocode?

Code: Select all

obj = FreeCADGui.Selection.getSelection()
pos = obj[0].getExpression(Base, Placement.Position.x)
obj[1].setExpression(pos)
Always when i try something like 'getExpression' or similar FreeCAD says: 'FeaturePython' object has no attribute 'getExpression'.
I did not find anything in the in the documentation or in the forum seach.

Setting the expression from the placement is no problem with setExpression().

Thanks for helping.
Greetings user1234

Edit: I have forgotten the version:

Code: Select all

OS: Debian GNU/Linux 8.7 (jessie)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.10893 (Git)
Build type: Debug
Branch: master
Hash: a75a98ef279e9e067abf5cef3a6de6f09fba2c94
Python version: 2.7.9
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 7.1.0
Last edited by user1234 on Thu Apr 20, 2017 6:53 pm, edited 1 time in total.
eivindkvedalen
Posts: 602
Joined: Tue Jan 29, 2013 10:35 pm

Re: Expression Placement

Post by eivindkvedalen »

user1234 wrote:Hello!

Is there a way to get the expression from the placement like this pseudocode?

Code: Select all

obj = FreeCADGui.Selection.getSelection()
pos = obj[0].getExpression(Base, Placement.Position.x)
obj[1].setExpression(pos)
Always when i try something like 'getExpression' or similar FreeCAD says: 'FeaturePython' object has no attribute 'getExpression'.
I did not find anything in the in the documentation or in the forum seach.
You can get all registered expressions using e.g

Code: Select all

obj = FreeCADGui.Selection.getSelection()
expressions = obj[0].ExpressionEngine
This wlll give you an array of tuples that you can search through. Not the nicest interface, but possible to do at least...


Eivind
user1234
Veteran
Posts: 3319
Joined: Mon Jul 11, 2016 5:08 pm

Re: Expression Placement

Post by user1234 »

This was really fast!!!

Thanks for the help!
Post Reply