How to convert file of triangles to SU surface?

Onward in the quest.

Consider a file listing (x,y,z) coordinates of points (each point labeled 1,2,3,…, say) and a list of lines between points ( say in form (5,19), (12,82),…). The set of lines are further grouped so they form triangles. That is, all possible polygons are resolved to triangles. Each triangle has a color. Call this a CS file.

I will write a simple python program to semi-automatically convert an ordered sequence of cross-section image files to CS file format. (I think this will be a lot simpler than doing the equivalent within SU.) Assume that the cross-section files are such that this procedure is well-defined.

I would like to convert a CS file into something that SU can read and turn into an actual colored surface, where the mesh lines are hidden.

I don’t expect detailed instructions here. It would be very useful for, (1) an indication whether, given a CS file, this is actually possible with SU, and if so, (2) a roadmap map pointing me to the appropriate file formats and how to import into SU.

This is not necessarily reducing SU to a 3D viewer, because I anticipate that the mesh will have to be modified in SU to make the information conveyed by the surface more comprehensible and to round out rough spots.

Thanks.

to build the geometry

colored surface

mesh lines are hidden

&&

Thank you.

If I’m not mistaken, you sent me references to classes which make up part of the sketchup system, and are written Ruby, a language I do not wish to learn or use. I am not looking to add to the sketchup system, as much as I would probably find that interesting. My project really is just to develop a visualization of brain anatomy based on specific existing images (coronal sections), and not general application development. For me, the more specific the better.,

For my project, the creation of the software (in Python) is the least of the problems, and I expect it to go fast because of the very specialized nature of my cross sections. The hard part is setting up an interactive system so that one can quickly and easily create the x,y,z coordinates of the various polygons which are already outlined in the cross-section images, by clicking with a mouse. The setting up will not be a problem. But using it will involve tons of mouse clicking, which will, frankly, take up most of the time.

There are probably systems out there which will of what I want, but they cost lots of money and require existing specialized data which I don’t have access to.

But thank you for your interest.

Yet, you posted a request in SketchUp’s Ruby API subcategory.

For extensions running within SketchUp’s application process, you only have two choices of coding language:

The C API can also be used standalone for writing out SKP files from a 3rd party application or command line utility. (It might be possible that someone has already written Python binders to the SketchUp C API.)

If this is the route you must take, then really this topic should be reassigned to the C SDK subcategory.

SketchUp is specifically developed to model buildings and associated furnishings (indoor and outdoor.) It has a 0.001 inch vertex tolerance. So, it is not so good at modeling small things and has problems with very small faces in meshes. Basically, if vertex coordinates are within the tolerance they are combined which could leave holes in your mesh.

What some modelers do for small objects is model them at a larger scale as a component, then place a scaled down instance in the model.

I do not think I would choose SketchUp for such a project. I would look into creating a glTF or glB model file instead and using the many viewers or perhaps a web browser viewer implemented in JavaScript. (They already exist and are free to use.)