Planning to do some work on Sketch solver
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Planning to do some work on Sketch solver
Hi everyone.
I've been playing around a bit with the sketch solver lately and I'm planning to make some improvements. One of the things I want to do is implement variables and expression (http://www.freecadweb.org/tracker/view.php?id=800). Just want to know if someone else is working on the same thing or if there are some inputs from the rest of you.
Cheers,
Johan
I've been playing around a bit with the sketch solver lately and I'm planning to make some improvements. One of the things I want to do is implement variables and expression (http://www.freecadweb.org/tracker/view.php?id=800). Just want to know if someone else is working on the same thing or if there are some inputs from the rest of you.
Cheers,
Johan
Re: Planning to do some work on Sketch solver
It doesn't seem so. Good luck!Just want to know if someone else is working on the same thing or if there are some inputs from the rest of you
- tanderson69
- Veteran
- Posts: 1626
- Joined: Thu Feb 18, 2010 1:07 am
Re: Planning to do some work on Sketch solver
Some relevant forum threads:
viewtopic.php?f=9&t=4359
viewtopic.php?f=10&t=6354
Some relevant mantis tickets:
http://www.freecadweb.org/tracker/view.php?id=1098
http://www.freecadweb.org/tracker/view.php?id=1437
Some relevant branches, with origin being sourceforge:
The sticking point on these ideas is how the expressions are stored in the document and related to features. Specific links to discussion beginnings:
viewtopic.php?f=9&t=4359&start=80#p50832
viewtopic.php?f=10&t=6354&start=30#p54546
viewtopic.php?f=9&t=4359
viewtopic.php?f=10&t=6354
Some relevant mantis tickets:
http://www.freecadweb.org/tracker/view.php?id=1098
http://www.freecadweb.org/tracker/view.php?id=1437
Some relevant branches, with origin being sourceforge:
Code: Select all
origin/master-spreadsheet
Code: Select all
origin/tanderson-dev-expressions1
viewtopic.php?f=9&t=4359&start=80#p50832
viewtopic.php?f=10&t=6354&start=30#p54546
Re: Planning to do some work on Sketch solver
Hi Johan,
I've thought about doing some work that might work nicely with what you're proposing. Maybe we could sync up sometime, but I'm a bit busy with real (well, at least paying) work for at least the next few days.
Basically, what I was considering is allowing python variables to be used in many of the places where numbers are currently used. For instance, a person could use the GUI to set the rotation angle of a part to some python variable, say hourAngle, rather than a number, then if that number were changed in the python interpreter, the drawing would be updated appropriately. The hourAngle variable would be attached to the document object as an attribute, saved and loaded as appropriate, etc.
I've not done much more than think about how this would work from the user's perspective, but I assume that a first step would be to facilitate adding python attributes to Document objects. It's also entirely possible that the feature I'm imagining exists already and I just haven't looked hard enough for it. -Ian-
I've thought about doing some work that might work nicely with what you're proposing. Maybe we could sync up sometime, but I'm a bit busy with real (well, at least paying) work for at least the next few days.
Basically, what I was considering is allowing python variables to be used in many of the places where numbers are currently used. For instance, a person could use the GUI to set the rotation angle of a part to some python variable, say hourAngle, rather than a number, then if that number were changed in the python interpreter, the drawing would be updated appropriately. The hourAngle variable would be attached to the document object as an attribute, saved and loaded as appropriate, etc.
I've not done much more than think about how this would work from the user's perspective, but I assume that a first step would be to facilitate adding python attributes to Document objects. It's also entirely possible that the feature I'm imagining exists already and I just haven't looked hard enough for it. -Ian-
Re: Planning to do some work on Sketch solver
Hi all
Ian a couple of points that immediately spring to mind ...you have quite possibly already thought of these.
1) no Python code is saved into the fcstd file as deliberate design decision, as a security measure ....so no one can save the Python code for "please wipe my HDD" or some such thing, into the FreeCAD file where an expecting user could open the file and have the Python code automatically executed.
2) the input would have to not clash with the Units functionality.
Jim
Ian a couple of points that immediately spring to mind ...you have quite possibly already thought of these.
1) no Python code is saved into the fcstd file as deliberate design decision, as a security measure ....so no one can save the Python code for "please wipe my HDD" or some such thing, into the FreeCAD file where an expecting user could open the file and have the Python code automatically executed.
2) the input would have to not clash with the Units functionality.
Jim
Re: Planning to do some work on Sketch solver
Hi there!!
This is something that is also on my list. I share my thoughts with you.
Because of the way properties system works, my first thought was not try to embed the functionality into the existing Sketcher Module (Or any other module). I would do a separate module that sets the properties values based on formulas. This is the case of the Spreedsheet module, but you could use that or whatever else you might like, like an Octave module (similar to Matlab), or sage (NumPy, SciPy, matplotlib, Sympy, Maxima).
Problem with the first thought: The Sketchs, Pads, ... still show a numerical value, instead of a relationship (L/2).
My second thought is still in progress, and tackles the problem with the first thought. This implies making a new class (an new type) that has the interface of a double (internally I think all the units are doubles), but internally stores relationships (L,L/2,sqrt(L)). The object having an identity relationship has to define the value (L,32 mm). For that to happen, it is necessary to define new Property Editors, that can handle this kind of expressions. This Editors would only allow to edit the value of objects having an identity relationship (L, 32 mm). The editor would have to the right the option of calling an edit dialog (Like placement property has), This dialog would allow to edit either a identity relationship (L, 32 mm), or a relationship (L/2).
That solution should allow to work based only on magnitudes, with relationships, and should allow to load old files (backwards compatibility). A separate tool, integral part of FreeCAD, would allow to list all the objects of that class like a property view, and modify their values...
The inventor view will have two modes (value/relationship), and will show the actual value or the relationship depending on the mode selected.
Of course that is a though in progress...
This is something that is also on my list. I share my thoughts with you.
Because of the way properties system works, my first thought was not try to embed the functionality into the existing Sketcher Module (Or any other module). I would do a separate module that sets the properties values based on formulas. This is the case of the Spreedsheet module, but you could use that or whatever else you might like, like an Octave module (similar to Matlab), or sage (NumPy, SciPy, matplotlib, Sympy, Maxima).
Problem with the first thought: The Sketchs, Pads, ... still show a numerical value, instead of a relationship (L/2).
My second thought is still in progress, and tackles the problem with the first thought. This implies making a new class (an new type) that has the interface of a double (internally I think all the units are doubles), but internally stores relationships (L,L/2,sqrt(L)). The object having an identity relationship has to define the value (L,32 mm). For that to happen, it is necessary to define new Property Editors, that can handle this kind of expressions. This Editors would only allow to edit the value of objects having an identity relationship (L, 32 mm). The editor would have to the right the option of calling an edit dialog (Like placement property has), This dialog would allow to edit either a identity relationship (L, 32 mm), or a relationship (L/2).
That solution should allow to work based only on magnitudes, with relationships, and should allow to load old files (backwards compatibility). A separate tool, integral part of FreeCAD, would allow to list all the objects of that class like a property view, and modify their values...
The inventor view will have two modes (value/relationship), and will show the actual value or the relationship depending on the mode selected.
Of course that is a though in progress...
Re: Planning to do some work on Sketch solver
Guys, since most of you "new coders" of FreeCAD are here, if any of you would like to be upgraded to developer on the bug tracker, so you can attribute bugs to yourself, or close bugs, or help with triaging, etc... just tell me, I'll gladly do it.
Re: Planning to do some work on Sketch solver
Hi everyone.
There seems to be a fair amount of interest in working on this issue. I guess we should be able to collaborate at least to some extent. My main focus is to bring this functionality to the Sketcher and link it to the sketch solver. I guess extending the reach of the code may well be possible but I want to focus on a limited scope.
Ian: I don't believe in the idea of linking the sketcher variables to some python variables. However, I do think they should be exposed through a python interface to allow python code to change the variables.
Abdullah: Have you checked out what tanderson69 linked as related forum threads?
Tanderson69: Thanks for all the links and code references!
/Johan
There seems to be a fair amount of interest in working on this issue. I guess we should be able to collaborate at least to some extent. My main focus is to bring this functionality to the Sketcher and link it to the sketch solver. I guess extending the reach of the code may well be possible but I want to focus on a limited scope.
Ian: I don't believe in the idea of linking the sketcher variables to some python variables. However, I do think they should be exposed through a python interface to allow python code to change the variables.
Abdullah: Have you checked out what tanderson69 linked as related forum threads?
Tanderson69: Thanks for all the links and code references!
/Johan
Re: Planning to do some work on Sketch solver
I am not that skillful, but I am looking in Mantis for jobs that seem doable by me, so why not... currently I am working in the utf support for the data properties and in bejant's bug/request to rotate symetric symbol to make it perpendicular to line of symmetry.if any of you would like to be upgraded to developer on the bug tracker, so you can attribute bugs to yourself, or close bugs, or help with triaging, etc... just tell me, I'll gladly do it.
Not at all. I have just thrown what was in my mind.Abdullah: Have you checked out what tanderson69 linked as related forum threads?
Re: Planning to do some work on Sketch solver
Hi Jim,
Would be interested to know more about the "deliberate design decision", because it seems like a competing solution might have been to use a sandboxed Python interpreter in FreeCAD. As things stand now, the macro functionality in FreeCAD seems to allow the same sort of security hole you're describing.
I do understand that's how things work at the moment, but haven't looked into the details. I'm mainly interested in adding the ability to access values that are already stored in the FreeCAD file, as Python variables, so on it's own this wouldn't really involve saving python code into the FreeCAD file.jmaustpc wrote: 1) no Python code is saved into the fcstd file as deliberate design decision, as a security measure ....so no one can save the Python code for "please wipe my HDD" or some such thing, into the FreeCAD file where an expecting user could open the file and have the Python code automatically executed.
Would be interested to know more about the "deliberate design decision", because it seems like a competing solution might have been to use a sandboxed Python interpreter in FreeCAD. As things stand now, the macro functionality in FreeCAD seems to allow the same sort of security hole you're describing.
Agreed, and I think this shouldn't be too much of a problem. -Ian-jmaustpc wrote: 2) the input would have to not clash with the Units functionality.