Typescript createItem functionality

let startPositionVector = new Vector3(0, 0, 0)
let endPositionVector = new Vector3(0, -5, 1)
let cameraExample = Scene.createCamera(startPositionVector)
let cylinder = Scene.createCylinder(endPositionVector)
let semiTorus = Scene.createSemiTorus(5,-5, 1)
semiTorus.speech = Scene.getItems().map(item => item.name).join(",\n")


This doesn’t set an Object Name for objects so I won’t be able to refer to them in a Block Code Script. Would love some ideas on how to solve this issue.

Hi @Alex_Hong,

You can set the name for each item you create:

let cylinder = Scene.createCylinder(endPositionVector);
cylinder.name = "My Awesome Cylinder";

Once you’ve done that, you can refer to the name in CoBlocks or Scripting. See this remixable example:

Thanks for the query - it’s cool to see that there’s more possibility of cross-over between Scripting and CoBlocks than initially thought. CoSpace Properties are the other thing they can share.

Hope this helps! Let me know if you have any further questions about this. If this solves your problem, please mark this post as the Solution.

Many thanks,
Geoff @ TechLeap

Simple solution! An almost “duh” moment for me, so I appreciate the thoughtful answer.

Interesting that the Scripts have higher priority and run first before the “Set Variable” block… or maybe the block code tries multiple times?

Can’t wait for all the amazing CoSpaces tutorials the community can and will make!

1 Like