SketchUp Ruby scripts to custom iOS Viewer app

In my project I need to create 3D objects with SketchUp Ruby scripts and save them into a file. Later, these 3D objects will be loaded into and displayed in an iOS app. User can view/pan/zoom, and he/she can click an object to display information related to it.
What I’m not confident is the last step. When a user clicks on an object, is it possible for me to get its identifier? I assume that when building these 3D objects with scripts I can put the identifier somewhere.
I have no experience on Ruby API but have experiences on SketchUp and Ruby, btw.

In what format will they get to the ios app? In what app?

1 Like

Ken asks this because Trimble does not release an .skp file API for iOS.
This means you will have to use an external format and an iOS compatible API for this external format.

1 Like

Entities have ID’s though these are local to the session. Persistant IDs are kept between sessions.
But it sounds like you maybe want to set your own attribute on your objects ;entity.set_attribute('ExampleSection', 'ExampleKey', 'ExampleValue')

But if you plan to load the SKP file directly, I don’t know how you would access it. Our C API is for macOS, not iOS.

Oh, I didn’t notice this. I used SketchUp Viewer on iOS and it can load my saved SketchUp file so I took it for granted that skp file can be loaded directly in iOS. Can Ruby API exports the objects into an iOS compatible format?

Since it cannot be skp file, I just use any other compatible format that suites my needs.
Are you saying that the ID set in SketchUp object can be retrieved in iOS app? May I know how? I do want to set my own ID as your code showed.

But, in which viewer? Surely something can be custom made. I do not believe we can make extensions for the mobile viewer.

The viewer that I’m currently use is

For sure to serve my purposes I’ll need to build a viewer on my own. I’m just worrying if this can be done.
BTW, I had used Unity to import skp file and created an iOS app to display it. I’m thinking to create the viewer this way. Still I’m wondering if I can get the object id when an user choose an object in the app.

I have no idea what your ultimate goal is. I would advise trying to use a standard format like glTF, DAE, OBJ or FBX.

This can be done in unity. If you control both the viewer app itself as the .skp to yourformat converter, you can add any data you want and do something with it in the viewer.

I can help you with that if needed.