Mark Szlazak wrote: ↑Sun Oct 28, 2018 4:05 pm
Hi Realthunder. Wondering if you have stopped working on ASM3? I did not see an update for a while.
Yes, I am doing some big changes on Expression related stuff. I haven't got time to write a document for that yet. Here is a brief summary.
I have refactored PropertyExpressionEngine and PropertySheet, to make them behave more like a link type property. So you can include sub-object reference or geometry reference inside your expressions, and they will be auto updated when your model changes, just like PropertyLinkSub in my branch.
I have also practically rewritten the Expression and its parser. Now, the expression becomes a functional language, which is modeled as a subset of Python. It does not support class and stuff, but has all the others, like if/else/while/for, including the handy list/set/dict comprehension. You can return any Python object from an expression, or call a method of an object. You can paste in multiple lines of Python code into a single spreadsheet cell, and then turn that cell into a function that accept parameters, and later call this function from other objects with expression binding. The property editor now has the option to show you all hidden properties and lets you bind expression on them, including the Shape property. You can copy a piece of Python code that generates a parametric shape, and binds it to various part feature with different parameters
FC has Macro since the beginning, but there is no easy way to pass in parameters. And my extended expression will fill that gap. However, with great ability comes great responsibility. The expression extension makes it possible to embed malicious code inside a file. Countermeasure is required to protect the end user. First of all, the expression code is not parsed and evaluated by Python interpreter. So we can filter out dangerous functions like eval() and open() etc. Second, the user can control which modules are allowed to be imported using FC parameter editor. More measure will be added later, such as showing user all the expression code before evaluation if the file has not been saved by the user before.