SOLVESPACE -- parametric 2d/3d CAD

(you are viewing a thread; or go back to list of threads)

Use of Variables for Constraints? (by Trakyan)
I've seen a couple of threads both here and on github about using variables. I haven't really understood the forum posts on it here, and the github threads have all been closed.

I'm still not sure how, or if it's possible, to use variables in solvespace. I.e. declare radius = 5 somewhere and then use 'radius' to dimension a part.

Could anyone shed some light on this for me?
Wed Feb 21 2018, 02:14:11
(no subject) (by Chinmay)
Look up forum posts here by Ryan Widi. The thread is named something like "command line interface". He created a Youtube video and a closed source exe of Solvespace. A plain text file is used to list all the variables and their values. This file is linked to the Solvespace file and the variables can then be used in a sketch (also possible to do math with variables).

Unfortunately, the example Ryan provided is closed-source. But, it is a big improvement in functionality. It is so easy to auto-generate the list of variables from any design/analysis code (MATLAB, C++, python, etc.) and the slvs file gets updated when you open it. Doesn't require a single mouse click.
Wed Feb 21 2018, 13:17:49
(no subject) (by Trakyan)
It's a shame it's closed source, and judging by the Github threads, wont be compatible with whatever the official fix for this will be since it sounds like there will be a new file format. This feature is probably the only thing stopping me from fully migrating to solvespace, that and maybe some scripting capability to generate things like gear profiles.

I actually find solvespace to have one of the best and cleanest UIs of any CAD program, it's the only graphical CAD program I've actually enjoyed using.
Wed Feb 21 2018, 19:54:40
(no subject) (by Chinmay)
I'm in the same boat. It's a little hard to decipher the current slvs format and auto-generate the files. If there's documentation of the new file format and coordinates/constraints are stored concisely, I'd prefer auto-generating the file to pointing and clicking every time.

Solvespace is indeed a superb application. These days one has to download gigabytes of packages just to write a hello-world application or draw a rectangle in CAD. Solvespace makes it trivial to get started, and it's elegant to require just one exe.
Wed Feb 21 2018, 21:07:57
(no subject) (by EvilSpirit)
Can someone do coding here? I can implement the core feature, but don't have so much time to spend on CLI interfaces etc.
Thu Feb 22 2018, 04:08:21
(no subject) (by Chinmay)
I have dealt with UI in the past, but the prospect of having to set up the build environment (VC++ or MingW) has deterred me from building Solvespace myself. My first hack would be to check if a text file of the same name as the slvs file was present in the working directory. If so, the variable names and values in that file could be read and used in the slvs file thereafter. I'm not sure how to code up the Menu and UI, but I'd be happier without them.
Thu Feb 22 2018, 21:13:40
(no subject) (by EvilSpirit)
The *simpliest* thing we could do is introduce the names for constraints. In this case, you can just find the needed constraint in slvs file and change it's dimension value. Or you can just use constraint h.v now for finding it.
Constraint.h.v=00000009 <<<< actually, now we can use this <<<< or can introduce this in UI
Constraint.valA=42.59999999999997300000 <<< change value here
Fri Feb 23 2018, 01:19:47
(no subject) (by EvilSpirit)
^^^^^ SLVS file
Fri Feb 23 2018, 01:20:44
(no subject) (by EvilSpirit)
^^^^^ SLVS file
Fri Feb 23 2018, 01:21:03
(no subject) (by EvilSpirit)
For easy building, I use Qt creator directly with CMake.
Most updated version with some experimental features you can find here
Fri Feb 23 2018, 01:29:33
(no subject) (by app4soft)
> Unfortunately, the example Ryan provided is closed-source.

It's look like violate with GNU GPLv3, that is a license[0] of SolveSpace sources...

> It is so easy to auto-generate the list of variables from any design/analysis code (MATLAB, C++, python, etc.) and the slvs file gets updated when you open it.

Think, need cast Kmol Yuan here ;-) Kmol Yuan already ported SolveSpace core to Python3 as "python-solvespace"[1,2] & write ontop "Pyslvs"[3] -- 2D dimensional planar linkage mechanism simulation and mechanical synthesis system! "Pyslvs" has PyQt5 GUI.




Fri Feb 23 2018, 22:32:23
(no subject) (by Trakyan)
I'd be happy without a specific UI, just a text file with variable names and values (support for some math would be cool, like trig, powers, sqrts etc.) that can be referenced when typing in a value for the dimension.

I don't know about anyone else but I think having to go through a separate UI would feel a bit more clunky to me than just writing a variable name from a text file into the dimension box.

And yeah, it does breach the license, but who's gonna chase him up in court over it? I know I can't.
Sat Feb 24 2018, 08:25:52
(no subject) (by Trakyan)
As for programming, my experience is very limited, and I wouldn't know where to start. I've only ever really done work with micro controllers, OpenSCAD and that one python course I had to do at Uni. I wish I could be of help, but my open source contributions look like they'll be predominantly on the hardware side.
Sat Feb 24 2018, 08:28:42
(no subject) (by EvilSpirit)
I've made a prototype:
Sun Feb 25 2018, 07:22:23
(no subject) (by app4soft)
> I've made a prototype:

@EvilSpirit, AWESOME!

