Miscellaneous Classes

LWLoadState

The LWLoadState class is somewhat different than the raw interface of the LightWave SDK. Python-based “helpers” methods have been substituted for most of its functions.

class lwsdk.LWLoadState(*args)

Bases: object

Proxy of C++ PCore::LWLoadState class

 ioMode → int

Indicates whether the file contents will be interpreted as binary (lwsdk.LWIO_BINARY) or text (lwsdk.LWIO_ASCII). Handler plug-ins that receive the LWLoadState in their instance load function can usually infer from the ioMode whether they're reading their data from a scene file or an object file.

In ASCII mode, all of the read functions are line-buffered, meaning that they won't wrap around to the next line when reading an array of values. If you ask for six numbers and the current line contains only five, the read functions will return five values rather than trying to get the sixth from the following line.

 lwload_depth() → int

Returns the current block nesting level, where 0 means we've entered no blocks.

 lwload_dp(int count) → (result, double[])

Read a sequence of double-precision floating point numbers (i.e., doubles) of up to count elements. Returns a Python tuple whose first element is the result code, and whose second is the sequence of double values. The result code will be a positive integer value representing the number of elements actually read (which should match the len() of the data sequence), or -1 for end of data.

 lwload_end()

Move the file pointer to the end of the current block. Call this when you've finished reading a block.

 lwload_find(LWBlockIdent ids[]) → LWBlockIdent

Read ahead, looking for the next block. The ids list is a Python sequence of LWBlockIdent structures, and the function returns when it finds any one of the blocks in the list. In binary mode, a block is identified by a 4-byte integer constructed using the lwsdk.LWID_() function. In ASCII mode, the block ID is a string token. Returns None if no blocks in the list were found.

 lwload_fp(int count) → (result, float[])

Read a sequence of floating point numbers of up to count elements. Returns a Python tuple whose first element is the result code, and whose second is the sequence of floating point values. The result code will be a positive integer value representing the number of elements actually read (which should match the len() of the data sequence), or -1 for end of data.

 lwload_i1(int count) → (result, char[])

Read an array of bytes of up to count elements. These are interpreted as numbers rather than text characters. Returns a Python tuple whose first element is the result code, and whose second is the sequence of byte values. The result code will be a positive integer value representing the number of elements actually read (which should match the len() of the data sequence), or -1 for end of data.

 lwload_i2(int count) → (result, short[])

Read an array of signed shorts (two-byte integer values) of up to count elements. Returns a Python tuple whose first element is the result code, and whose second is the sequence of short values. The result code will be a positive integer value representing the number of elements actually read (which should match the len() of the data sequence), or -1 for end of data.

 lwload_i4(int count) → (result, int[])

Read an array of signed integers (four-byte integer values) of up to count elements. Returns a Python tuple whose first element is the result code, and whose second is the sequence of integer values. The result code will be a positive integer value representing the number of elements actually read (which should match the len() of the data sequence), or -1 for end of data.

 lwload_id(int ids[]) → id

Read a block identifier. id is a sequence of LWBlockIdent structures, and the method returns the first match of the read identifier with any one of the blocks in the list. In binary mode, a block is identified by a 4-byte integer constructed using the lwsdk.LWID_() function defined in the lwtypes.h header file. In ASCII mode, the block ID is a string token. Returns 0 if no blocks in the list were matched.

 lwload_read(int count) → (result, byte[])

Read raw bytes. In binary mode, count bytes are read directly from the file. In ASCII mode, up to count bytes of the current line are read from the file, possibly leaving more bytes to be read later (the file pointer isn't moved to the next line until all of the current line is read).

The return value is a Python tuple containing the result code in the first element, and a sequence of data read (which may be empty in ASCII mode if the current line is empty) in the second. The result code will be a positive integer value representing the number of elements actually read (which should match the len() of the data sequence), or -1 for end of data.

 lwload_str() → (result, string)

Reads a string. Double quotes used to delimit the string in a text file are removed. The return value is a Python tuple containing the result code in the first element, and a sequence of data read (which may be empty in ASCII mode if the current line is empty) in the second. The result code will be a positive integer value representing the length of the string read, or -1 for end of data.

 lwload_u1(int count) → (result, byte[])

Read an array of unsigned bytes of up to count elements. These are interpreted as numbers rather than text characters. Returns a Python tuple whose first element is the result code, and whose second is the sequence of unsigned byte values. The result code will be a positive integer value representing the number of elements actually read (which should match the len() of the data sequence), or -1 for end of data.

 lwload_u2(int count) → (result, short[])

Read an array of unsigned shorts (two-byte integer values) of up to count elements. Returns a Python tuple whose first element is the result code, and whose second is the sequence of unsigned short values. The result code will be a positive integer value representing the number of elements actually read (which should match the len() of the data sequence), or -1 for end of data.

 lwload_u4(int count) → (result, int[])

Read an array of unsigned integers (four-byte integer values) of up to count elements. Returns a Python tuple whose first element is the result code, and whose second is the sequence of unsigned integer values. The result code will be a positive integer value representing the number of elements actually read (which should match the len() of the data sequence), or -1 for end of data.

LWSaveState

The LWSaveState class is somewhat different than the raw interface of the LightWave SDK. Python-based “helpers” methods have been substituted for most of its functions.

class lwsdk.LWSaveState(*args)

Bases: object

Proxy of C++ PCore::LWSaveState class

ioMode

LWSaveState_ioMode_get(LWSaveState self) -> int

lwsave_begin(self, id, int leaf)
lwsave_depth(self) → PyObject
lwsave_dp(self, PyObject buffer)
lwsave_end(self)
lwsave_fp(self, PyObject buffer)
lwsave_i1(self, PyObject buffer)
lwsave_i2(self, PyObject buffer)
lwsave_i4(self, PyObject buffer)
lwsave_id(self, id)
lwsave_str(self, PyObject buffer)
lwsave_u1(self, PyObject buffer)
lwsave_u2(self, PyObject buffer)
lwsave_u4(self, PyObject buffer)
lwsave_write(self, PyObject buffer)
valid(self) → bool
writeData

LWSaveState_writeData_get(LWSaveState self) -> void

Table Of Contents

Previous topic

Raster Funcs

Next topic

The Python Reduced Instruction Set

This Page