I am looking into exporting geometry from sketchup.
- if I make a face and apply a texture this is exported correctly.
- if I place an image into my viewport (screenshot is the entity info for this image) this gets ignored by my exporter. I am currently only looking at components, groups and faces.
Is there a way to cast this image to a face (preferably w texture) or any other method to be able to export this image as a mesh and a separate texture of some sort?
Care must taken. An “image” object in SketchUp is a special component instance whose definition has it’s image flag set
true. The image definition’s entities collection contains 1 face with a special “image owned” material object applied. The Ruby API has (recently) made it difficult to apply these image textures to other objects because this was never intended and can (and has) crashed some versions of the SketchUp application. One thing that was always the case is that no direct means of accessing the image instance’s definition is defined in the live Ruby API order to discourage messing with it’s entities collection (which can destabilize the model or a SKP file.)
Never attempt to paint a non-image object with an “image owned” material.
So also recently access was created (in both APIs) to a
SUImageRepRef object directly from an
SUImageGetImageRep. You can access the texture data directly from this representation class.
Also because of the need some 3rd party app programmers expressed reading SKP files, the C SDK does allow since v2021.1 (SDK v9.1) the direct access to an image instance’s definition via
So you can get the face through the definition, but it’s vertex positions will be in local coordinates. You would need to transform these positions using the image instance’s transformation in case it has been rotated and/or scaled.
I think (looking at the docs a bit) that you must access the UV texture coordinates through the face.
Direct manipulation (changing) of the image’s primitives (through it’s definition) is strongly discouraged.
The API should have enough information for you to correctly export this. You get the width and height and transformation of the Image from the API. Can you show us what code you currently have?