-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Core] Allow properties owned by the document to be used in expressions #10653
base: main
Are you sure you want to change the base?
[Core] Allow properties owned by the document to be used in expressions #10653
Conversation
afea933
to
ad61d58
Compare
@JohnAD the branch for expression engine. |
855e773
to
3741ba7
Compare
3741ba7
to
e9262c6
Compare
How is this one going @AjinkyaDahale ? Any progress? |
It's probably going to take a good while longer. The changes are quite deep and I haven't been able to get a compilable code before making all of the changes at the same time. That said, @JohnAD was able to make some workaround which checks for the type of the property container solely in There is also an option of falling back to a "dummy" document object, but that is more inelegent than the present attempt. |
e9262c6
to
856c7e8
Compare
I've been playing a bit with this here but cannot get any further than you 😅 |
As promised, an example of why both the document and the document properties need prefixes: The user makes a new document:
What does a. The document Since we know document properties and document object names are separate namespaces (and can collide), we are already planning on having the document-properties having a hash prefix. So (a) above is now What about In other words, the "document names" and "object name" namespaces will also collide. So, if the document name always has a prefix, such as
And even:
Or even what is not allowed (yet):
In the documentation we can simply explain the general rules: prefix document property names with |
@JohnAD I see a bit clearer what you mean here. Of course we would need to make sure existing mechanisms are not broken. For example in I have some doubts about what happens if some of the properties themselves evaluate to another document or document object. For example if
I think you mean "prefix property name with |
bd7717e
to
dec33cc
Compare
@JohnAD I see a flaw here. Consider [1] As such, we would also need a method to describe files from different folders. |
dec33cc
to
7c60072
Compare
I see what you are saying. We could possibly make an empty Or we could be more explicit, perhaps an empty paren. So, |
6df5841
to
eb1e625
Compare
aaab849
to
7e178eb
Compare
In collaboration with John Dupuy.
Also contains: [Core] Some more attempts at identifying `$` token [Core] Fix identifying `$` sign in parser
In collaboration with John Dupuy. Finished Spreadsheet expression test; started on document property test Finished document property expression binding test
Needed to support properties belonging to documents.
…dentifier`" This reverts commit 855e773. Keeping Graphviz changes and taking one step at a time.
From `DocumentObject` to `PropertyContainer`
So that Documents can also be containers.
7e178eb
to
6a7fda5
Compare
@AjinkyaDahale and @JohnAD, I think this is a great way to improve the parameter system. After studying the code, I agree this is a very challenging topic and should be done carefully, especially with compatibility issues in mind. I have some questions and comments. Regarding the prefixes a first observation is that there are multiple interfaces to properties:
The discussion above only discusses the expression engine interface. I think it makes sense to make a distiction between fully qualified names and partially qualified names. Currently, the expression engine is "smart" in the sense that it automatically restores fully qualified names to partially qualified names. For example after making a Part Cube in a document saved as "mydoc.FCStd": doc = App.ActiveDocument
doc.Box.addProperty("App::PropertyFloat", "MyProp")
doc.Box.MyProp = 6 Using the GUI to set the Length of the Box to Making a second Cube and setting the length to This only discusses the expression interface, but the Python interface should also be taken into account. In the example above Note that this is already the case in other parts of FreeCAD: I cannot make a property "Shape" in
It is a bit strange that FreeCAD allows a property "Box" if there is already a "Box" object. By the way, in Python In my humble opinion the case for document properties should follow the same semantics as for object properties: it should not be possible to have properties with the same name as objects, so it should not be possible to make a property The benefit is that adopting these semantics make things much more simple. So, following this logic, in my humble opinion, I don't see the need for an extra prefix in the expression engine: Note that this is only valid if we are talking about fully qualified names. The problems arise when there is ambiguity in partially qualified names and I believe your additional prefix solution tries to address this problem as well. I think the way forward would be to default to fully qualified names internally and use other mechanisms for scoping than the expression engine now offers. This is another topic that is more fitting in the discussion of the issue Ondsel-Development#5 than in this conversation on this pull request, but in the context of this pull request Since I only took a look at the code while you have been actually working on it, I'm sure I missed something, so I'm looking forward to your comments. |
I like @pieterhijma's idea... It would solve a lot of issues (although it introduced s more work too), and it could be dealt with on a simple "first come first served" basis, same as when adding new objects. In case a name already exists, then we would have two different behaviours:
|
Dear all, I've created an issue for the problem that this PR addresses in the FreeCAD repo: #12120. |
@AjinkyaDahale @pieterhijma what's the status on this PR? Will it be resumed or replaced by VarSet? If you want this draft PR to be considered for a version 1.0 release, it should be marked ready for review by Monday, 2024-06-03 at the latest. (further details in the 1.0 feature freeze forum announcement). |
Draft PR. Nothing to see here, for now.
Addresses Ondsel-Development#5 but does not completely solve it (expression completion to follow in a separate PR).
There are two parts to this problem: