Quick Placement editor

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
comunityfc
Posts: 8
Joined: Fri Nov 19, 2021 9:05 pm

Quick Placement editor

Post by comunityfc »

Is there any way to really fast access to Placement edit fields?
In most cases, they contain formulas, so, to start editing them, I should make several click series:
1) Open closed by default Placement branch item
2) Open closed by default Position item
3) Try to get click into the minuscule formula editor circle to open field that I need
Oh, come on...

The ideal solution (as for me now) is just
a) select an element
b) press hot-key or toolbar button
c) get the form with three (or more additional) fields with x, y, and z that already contains formulas that can be edited all at once on one form.

Is it possible to implement? Please guide me how to make it or gime a link to a similar solution.
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Quick Placement editor

Post by Roy_043 »

Are you aware of Std_Placement? And there is also Std_TransformManip (not for formulas)
comunityfc
Posts: 8
Joined: Fri Nov 19, 2021 9:05 pm

Re: Quick Placement editor

Post by comunityfc »

Yes, I am. However, I need the same or similar form(s) especially for the formulas editing
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Quick Placement editor

Post by onekk »

comunityfc wrote: Wed May 31, 2023 9:34 am Yes, I am. However, I need the same or similar form(s) especially for the formulas editing
When you enter a formula, you are on your own, these dialogs are made to be used with UI.

You could use as example this construct:
placement(base; rotation; center)
See maybe:
https://wiki.freecad.org/Expressions

under:

Object creation functions

I doubt that is possible to open a new dialog when you have already open the "expression editor" (From What I Know it is called this way on FreeCAD).

Or a more complex dialog have to be made with helpers functions to enter things in the "expression editor".

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
comunityfc
Posts: 8
Joined: Fri Nov 19, 2021 9:05 pm

Re: Quick Placement editor

Post by comunityfc »

The question is not about "how to write expressions correctly", but "hot to pull expression text from the object's properties, and then push it back edited" (using built-in Python macros), so that FreeCAD redraw your model after your editing...
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Quick Placement editor

Post by onekk »

comunityfc wrote: Fri Jun 02, 2023 4:13 pm The question is not about "how to write expressions correctly", but "hot to pull expression text from the object's properties, and then push it back edited" (using built-in Python macros), so that FreeCAD redraw your model after your editing...
If you use expressions they are recalculated if data will change.

So the retrieve of properties from objects are in expression wiki page, you should assign it with python if you want.

Try to put data in a spreadsheet and it will work, I use it to change orientations of assemblies and to tune model parameters.

A simple doc.recompute() will update things.

Regards

Carlo D.
Last edited by onekk on Tue Jun 20, 2023 7:55 am, edited 1 time in total.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
comunityfc
Posts: 8
Joined: Fri Nov 19, 2021 9:05 pm

Re: Quick Placement editor

Post by comunityfc »

Thanks a lot Carlo for trying to help me. However, you're giving me answers to the questions I wasn't asked.
Let me repeat my main issue. I don't know how to implement the expression EDITING process.
i.e. I need a Python code for the function that will do the following:
1 - Create a GUI form with one text edit field and two buttons - Update and Cancel
2 - Take from the first given parameter object label (not name but label that I can see in the model tree)
3 - Take from the second parameter the parameter name that I want to edit
4 - Pull its expression or value if there is no expression in it
5 - Fill text edit box with pulled value and show form to edit pulled text
6 - On pressing the Update button - get (edited) text from the text edit field and push it back to the parameter
7 - Recompute the entire model or may be edited object only.
From all list above, I can do the only first item (
I would appreciate it if the CF community could assist me with the rest.

BTW about 3-d item: I was very surprised to see In the properties' tree Base / Placement / z although in the Python code I should write Placement.Base.z
mario52
Veteran
Posts: 4673
Joined: Wed May 16, 2012 2:13 pm

Re: Quick Placement editor

Post by mario52 »

Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Quick Placement editor

Post by onekk »

comunityfc wrote: Fri Jun 02, 2023 8:26 pm ...
BTW about 3-d item: I was very surprised to see In the properties' tree Base / Placement / z although in the Python code I should write Placement.Base.z
Not more to add to @mario52 answer, it is not too hard and documented somewhere in the wiki. Read the Wiki and you will find many things.

Speaking about code, it is hard to guess what you are trying to do, a good expectation is that you post some code and ask for advice on code you have written, if not writing code from scratch is very near to a "paid job" than to an user to user volunteer help.

There are some idiosyncrasies but if you activate things like in the introductory Python scripting document in the Wiki, you will have some echo in Python Consolee that will help you to guess "how things are working", some of these idiosyncrasies have to be taken as is as it is not advisable to change this strange behaviour as it will break almost any Python FreeCAD code around, just take as is Placement.Base is the "Translation Vector" component in a FreeCAD.Placement object.

The other component is a FreeCAD.Rotation. object.

Once learned it is not too difficult to manage.

Regards

Carlo D.
Last edited by onekk on Tue Jun 20, 2023 7:56 am, edited 2 times in total.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Quick Placement editor

Post by Roy_043 »

Is there a Qt widget that is expressions aware?
Post Reply