drag issue

24 views
Skip to first unread message

Outpost 31

unread,
Aug 29, 2017, 2:34:40 PM8/29/17
to CoSpaces Scripting
Hi I am trying to drag the cylinder up to the grid but I am having no luck
full code on the block is
container = Scene.createItem('EllipticCylinder', 0, 5.55,0); container.setColor(255,0,0); 

as well is there a way to flip it on it's side when it is created so the circle faces the user?
thanks for any help!
Screen Shot 2017-08-29 at 11.31.33 AM.png

Pavel Kakolin

unread,
Aug 29, 2017, 2:41:48 PM8/29/17
to cospaces-...@googlegroups.com
Hi there, 

The correct way to get item by its id is to use Scene.getItem(id) (notice lowercase g) function, not Scene.GetItem(id) that simply does not exist. I would also recommend you to use block with item dropdown list (in Scene Items category) instead of Coding block: 

Message has been deleted

Outpost 31

unread,
Aug 29, 2017, 3:09:24 PM8/29/17
to CoSpaces Scripting
Awesome thanks so much, it seems though I can drag the cylinder on DragZone1 but not onto DragZone2? As well is there a way to rotate the cylinder when it is created so the bottom faces the user?
Screen Shot 2017-08-29 at 12.11.30 PM.png

Pavel Kakolin

unread,
Aug 29, 2017, 4:34:51 PM8/29/17
to cospaces-...@googlegroups.com
One way to rotate cylinder after it is created is to use combination of two turn blocks:

DragZone2 in you example is cuboid behind graph area. Currently, you can't use addMoveOnItemInteraction with cuboids. 

Not sure what you are trying to achieve here, but I'd suggest you to use it with image billboard: rename it to DragZone2 and clear name of cuboid which is standing behind it.

Here is my final code: https://cospac.es/MZVC



Message has been deleted

Outpost 31

unread,
Aug 29, 2017, 5:44:52 PM8/29/17
to CoSpaces Scripting
Thanks for that, your example is perfect and I changed the cuboid to a billboard but it will still not drag onto the billboard as in your example.
Capture.PNG

Pavel Kakolin

unread,
Aug 29, 2017, 6:06:19 PM8/29/17
to cospaces-...@googlegroups.com
It is dragging, but looks like it is dragging on the other side of the billboard. Try to rotate billboard by 180 degrees so that this side will be facing camera.

Outpost 31

unread,
Aug 29, 2017, 6:09:58 PM8/29/17
to CoSpaces Scripting
Ha, yes that was it, so many things to learn, thanks so much for your patients.I really appreciate it!

Daniel Pers

unread,
Aug 30, 2017, 3:07:26 AM8/30/17
to CoSpaces Scripting
Hi Pavel

I am very interested in this kind of advice, but I do not quite understand it here.
When I need to use Object1 in a coding block (in the case where it was not created in the code), I use first:
Object1 = Scene.getItem (Object1Id)
You say that it is better to define an Object1 variable then to do:
Set Object1 to Object1, using a drop-down list (in Scene Items category).
Why this is preferable ?

Thank you

Daniel Pers

Pavel Kakolin

unread,
Aug 30, 2017, 3:57:06 AM8/30/17
to cospaces-...@googlegroups.com
Hi Daniel,

Topic starter in the code attached to the first post tries to use Coding block to get already existing (and even named) item by id and assign it to a variable.

I think it is preferable to use block from "Scene Items" category to do this because it won't allow to make coding mistakes eg to call non-existing methods just like it happened to TS.
Reply all
Reply to author
Forward
0 new messages