Hope, it could be merged in "master" tree as soon as possible.
Sun Feb 25 2018, 08:38:18
(no subject) (by Paul)
I always thought it would be nice to put the name/value pairs in the text window and have them saved in the .slvs file. I can also see the value in having something like #include to link in a text file of such named constraints. There's already a way to link in different sketches right? Could a .slvs file with only named values be used like a #include in C?
Sat Mar 3 2018, 23:15:24
(no subject) (by EvilSpirit)
I think we could assemble files with defined variables and reference them by using "linked_group_name.var_name". When we define some parameter, we can do it visible inside group only, or mark it "public" and make it visible when making assemblies.
Tue Mar 6 2018, 00:46:42
(no subject) (by 3dsman)
realy cool this new function.
Is it possible to share a variable value between multiple files?
Thu Apr 26 2018, 07:36:07
(no subject) (by Trakyan)
Awesome, exactly what I was looking for. Also interested in whether it can be shared between different parts/slvs files or whether each variable is just within the one slvs file. I didn't really get a good idea of how it worked in the video.
Fri Jun 29 2018, 04:20:03
(no subject) (by Paul)
The video is very cool, but I think we still want to be able to define variables in the text window with NAME: Value and then use them by name in a sketch.

I'd also want them to be reused on multiple instances of the same imported part but with different values. I think this is along the lines whitequark was thinking for solvespace 3.0 which requires a lot of rework on the internals.
Fri Jun 29 2018, 18:10:26
(no subject) (by EvilSpirit)
You are right - the feature is not completed. Whitequark stopped woriking on integration of my impovements, so I am not interested to continue develop this feature. The second thing why I not able to finish is what I develop my own project This is very similar to SolveSpace, but have independent codebase and some of SolveSpace's problems were solved. Now project is in alpha-version stage - too many bugs, issues, so I don't force promotion. But it is already useable - at least you can load STL and edit it.
Mon Jul 2 2018, 01:54:47
(no subject) (by whitequark)
I haven't been able to work on SolveSpace for several months due to health issues. However, I am now able to spend significant time on it again. I hope that EvilSpirit would continue his great work on SolveSpace, and that the improvements in Notecad could be integrated in it.
Thu Jul 12 2018, 16:54:07
(no subject) (by Eric Buijs)
Whitequark, I'm sorry to hear about your health issues. I hope everything is alright now.
Mon Jul 30 2018, 03:54:54
use JSON format? (by William Adams)
Would it be possible to import/use JSON files for this?

I've been working on a system to have CNC projects modeled in OpenSCAD:

and am extracting the parameters from the JSON file which OpenSCAD saves and then loading that to make cut files --- using Solvespace for this would make things more generally useful I believe.
Wed Dec 5 2018, 13:02:17
Solvespace with named variable (by Ryan widi)
no its not closed, i already upload on github long time ago

I still use solvespace for small fast project, since i run Laser cutting and CNC workshop.
Wed Mar 20 2019, 06:32:24
(no subject) (by trakyan)
Ryan, any chance you could give me a brief rundown on how to instal your version on manjaro? The lack of variables as constraints is the only thing holding me back from shifting to solvespace entirely.
Fri Apr 5 2019, 00:48:28
Alternately, could one use Solvespace to model a polyhedron and export to OpenSCAD? (by William Adams)
Still trying to wrap my mind around doing opensource parametric design, and wish there was a nice graphical tool for it.

Worked through the first tutorial in Solvespace but got stuck by not having a middle mouse button on my stylus.

Any other options / controls for that sort of thing?
Sun Apr 7 2019, 10:58:11
(no subject) (by EvilSpirit)
> Worked through the first tutorial in Solvespace but got stuck by not having a middle mouse button on my stylus.

Use Shift+Right instead of middle for rotating view. Use selection of some enetities and F key for zooming, Ctrl+A and F for showing all, or +/- keys.
Thu Apr 11 2019, 00:14:40
stylus only as left click (by William Adams)
No right-click option (it's a Samsung S-Pen)
Sun Apr 14 2019, 09:17:23
Solvespace with named variable (by sebastien)

I know this feature request is old, but I would like to know if it is still in the dev backlog or if it has been canceled?

For sure, as mentioned in various thread, the variable name and potentially formula that goes with it is a very useful feature used in several professional CAD software (from SolidEdge/NX to Catia). Good part of solvespace versus these proprietary solutions : slvs files are human readable, so it helps to find workarounds.

On my side, as probably lots of people, I am using external scripts to recompute valA thanks to external entries, maintaining the link between (re)computed Constraint.valA and Constraint.h.v, as suggested by EvilSpirit on that thread.
But it is a bit clunky to go back and forth scripts manipulating files... if there is no available time to develop this feature in a future mainline release, I wanted to know if is there any dev or architecture document available (such as an UML scheme) to better understand the code structure (and to get some basic guidance instead of digging on top of everything).

Additionally to the sole name variable feature, this might be linked to others (and potentially asked in several other threads)
- parsing and processing expression in formula (with standard maths operands) would be the next step
- general "parameters table", collecting all named constraints and expression in variables (even when assembly)

Tue Jun 29 2021, 06:31:23
(no subject) (by Paul)

The EvilSpirit demo was updated to master a while ago on one of my personal "parameters" branch here:

I'll try to rebase that to current master soon (tonight if I remember and have time).

The original open issue is still there:

I would like to add the suggestion in this comment:

That should be possible without breaking file compatibility, but it's also going to open a huge can of worms because it will only be a partial implementation. I think that would be a good step because then the real challenging parts will be moved front and center.

In particular, I think having a separate file with parameter names and values will be the first ask. I also foresee questions about "scope". Since each group is solved separately, how should we handle named parameters that are defined in previous groups? Can we override previously defined parameters with ones of the same name? What about linked files? That's why this was really supposed to depend on hierarchical sketches getting implemented.
Tue Jun 29 2021, 13:22:52
Post a reply to this comment:
Your Name:
Your Email:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):
© 2008-2021 SolveSpace contributors. Most recent update Apr 18 2021.