Undocumented string processing in expressions : shall we document ?
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Be nice to others! Read the FreeCAD code of conduct!
Re: Undocumented string processing in expressions : shall we document ?
I just used the wiki for this 5 minutes ago to remove the (preferences dependent) decimals from a string .
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
- adrianinsaval
- Veteran
- Posts: 5541
- Joined: Thu Apr 05, 2018 5:15 pm
Re: Undocumented string processing in expressions : shall we document ?
JFYI it is possible to use more than one % specifier like this:openBrain wrote: ↑Sat May 15, 2021 9:23 am Only one specifier is possible inside delimiters, but string concatenating is also possible using '+', and all Python specifiers are available.
So with a default cube and 3 decimals as a precisionwould expand inCode: Select all
<<Box (%s) : >> % Box.Label + <<L = %g mm : >> % Box.Length + <<W = %.2f mm>> % Box.Width
Code: Select all
Box (Cube) : L = 10 mm : W = 10.00 mm
Code: Select all
<<Cube length is %s and width is %s>> % tuple(Box.Length; Box.Width)
Re: Undocumented string processing in expressions : shall we document ?
Hello.
Is there any way to get one specific value from an array of data? The picture shows the distances between the centerlines. And I would like to get the second value. And then the second + third.
And in the tooltips when hovering over a particular axis, I see the data. But I can not output them through expressions in any way.
So that this data can be used in other elements of construction in expressions.
Perhaps this array can somehow be broken down into smaller parts using formatting. But I have not found an example in the documentation.
Such data is used in the axis lines, roof settings. And it would be very useful in building parametric models.
And if it were possible to modify these arrays through expressions, that would be really great. Now the axes and roofs settings do not accept expressions and are filled manually.
UPD. The solution seems to be simple (prompted)
Axis.Distances[1] , Axis.Distances[1]+Axis.Distances[2] and so on
I apologize for distracting you.)
Is there any way to get one specific value from an array of data? The picture shows the distances between the centerlines. And I would like to get the second value. And then the second + third.
And in the tooltips when hovering over a particular axis, I see the data. But I can not output them through expressions in any way.
So that this data can be used in other elements of construction in expressions.
Perhaps this array can somehow be broken down into smaller parts using formatting. But I have not found an example in the documentation.
Such data is used in the axis lines, roof settings. And it would be very useful in building parametric models.
And if it were possible to modify these arrays through expressions, that would be really great. Now the axes and roofs settings do not accept expressions and are filled manually.
UPD. The solution seems to be simple (prompted)
Axis.Distances[1] , Axis.Distances[1]+Axis.Distances[2] and so on
I apologize for distracting you.)
- Attachments
-
- Scr_20230705_111452.jpg (13.29 KiB) Viewed 527 times
-
- Scr_20230705_104813.jpg (22.78 KiB) Viewed 539 times
There may be a misunderstanding . I communicate with the help of a translator
Re: Undocumented string processing in expressions : shall we document ?
Probably wrong place to ask, and necrobumbing such an old post is not the best way.
However Expressions:
https://wiki.freecad.org/Expressions
it is not clear from what you intend for array.
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/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: Undocumented string processing in expressions : shall we document ?
I saw a link to this post in the manual. in the formatting section. thought it might answer the question. That's why I wrote it here. I will be more careful next time. I haven't got the hang of the forum yet.
There are a lot of questions accumulated on the way to modeling a parametric house. I will probably have to create a separate topic for discussion
In "However Expressions" there is no example of work for such a problem. I'm not a programmer and don't know what square brackets do.
UPD.
I realized my mistake. I was looking for the solution in the manual in the wrong place (flipping down hard). I don't understand what [list_index] means in the manual.
I apologize for taking up your time.
I can delete my posts if they disturb someone
UPD2.
"it is not clear from what you intend for array."
I needed to get one of its values.
I figured it out.
What remains to be understood is whether it is possible to insert an expression from a table into one of the places of such an array, for example. That would expand the possibilities of parametric model building.
There may be a misunderstanding . I communicate with the help of a translator
Re: Undocumented string processing in expressions : shall we document ?
No problem, is only a matter of "appropriate way" to obtain answers.
It is a more general approach, as usually the "Open Discussion" is not for asking help, is about "discussing things", usually here there are proposal, or more general discussion about "how to do things" maybe with "future tools" or about "how about making FreeCAD better in this area".
About your problem lists in Python (you could search it in a Python tutorial) could be used to make arrays (list of lists) and index is as example list[0] is first element (and in Python list[-1] the last element).
Some Python construct could be used in Expressions some other not, so your mileage may vary.
Good move is to make a proper post in a relevant forum section and asking for help there, probably Arch section as you are speaking of house will be a good place.
About parametric, FreeCAD is parametric, expressions and spreadsheet could improve the model if correctly done, usually most of the "input fields" in an object could support an expression and an expression could be a "reference" to a spreadsheet cell too.
Code: Select all
<<SpreadSheet1>>.wall_hei
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/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/