davidson16807 / relativity.scad Goto Github PK
View Code? Open in Web Editor NEWThe OpenSCAD General Library of Relativity
The OpenSCAD General Library of Relativity
It appears that 'color()' directives underneath an align()
directive are ignored. I rely on colors to understand the resulting picture, so this is a rather serious hindrance for me. I am new to OpenSCAD, so I don't know that digging in to solve this myself is probably not a good approach.
I've tried to use colored()
but the output results appear to be the same. The stumper is that the demo with the sphere and rods works. I've been trying to make slow, incremental changes to the demo, but once I get my two boxes involved, something goes wonky.
Oh yeah, and every time I use colored, I get a lot of these warnings:
Here are some examples:
No call to align()
, both colors show up:
{ // Both colors shown
color([ 1, 0, 0, 0.3 ])
box([ housing_botton_length, housing_bottom_width, servo_body_height ], anchor = [ -1, -1, -1 ]);
color([ 0, 0, 1, 1 ])
box([ housing_cutout_length, housing_cutout_width, housing_cutout_height ], anchor = [ 1, 1, -1 ]);
} // Both colors shown
Call to color()
above align()
call, both boxes are the same (top) color:
{ // Both boxes red
color([ 1, 0, 0, 0.3 ])
box([ housing_botton_length, housing_bottom_width, servo_body_height ], anchor = [ 1, 1, -1 ])
color([ 0, 0, 1, 1 ])
align([ 0, 0, 1 ])
box([ housing_cutout_length, housing_cutout_width, housing_cutout_height ], anchor = [ 1, 1, -1 ]);
} // Both boxes red
Call to color()
below align()
call, both boxes are the same (top) color:
{ // Both boxes red
color([ 1, 0, 0, 0.3 ])
box([ housing_botton_length, housing_bottom_width, servo_body_height ], anchor = [ 1, 1, -1 ])
align([ 0, 0, 1 ])
color([ 0, 0, 1, 1 ])
box([ housing_cutout_length, housing_cutout_width, housing_cutout_height ], anchor = [ 1, 1, -1 ]);
} // Both boxes red
I don't know enough about relativity.scad
to know if this is my fault somehow, or not, but it's making things rather tough to suss out. If it's my fault, and anyone knows what's going on here I'd appreciate the help. Thanks!
I'm trying to align tops for box and a sphere. Anchor seems has no effect at all. How do I do that?
include <relativity.scad/relativity.scad>;
//
//%box(50, anchor=[0,0,-1])
// color("red") translate([0, 0, -30]) {
// align([0,0,1])
// %%sphere(d=60);
// }
%box(50, anchor=[0,0,-1])
color("red")
align([0,0,1])
%%sphere(d=60, anchor=[0,0,1]);
The "hide()" module does not work with the default geometric primitives (like cube, cylinder, sphere). These are still rendered. Also nearly every other module uses the "hide()" module, so the problem occurs very often!
I have no (good) idea how to fix this. Perhaps a variable only available in relativity.scad-modules that enables the hide()-module to identify non-relativity.scad-children and therefore not rendering the sub-tree? Would this work with single default transformation in between a sub-tree (like a normal translate() or what ever)?
In the table describing the selectors the last selector seams to be at least a copy-paste error, because it contains ".png" (simply search for "(parent child),B grandchild.png" in the wiki).
By the way, great work with the lib!
But I need more documentation, I just reached the end :D. And for example the "orient" module seams to be able to use lists of vectors (see "orient([x,y,z])" in the examples), but this isn't documented under the orient section.
include <relativity.scad>
box(50, anchor=[0,0,-1])
align([0,1,0])
orient([0,1,1])
rod(d=50, h=50, anchor=[0,0,-1]);
WARNING: len() parameter could not be converted, in file C:/Users/1/Documents/OpenSCAD/libraries/relativity.scad, line 918
WARNING: len() parameter could not be converted, in file C:/Users/1/Documents/OpenSCAD/libraries/relativity.scad, line 868
WARNING: len() parameter could not be converted, in file C:/Users/1/Documents/OpenSCAD/libraries/relativity.scad, line 887
WARNING: len() parameter could not be converted, in file C:/Users/1/Documents/OpenSCAD/libraries/relativity.scad, line 887
Why???
OpenSCAD version 2019.05
For small projects where your library is a submodule, it would be convenient to just clone what's required for the thing to work and skip the 40MBs of .STLs in the body
demo, for instance.
I don't know enough about git, but maybe there's a way people could clone progressively, first shallow then complete... The idea is to help people bootstrap quicker and always with the latest code. Open to suggestions!
include <C:\Users\herve\Downloads\openscad-2019.05\libraries\relativity.scad\strings.scad>
cube(10);
Console throw
Parsing design (AST generation)...
Saved backup file: C:/Users/herve/Documents/OpenSCAD/backups/unsaved-backup-FQfmFakr.scad
Compiling design (CSG Tree generation)...
WARNING: Too many unnamed arguments supplied, in file openscad-2019.05/libraries/relativity.scad/strings.scad, line 820
WARNING: Too many unnamed arguments supplied, in file openscad-2019.05/libraries/relativity.scad/strings.scad, line 820
WARNING: Too many unnamed arguments supplied, in file openscad-2019.05/libraries/relativity.scad/strings.scad, line 820
WARNING: Too many unnamed arguments supplied, in file openscad-2019.05/libraries/relativity.scad/strings.scad, line 820
WARNING: Too many unnamed arguments supplied, in file openscad-2019.05/libraries/relativity.scad/strings.scad, line 820
Compiling design (CSG Products generation)...
Geometries in cache: 1
Geometry cache size in bytes: 728
CGAL Polyhedrons in cache: 0
CGAL cache size in bytes: 0
Compiling design (CSG Products normalization)...
Normalized CSG tree has 1 elements
Compile and preview finished.
Total rendering time: 0 hours, 0 minutes, 0 seconds
Rod does not fully replace cylinder, as it only take r, not r1,r2 to make cones.
rod([6, 6, 2.25], anchor = [0,0,1], $class = "nut", $fn= 6);
cylinder(d = 6, h = 2.25, $fn = 6);
if you try to compare this objects you will see that rod is wider and not really even hexagon;
rod([6, 5.2, 2.25], anchor = [0,0,1], $class = "nut", $fn= 6);
cylinder(d = 6, h = 2.25, $fn = 6);
experimantally I found than x/y ratio of 6 to 5.2 makes nearly even hexagon. This result seems to be odd, cause in first case we 6mm between two sides and two verticies. Checking a few nuts and specifications [http://archicad-talk.graphisoft.com/files/filepages_from_16._nuts__bolts__screws_and_washers_559.pdf] see page 1 table 16.1 and page 2 figure 16.1(b), I would expected to see rod([6, 5.5, 2.25]) to be same size as d=6 cylinder, but it was still bigger.
I have to add and rod(... , $fn= 2^n) is fine, It means if u have vertex at +Pi/2 and -Pi/2. otherwise the rod is a bit wider at Y side.
In OpenSCAD 2021.01 there's a warning on line 429
WARNING: undefined operation (undefined - number) in file ../../../../Documents/OpenSCAD/libraries/relativity/relativity.scad, line 429
I wondered if you could make use of this more generalised version of orient ;)
module orient(a,b) {
angle=acos((a*b)/(norm(a)*norm(b)));
rotate(a=angle,v=cross(a,b))
children();
}
where a and b are vectors.
If echoing the version on export isn't essential I would suggest to remove it.
I came across an issue where I was trying to set up git hooks and because of that echo the command's exit code is non-zero and the commit fails.
Sorry if it's inappropriate to create an issue for that, but it's just hurts to see such a great library to have a majority of commits being older than 7 years. OpenSCAD constantly throws warnings at me as I use it, but it steel works. It would be so awesome if someone would continue development.
I'm trying basic examples from wiki, like
use <../relativity.scad/relativity.scad>;
box(50, anchor=[0,0,-1])
align([0,0,1])
sphere(d=60);
and get this
instead of this:
from the wiki.
I'm running OpenScad 2015.03 on OS X (10.11.6) and latest commit (6d5cc88) of
https://github.com/davidson16807/relativity.scad
Apologies if I'm missing something obvious.
When starting to use your library, I found a couple of small syntax issues, namely a missing ?
and a missing ;
in the function _css_select
. I have included a diff below, and I'll try to do a pull request if needed (it's only two lines that need to be changed, though). Thanks.
diff --git a/relativity.scad b/relativity.scad
index e114c6a..174e1f9 100644
--- a/relativity.scad
+++ b/relativity.scad
@@ -237,10 +237,11 @@ function _css_select(tag, class, id, selector, index=0) =
id == after(selector, "#")
: starts_with(selector, ".") ?
_has_token(class, after(selector, "."))
- : starts_with(selector, "*")
+ : starts_with(selector, "*") ?
id == after(selector, "#") || _has_token(class, after(selector, ".")) || tag == selector
:
tag == selector
+ ;
//echo(_has_all_tokens("foo bar baz", "foo baz"));
//echo(_has_all_tokens("foo bar baz", "spam baz"));
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.