getting an object's dimensions/orientation etc

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

getting an object's dimensions/orientation etc

matthew venn
Hi all,

I'm a beginner openscad, but have been making some good progress recently.
One thing I find difficult is after creating objects and moving them about, how to move other objects in relation to the first object.
At the moment I push all the numbers into variables, then repeat all translations/rotations for all objects that need to stay in alignment.

What I would like is to be able to query an object to find out where its center point is.

Does anyone have an idea about how hard this would be to implement? I downloaded the source and tried to compile so I could have a go at making changes myself, but I've not been successful in setting up the environment yet.

Matt

--
Matthew Venn
mattvenn.net
Reply | Threaded
Open this post in threaded view
|

Re: getting an object's dimensions/orientation etc

Peter Falke
Hi Matt,

I cant answer your question of where you would have to look in the code or how to compile it.

I think one can not do what you want in a trivial way.
In OpenSCAD you can not assign a value to a variable at runtime at all.

This makes for a very special way that you have to write your programs.

Some people have written a "front end" in python to use variables. It then creates a intermediate OpenSCAD code.
I suggest looking there first.

Otherwise, post some of your OpenSCAD program on this list and we can look it over. Its easier to discuss these problems on some concrete example.

Greetings,

TakeItAndRun








On 18 December 2012 14:55, matthew venn <[hidden email]> wrote:
Hi all,

I'm a beginner openscad, but have been making some good progress recently.
One thing I find difficult is after creating objects and moving them about, how to move other objects in relation to the first object.
At the moment I push all the numbers into variables, then repeat all translations/rotations for all objects that need to stay in alignment.

What I would like is to be able to query an object to find out where its center point is.

Does anyone have an idea about how hard this would be to implement? I downloaded the source and tried to compile so I could have a go at making changes myself, but I've not been successful in setting up the environment yet.

Matt

--
Matthew Venn
mattvenn.net

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566



--
[hidden email]

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!
Reply | Threaded
Open this post in threaded view
|

Re: getting an object's dimensions/orientation etc

nophead
Take a look at http://rocklinux.net/pipermail/openscad/2012-November/003485.html 

On 19 December 2012 16:55, Peter Falke <[hidden email]> wrote:
Hi Matt,

I cant answer your question of where you would have to look in the code or how to compile it.

I think one can not do what you want in a trivial way.
In OpenSCAD you can not assign a value to a variable at runtime at all.

This makes for a very special way that you have to write your programs.

Some people have written a "front end" in python to use variables. It then creates a intermediate OpenSCAD code.
I suggest looking there first.

Otherwise, post some of your OpenSCAD program on this list and we can look it over. Its easier to discuss these problems on some concrete example.

Greetings,

TakeItAndRun








On 18 December 2012 14:55, matthew venn <[hidden email]> wrote:
Hi all,

I'm a beginner openscad, but have been making some good progress recently.
One thing I find difficult is after creating objects and moving them about, how to move other objects in relation to the first object.
At the moment I push all the numbers into variables, then repeat all translations/rotations for all objects that need to stay in alignment.

What I would like is to be able to query an object to find out where its center point is.

Does anyone have an idea about how hard this would be to implement? I downloaded the source and tried to compile so I could have a go at making changes myself, but I've not been successful in setting up the environment yet.

Matt

--
Matthew Venn
mattvenn.net

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566



--
[hidden email]

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566

Reply | Threaded
Open this post in threaded view
|

Re: getting an object's dimensions/orientation etc

matthew venn
looks interesting, I'll take a look and post back.
Matt

On 19 December 2012 17:11, nop head <[hidden email]> wrote:
Take a look at http://rocklinux.net/pipermail/openscad/2012-November/003485.html 


On 19 December 2012 16:55, Peter Falke <[hidden email]> wrote:
Hi Matt,

I cant answer your question of where you would have to look in the code or how to compile it.

I think one can not do what you want in a trivial way.
In OpenSCAD you can not assign a value to a variable at runtime at all.

