If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
Dynamic Duplication
7 posts
• Page 1 of 1
Dynamic Duplication
I built this schematic. Basically I am able to click on the square in the window, and drag it around on the screen.
I would like to know if there is an easy way to dynamically create a new square so that when I drag the mouse away from the square, it stays there, but a new square is created.
I am pretty certain that I can do it using Ruby, but I was wondering if there might be an answer using just components?
- alexalthauser
- Posts: 9
- Joined: Thu Jan 20, 2011 7:29 am
Re: Dynamic Duplication
Not to 'bump' this post, but I wanted to add that a module which could build and place other stored modules would be incredibly useful.
- alexalthauser
- Posts: 9
- Joined: Thu Jan 20, 2011 7:29 am
Re: Dynamic Duplication
Is it possible to do this?
Yes, sort of. You would have to make a finite set of squares in forehand that is hidden until some user interaction will unhide them at the desired place. If it is easy or not depends on you and you skills. I really cant think of any examples atm either.
As you suggest Ruby is the best method here. But I am not that skilled with Ruby yet so I cant give you any good advice other than that.
Yes, sort of. You would have to make a finite set of squares in forehand that is hidden until some user interaction will unhide them at the desired place. If it is easy or not depends on you and you skills. I really cant think of any examples atm either.
As you suggest Ruby is the best method here. But I am not that skilled with Ruby yet so I cant give you any good advice other than that.
- tor
- Posts: 114
- Joined: Fri Sep 24, 2010 5:54 pm
Re: Dynamic Duplication
I tried to make an example for you. It is very basic and can make only two squares:
First click (and hold) anywhere in the field to make square 1. Drag to desired position.
Then click (and hold) on square 1 to make nr 2. Drag to desired position.
Click Reset button to restart the procedure.
It should be fairly easy for you to make more squares. If you need more guidance (I did not comment the scematic) please tell and I shall see if I can. It is also possible to move the squares after placement with some more logic not implemented here.
First click (and hold) anywhere in the field to make square 1. Drag to desired position.
Then click (and hold) on square 1 to make nr 2. Drag to desired position.
Click Reset button to restart the procedure.
It should be fairly easy for you to make more squares. If you need more guidance (I did not comment the scematic) please tell and I shall see if I can. It is also possible to move the squares after placement with some more logic not implemented here.
- tor
- Posts: 114
- Joined: Fri Sep 24, 2010 5:54 pm
Re: Dynamic Duplication
You don't necessarily need 'hidden' elements either.
The trick is to keep all of the data about each "object" in an array of some kind - and draw the objects by looping through the array. Once you have that structure, adding a new object is just a matter of adding new data to the array.
Similarly you can then delete objects by removing them from the array.
My 'button array' example shows an example of the kind of system needed - there's no adding/removing items currently - but everything is in place there to make it possible.
Something similar could also be done using primitives - float arrays and a 'Draw Loop'. The stock "multi-stage envelope" uses this approach to allow the number of envelope stages to be changeable.
The trick is to keep all of the data about each "object" in an array of some kind - and draw the objects by looping through the array. Once you have that structure, adding a new object is just a matter of adding new data to the array.
Similarly you can then delete objects by removing them from the array.
My 'button array' example shows an example of the kind of system needed - there's no adding/removing items currently - but everything is in place there to make it possible.
Something similar could also be done using primitives - float arrays and a 'Draw Loop'. The stock "multi-stage envelope" uses this approach to allow the number of envelope stages to be changeable.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
Don't stagnate, mutate to create!
-
trogluddite - Posts: 1730
- Joined: Fri Oct 22, 2010 12:46 am
- Location: Yorkshire, UK
Re: Dynamic Duplication
Tor:
I can follow some of the schematic, but other parts I don't understand. It works nicely though. I will work some more on studying it.
Trog:
I will have to learn a bit more about Ruby, but I understand most of the code.
I'm off to a good start, thank you both.
I can follow some of the schematic, but other parts I don't understand. It works nicely though. I will work some more on studying it.
Trog:
I will have to learn a bit more about Ruby, but I understand most of the code.
I'm off to a good start, thank you both.
- alexalthauser
- Posts: 9
- Joined: Thu Jan 20, 2011 7:29 am
Re: Dynamic Duplication
Just tell if you need more info
Glad to help
Glad to help
- tor
- Posts: 114
- Joined: Fri Sep 24, 2010 5:54 pm
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 75 guests