My favorites | English | Sign in

Google SketchUp Ruby API

TextureWriter

class

Parent: Object

Introduction

SketchUp 6.0+

The TextureWriter class is used primarily for writing the textures used in a SketchUp model out to files as part of an export for use in another application. These methods are usually invoked in this order:

  • 1. load - load one or more textures from a model into the TextureWriter.
  • 2. write_all or write - write the texture(s) to file.

Methods

TextureWriter.countSketchUp 6.0+

The count method is used to determine the number of textures loaded into the texture writer.

Returns:

count
the number of textures loaded in the texture writer
 count = tw.count

TextureWriter.filenameSketchUp 6.0+

The filename method is used to retrieve the original filename for a particular texture.

Arguments:

handle
The index or handle of the texture in the texture writer.

Returns:

filename
the filename of the texture on the file system
 filename = tw.filename 1

TextureWriter.handleSketchUp 6.0+

The handle method is used to retrieve a handle or index for a specific texture in the texture writer.

Arguments:

entity
A face, image, component instance, group, or layer.
side
If the entity is a face, the side represents the side whose handle you are retrieving (true if front, false if back.)

Returns:

handle
the index for the entity in the texture writer.
 index = tw.handle myface

TextureWriter.lengthSketchUp 6.0+

The length method is used to determine the number of textures loaded into the texture writer. This is an alias of the count method.

Returns:

length
the number of textures loaded in the texture writer
 length = texturewriter.count

TextureWriter.loadSketchUp 6.0+

The load method is used to load one or more textures into the texture writer for writing out to a file.

Arguments:

entity
A face, image, component instance, group, or layer to load.
side
If the entity is a face, the side is used to indicate the side of the face being loaded (true if front, false if back).

Returns:

handle
the index or handle of the entity that was loaded
 index = tw.load myface

TextureWriter.writeSketchUp 6.0+

The write method is used to write an individual textures, within the texture writer, to a file.

This method will return one of the following status messages. (These are constants that are defined by the API.)

  • 0 = FILE_WRITE_OK
  • 1 = FILE_WRITE_FAILED_INVALID_TIFF
  • 2 = FILE_WRITE_FAILED_UNKNOWN
  • Arguments:

    entity
    A face, image, component instance, group, or layer to write.
    filename
    The name of the file to contain the texture.
    side
    If the entity is a face, the side is used to indicate the side of the face being written (true if front, false if back.)

    Returns:

    status
    one of three status messages (see comments.)
     return_val = tw.write(ent, true, "C:\\textures\\A.jpg")
     if return_val == FILE_WRITE_OK
       UI.messagebox("File successfully written.")
     end

TextureWriter.write_allSketchUp 6.0+

The write_all method is used to write all of the textures within the texture writer to files. It will return one of three status numbers:

  • 0 = FILE_WRITE_OK
  • 1 = FILE_WRITE_FAILED_INVALID_TIFF
  • 2 = FILE_WRITE_FAILED_UNKNOWN
  • Arguments:

    entity
    A face, image, component instance, group, or layer to write.
    dirname
    The directory to write to.
    side
    If the entity is a face, the side is used to indicate the side of the face being written (true if front, false if back.)

    Returns:

    status
    one of three status messages (see comments.)
     return_val = tw.write_all("C:\\textures\\", true)