Skip to content
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

Warning for modules that shouldn't have children. #41

Open
WillAdams opened this issue Jul 16, 2022 · 3 comments
Open

Warning for modules that shouldn't have children. #41

WillAdams opened this issue Jul 16, 2022 · 3 comments
Labels

Comments

@WillAdams
Copy link

WillAdams commented Jul 16, 2022

If one has modules such as "setupcut" and "gcut" in https://github.com/WillAdams/gcodepreview/blob/main/gcodepreviewing.scad

and one calls them using a file such as:

include <C:/Users/willa/OneDrive/Documents/RapCAD/Libraries/gcodepreview.scad>

difference() {
  setupcut(9, 4, 1, "Top", "Center")

  gcut(0, 0, 0, 4.5, 2, -1, 390);

}

the text appears out-of-order in the console:

G1 X 0  Y 0 Z 0
G1 X 4.5  Y 2 Z -1
(STOCK/BLOCK,  9 ,  4 ,  1 )
G90
G21
(Move to safe Z to avoid workholding)
G53G0Z-5.000
M05
Total compiling time: 0h 0m 0s 20ms.
Я:

and in the file.

Adding the semicolon:

include <C:/Users/willa/OneDrive/Documents/RapCAD/Libraries/gcodepreview.scad>

difference() {
  setupcut(9, 4, 1, "Top", "Center");

  gcut(0, 0, 0, 4.5, 2, -1, 390);

}

Outputs things as expected:

(STOCK/BLOCK,  9 ,  4 ,  1 )
G90
G21
(Move to safe Z to avoid workholding)
G53G0Z-5.000
M05
G1 X 0  Y 0 Z 0
G1 X 4.5  Y 2 Z -1
Total compiling time: 0h 0m 0s 76ms.
Я: 
@WillAdams WillAdams changed the title writeln text from modules appears out of order missing semicolon causes writeln text from modules appears out of order Jul 16, 2022
@WillAdams WillAdams changed the title missing semicolon causes writeln text from modules appears out of order missing semicolon causes writeln text from modules to appears out of order Jul 16, 2022
@WillAdams WillAdams changed the title missing semicolon causes writeln text from modules to appears out of order missing semicolon causes writeln text from modules to appear out of order Jul 16, 2022
@GilesBathgate
Copy link
Owner

GilesBathgate commented Jul 16, 2022

@WillAdams Well, it's actually a feature.

This allows you to position objects relatively. i.e:

cube([1,1,1])
  translate([0,0,1]cube([2,2,2])
    translate([0,0,2])cube([3,3,3]);

I admit it probably doesn't make sense for writeln, I guess it could emit a warning.

writeln("c") { 
   writeln("a");
   writeln("b");
}

Warning: nested writeln will output in hierarchical order

@WillAdams
Copy link
Author

Oh. I would have put all those in groups using {} if writing things out by hand.

The warning makes a lot of sense --- feel free to close this ticket or leave it open as a reminder to implement that.

@GilesBathgate
Copy link
Owner

I would have put all those in groups using {} if writing things out by hand.

Yes this is probably clearer.

cube([1,1,1]) {
  translate([0,0,1]cube([2,2,2]) {
    translate([0,0,2])cube([3,3,3]);
  }
}

But I have to support both for it to work consistently. The idea is inspired by so called relativity.scad: https://github.com/davidson16807/relativity.scad

@GilesBathgate GilesBathgate changed the title missing semicolon causes writeln text from modules to appear out of order Warning for modules that shouldn't have children. Jul 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants