|
SketchUp Ruby API Reference |
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:
Parent: Object
Methods: count, filename, handle, length, load, write, write_all
Example Code: texturewriter.rb
The count method is used to determine the number of textures loaded into the texture writer.
count = texturewriter.count
count - the number of textures loaded in the texture writer
count = tw.count
The filename method is used to retrieve the original filename for a particular texture.
filename = texturewriter.filename handle
handle - the index or handle of the texture in the texture writer
filename - the filename of the texture on the file system
filename = tw.filename 1
The handle method is used to retrieve a handle or index for a specific texture in the texture writer.
handle = texturewriter.handle entity, <side>
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)
handle - the index for the entity in the texture writer
index = tw.handle myface
The length method is used to determine the number of textures loaded into the texture writer.
length = texturewriter.count
length - the number of textures loaded in the texture writer
The load method is used to load one or more textures into the texture writer for writing out to a file.
handle = texturewriter entity, <side>
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)
handle - the index or handle of the entity that was loaded
index = tw.load myface
The write method is used to write an individual textures, within the texture writer, to a file.
status = texturewriter.write entity, <side>, filename
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)
status - one of three status messages (see comments)
(0) FILE_WRITE_OK
(1) FILE_WRITE_FAILED_INVALID_TIFF
(2) FILE_WRITE_FAILED_UNKNOWN
retval = tw.write(ent, true, "C:\\textures\\A.jpg")
The write_all method is used to write all textures, held in the texture writer, to files.
status = texturewriter.write_all directory, filetype
directory - the directory for the textures being written
filetype - the file naming convention to be used (true for 8.3, false for extended)
status - one of three status messages (see comments)
(0) FILE_WRITE_OK
(1) FILE_WRITE_FAILED_INVALID_TIFF
(2) FILE_WRITE_FAILED_UNKNOWN
tw.write_all("C:\\textures", false)