class TextureWriter

Parent: Object | Class Index
Methods: count, filename, handle, length, load, write, write_all |
Sample Code: TextureWriter.rb |

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, each in the SketchUp model, into the TextureWriter object.
2. write_all or write - write all of the loaded textures (or individual textures) to files.

Instance Methods

count
The count method is used to determine the number of textures loaded into the texture writer.
Syntax:
count = texturewriter.count
Arguments:
Return Value:
count - the number of textures loaded in the texture writer
Comments:
Example:
count = tw.count

filename
The filename method is used to retrieve the original filename for a particular texture.
Syntax:
filename = texturewriter.filename handle
Arguments:
handle - the index or handle of the texture in the texture writer
Return Value:
filename - the filename of the texture on the file system
Comments:
Example:
filename = tw.filename 1

handle
The handle method is used to retrieve a handle or index for a specific texture in the texture writer.
Syntax:
handle = texturewriter.handle entity, <side>
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)
Return Value:
handle - the index for the entity in the texture writer
Comments:
Example:
index = tw.handle myface

length
The length method is used to determine the number of textures loaded into the texture writer.
Syntax:
length = texturewriter.count
Arguments:
Return Value:
length - the number of textures loaded in the texture writer
Comments:
Example:

load
The load method is used to load one or more textures into the texture writer for writing out to a file.
Syntax:
handle = texturewriter entity, <side>
Arguments:
entity - 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)
Return Value:
handle - the index or handle of the entity that was loaded
Comments:
Example:
index = tw.load myface

write
The write method is used to write an individual textures, within the texture writer, to a file.
Syntax:
status = texturewriter.write entity, <side>, filename
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)
Return Value:
status - one of three status messages (see comments)
Comments:
(0) FILE_WRITE_OK (1) FILE_WRITE_FAILED_INVALID_TIFF (2) FILE_WRITE_FAILED_UNKNOWN
Example:
retval = tw.write(ent, true, "C:\\textures\\A.jpg")

write_all
The write_all method is used to write all textures, held in the texture writer, to files.
Syntax:
status = texturewriter.write_all directory, filetype
Arguments:
directory - the directory for the textures being written filetype - the file naming convention to be used (true for 8.3, false for extended)
Return Value:
status - one of three status messages (see comments)
Comments:
(0) FILE_WRITE_OK (1) FILE_WRITE_FAILED_INVALID_TIFF (2) FILE_WRITE_FAILED_UNKNOWN
Example:
tw.write_all("C:\\textures", false)