Using Links

11 views
Skip to first unread message

David Estévez Fernández

unread,
Feb 6, 2013, 12:58:16 PM2/6/13
to oo...@googlegroups.com
Hello everyone!

I'm currently developing an object using OOML, and I would like to use the new Link and RefSys feature, but there is very little documentation about it.

I'm trying to attach one object to other object, in a way in which the links from both object coincide, but no matter where I place the link in the attachment, the object is always attached about its center.


I use:

        servo.attach(0, horn, 0);


And both the servo object and the horn object have one link added by me.

I have also checked the doxygen documentation, and the function 'attach' seems not to use the last parameter, the attachment link selector.

Am I doing something wrong or it is just that this feature is not complete yet ?

Alberto Valero Gomez

unread,
Feb 6, 2013, 1:08:47 PM2/6/13
to oo...@googlegroups.com
No you are not. Up to now it only attaches to the center of the figure as you have observed :)

Give me a week to implement it properly :D :D


--
You received this message because you are subscribed to the Google Groups "OOML" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ooml+uns...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

David Estévez Fernández

unread,
Feb 7, 2013, 11:20:38 AM2/7/13
to oo...@googlegroups.com
Thanks, I was going crazy trying to find the error.

I have another question also related to the links.

When I add multiple links to an object, using:

object.addLink( RefSys(x1, y1 , z1));
object.addLink( RefSys( x2, y2, z2));
...

The coodinates x2, y2, z2 seem to be relative to x1, y1, z1, but I want to specify them as absolute coordinates, how can I do that?


2013/2/6 Alberto Valero Gomez <alberto.va...@gmail.com>



--
---
David Estévez Fernández

Alberto Valero Gomez

unread,
Feb 7, 2013, 11:39:15 AM2/7/13
to oo...@googlegroups.com
If that is happening that is a bug. Coordiantes are always relative to the global reference system. if you can paste the whole code I will check it.

By the way. You can see the links of an object with the code

writer << LinksView(the_component);

Alberto.

David Estévez Fernández

unread,
Feb 7, 2013, 12:02:08 PM2/7/13
to oo...@googlegroups.com
Nice trick!

This is the code:

Component SkyMegaBoard::build()
{
    //-- PCB:
    Component pcb = RoundedTablet( side, side, thickness, side/20 );

    //-- Holes:
    Component hole_base = Cylinder( drill_diam/2.0, thickness + 0.1);
    Component hole01 = hole_base.translatedCopy(  drill_x/2.0,  drill_y/2.0, 0);
    Component hole02 = hole_base.translatedCopy( -drill_x/2.0,  drill_y/2.0, 0);
    Component hole03 = hole_base.translatedCopy(  drill_x/2.0, -drill_y/2.0, 0);
    Component hole04 = hole_base.translatedCopy( -drill_x/2.0, -drill_y/2.0, 0);
    Component holes = hole01 + hole02 + hole03 + hole04;

    //-- Make board:
    Component skymega = pcb - holes;

    //-- Add some links:
    //-- 4 for the upper side drills:
    skymega.addLink( RefSys(  drill_x/2.0,  drill_y/2.0, thickness/2.0));
    skymega.addLink( RefSys( -drill_x/2.0,  drill_y/2.0, thickness/2.0));
    skymega.addLink( RefSys(  drill_x/2.0, -drill_y/2.0, thickness/2.0));
    skymega.addLink( RefSys( -drill_x/2.0, -drill_y/2.0, thickness/2.0));

    //-- 4 for the lower side drills (looking downwards):
    skymega.addLink( RefSys(  drill_x/2.0,  drill_y/2.0, -thickness/2.0).relRotate(180,0,0));
    skymega.addLink( RefSys( -drill_x/2.0,  drill_y/2.0, -thickness/2.0).relRotate(180,0,0));
    skymega.addLink( RefSys(  drill_x/2.0, -drill_y/2.0, -thickness/2.0).relRotate(180,0,0));
    skymega.addLink( RefSys( -drill_x/2.0, -drill_y/2.0, -thickness/2.0).relRotate(180,0,0));

    //-- Put some color:
    skymega.color( 0.2, 0.2, 0.5);

    return skymega;
}

And in the main:

    SkyMegaBoard myTest;
    Component screw = Cylinder( 3/2.0, 20, 100, false).color(0.5, 0.5, 0.5, 0.7);

    for (int i = 0; i < 2; i++)
    myTest.attach( i, screw);


I'm also attaching an image of the result of this code.





2013/2/7 Alberto Valero Gomez <alberto.va...@gmail.com>
image01.png

Alberto Valero Gomez

unread,
Feb 7, 2013, 12:11:18 PM2/7/13
to oo...@googlegroups.com
Try this:

SkyMegaBoard myTest;
   
for (int i = 0; i < 2; i++){
    Component screw = Cylinder( 3/2.0, 20, 100, false).color(0.5, 0.5, 0.5, 0.7);
    myTest.attach( i, screw);
}

Lo que hacías es raro... porque estás moviendo siempre el mismo componente lo cual creo que no es posible... prueba a ver.

Alberto.

David Estévez Fernández

unread,
Feb 7, 2013, 12:32:15 PM2/7/13
to oo...@googlegroups.com
Now it works!! 

I thought I was attaching a copy of the screw, not the screw itself... too much time without programming in C++, I guess.

Thank you very much! :)

Alberto Valero Gomez

unread,
Feb 7, 2013, 3:37:03 PM2/7/13
to oo...@googlegroups.com
Well, it's not really a C++ issue, just a OOML design decision... in pyOOML in fact you make a copy, not move the object itself
Reply all
Reply to author
Forward
0 new messages