This makes for a very special way that you have to write your programs.

Some people have written a "front end" in python to use variables. It then creates a intermediate OpenSCAD code.
I suggest looking there first.

Otherwise, post some of your OpenSCAD program on this list and we can look it over. Its easier to discuss these problems on some concrete example.

Greetings,

TakeItAndRun








On 18 December 2012 14:55, matthew venn <[hidden email]> wrote:
Hi all,

I'm a beginner openscad, but have been making some good progress recently.
One thing I find difficult is after creating objects and moving them about, how to move other objects in relation to the first object.
At the moment I push all the numbers into variables, then repeat all translations/rotations for all objects that need to stay in alignment.

What I would like is to be able to query an object to find out where its center point is.

Does anyone have an idea about how hard this would be to implement? I downloaded the source and tried to compile so I could have a go at making changes myself, but I've not been successful in setting up the environment yet.

Matt

--
Matthew Venn
mattvenn.net

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566



--
[hidden email]

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566



--
Matthew Venn
mattvenn.net
Reply | Threaded
Open this post in threaded view
|

Re: getting an object's dimensions/orientation etc

Whosawhatsis
The "correct" way to do what you are trying to do looks like this:

translate([10, 20, 30]) rotate([30, 60, 90]) {

  cube(20, center = true);

  translate([10, -10, 10]) sphere(10);

}

On Wednesday, December 19, 2012 at 9:18 AM, matthew venn wrote:

looks interesting, I'll take a look and post back.
Matt

On 19 December 2012 17:11, nop head <[hidden email]> wrote:
Take a look at http://rocklinux.net/pipermail/openscad/2012-November/003485.html 


On 19 December 2012 16:55, Peter Falke <[hidden email]> wrote:
Hi Matt,

I cant answer your question of where you would have to look in the code or how to compile it.

I think one can not do what you want in a trivial way.
In OpenSCAD you can not assign a value to a variable at runtime at all.

This makes for a very special way that you have to write your programs.

Some people have written a "front end" in python to use variables. It then creates a intermediate OpenSCAD code.
I suggest looking there first.

Otherwise, post some of your OpenSCAD program on this list and we can look it over. Its easier to discuss these problems on some concrete example.

Greetings,

TakeItAndRun








On 18 December 2012 14:55, matthew venn <[hidden email]> wrote:
Hi all,

I'm a beginner openscad, but have been making some good progress recently.
One thing I find difficult is after creating objects and moving them about, how to move other objects in relation to the first object.
At the moment I push all the numbers into variables, then repeat all translations/rotations for all objects that need to stay in alignment.

What I would like is to be able to query an object to find out where its center point is.

Does anyone have an idea about how hard this would be to implement? I downloaded the source and tried to compile so I could have a go at making changes myself, but I've not been successful in setting up the environment yet.

Matt

--
Matthew Venn
mattvenn.net

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566



--
[hidden email]

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566



--
Matthew Venn
mattvenn.net

Reply | Threaded
Open this post in threaded view
|

Re: getting an object's dimensions/orientation etc

donbright
In reply to this post by matthew venn
If you don't mind, please post any trouble you had getting it to compile here, and/or file a github issue. Thank you

-DB

On Tue, Dec 18, 2012 at 7:55 AM, matthew venn <[hidden email]> wrote:
Hi all,

I'm a beginner openscad, but have been making some good progress recently.
One thing I find difficult is after creating objects and moving them about, how to move other objects in relation to the first object.
At the moment I push all the numbers into variables, then repeat all translations/rotations for all objects that need to stay in alignment.

What I would like is to be able to query an object to find out where its center point is.

Does anyone have an idea about how hard this would be to implement? I downloaded the source and tried to compile so I could have a go at making changes myself, but I've not been successful in setting up the environment yet.

Matt

--
Matthew Venn
mattvenn.net

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566

Reply | Threaded
Open this post in threaded view
|

Re: getting an object's dimensions/orientation etc

Triffid Hunter
In reply to this post by matthew venn
On Wed, Dec 19, 2012 at 12:55 AM, matthew venn <[hidden email]> wrote:
> I'm a beginner openscad, but have been making some good progress recently.
> One thing I find difficult is after creating objects and moving them about,
> how to move other objects in relation to the first object.
> At the moment I push all the numbers into variables, then repeat all
> translations/rotations for all objects that need to stay in alignment.

$fa = 0.01;
$fn = 2; // change to 0.5 for final render using F6

print = 0; // 0 - display assembly, 1- plate for printing

module part1() {
   ...
}

module part2() {
   ...
}

module part3() {
  ...
}

if (print == 0) {
  translate([...]) rotate([...]) translate([...]) {
     translate([...]) part1();
     translate([...]) {
        part2();
        translate([...]) part3();
     }
  }
}
else {
   translate([...]) rotate([...]) part1();
   translate([...]) rotate([...]) part2();
   // part3 is a non-printed vitamin
}

Reply | Threaded
Open this post in threaded view
|

Re: getting an object's dimensions/orientation etc

Triffid Hunter
On Thu, Dec 20, 2012 at 2:22 PM, Triffid Hunter
<[hidden email]> wrote:
> $fn = 2; // change to 0.5 for final render using F6

sorry that should be $fs, not $fn

Reply | Threaded
Open this post in threaded view
|

Re: getting an object's dimensions/orientation etc

nophead
Where objects have a defined mating point I use this trick for easy alignment: 

module washer(type) {

    ....

    translate([0, 0, thickness])
        child();
}

Then I can make assemblies like this: -

   washer(jhead_washer)
       star_washer(screw_washer(jhead_screw))
           screw(jhead_screw, jhead_screw_length);


On 20 December 2012 03:23, Triffid Hunter <[hidden email]> wrote:
On Thu, Dec 20, 2012 at 2:22 PM, Triffid Hunter
<[hidden email]> wrote:
> $fn = 2; // change to 0.5 for final render using F6

sorry that should be $fs, not $fn
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566

Reply | Threaded
Open this post in threaded view
|

Re: getting an object's dimensions/orientation etc

Giles Bathgate-2

That's really smart!

Regards,
Giles

Reply | Threaded
Open this post in threaded view
|

Re: getting an object's dimensions/orientation etc

Peter Falke
Hi,

Yes, the child() command is really interesting and you could do a lot of neat things with it.
But I stopped using it because of problems with recursions being not allowed in OpenSCAD.

When you want to use two washers (or maybe two nuts) on one bolt you will get the error:
WARNING: Ignoring recursive module instantiation of 'translate'.

For an example, please look at the attached code.

In my view OpenSCAD handles the recursions to rigidly.
I dont understand why this is necessary.

Sincerly,

TakeItAndRun

Inline images 1

On 20 December 2012 09:27, Giles Bathgate <[hidden email]> wrote:

That's really smart!

Regards,
Giles


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566



--
[hidden email]

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!

screwtest.scad (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: getting an object's dimensions/orientation etc

nophead


On 20 December 2012 14:53, Peter Falke <[hidden email]> wrote:
Hi,

Yes, the child() command is really interesting and you could do a lot of neat things with it.
But I stopped using it because of problems with recursions being not allowed in OpenSCAD.
 
Yes I have similar problems. 

When you want to use two washers (or maybe two nuts) on one bolt you will get the error:
WARNING: Ignoring recursive module instantiation of 'translate'.

For an example, please look at the attached code.

In my view OpenSCAD handles the recursions to rigidly.
I dont understand why this is necessary.

I think it is just a bug in child(). There is no real recursion. 
 

Sincerly,

TakeItAndRun

Inline images 1

On 20 December 2012 09:27, Giles Bathgate <[hidden email]> wrote:

That's really smart!

Regards,
Giles


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566



--
[hidden email]

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566