xshade

Basic module that is the foundation for Python in Shade.


xshade

List of Methods

beep Plays a beep
begin_timing Begins the timer
begin_timing_figure_window Begins timing Figure Window refreshes
create_dialog Creates a dialog object
create_dialog_with_uuid Creates a dialog object with the specified uuid
create_image Creates an image of the specified size and color depth
create_image_from_file Creates an image from the specified file
create_joined_image Creates a new image by combining multiple images horizontally
empty_image Creates an empty image object
end_timing Ends the timer
end_timing_figure_window Ends timing Figure Window refreshes and returns the time required for the window refreshes
euler_from_quaternion Converts a quaternion to the Euler value
get_amat Returns the transformation matrix for matching the directional vector A to the directional vector B
get_current_time The time since Shade launched
get_shadeexplorer_data_path Returns the path referenced by ShadeExplorer
get_zmat Returns the transformation matrix for matching the specified directional vector to the Z axis
idle Puts Shade in Idle Mode for the specified time
is_appstore_version Determines whether the build is an AppStore build or not
is_full Determines whether the build is a full build or not
load_color_list_1 Loads a color list settings file to Color List 1
load_color_list_2 Loads color list settings file to Color List 2
load_shortcut Loads a shortcut settings file
make_plane_equation Returns parameters for an equation defining the plane.
make_tv Returns a matrix that converts from global coordinates to perspective coordinates
message Outputs a text string to the Message Window
new_scene Opens a new scene document
open_scene Opens a Shade file
page_setup Displays the Page Setup dialog
play_sound Plays a sound file
quaternion_from_euler Converts a Euler value to quaternion
quit Quits Shade
reset_timing Resets the timer
save_color_list_1 Saves Color List 1
save_color_list_2 Saves Color List 2
save_shortcut Saves shortcut settings
show_message_box Displays the message box
show_yesnocancel_message_box Displays a dialog with "Yes", "No", and "Cancel"
sleep Puts Shade in Sleep Mode for the specified time
stop_sound Stops the sound currently playing
uniscale_rectangle Adjoins the inside of the circumscribed rectangle, and returns a rectangle with (nearly) the same aspect ratio as the reference rectangle
unmatrix Extracts scale, knife, rotation, and translation values from the transformation matrix




Method Details

beep

Plays a beep.

xshade.beep()

begin_timing

Begins the timer.
Used together with end_timing.
See also :
  begin_timing_figure_window

xshade.begin_timing()

begin_timing_figure_window

Begins timing Figure Window refreshes. Used together with
end_timing_figure_window. Use between
begin_timing and end_timing.

#Measure the time to move an object 10 times. 
xshade.begin_timing()
xshade.begin_timing_figure_window()
for i in xrange(10):
	xshade.scene().move_object(None, None, None, [1.0, 0.0, 0.0])
print xshade.end_timing_figure_window()
xshade.end_timing()

create_dialog

Creates a dialog object.
Return value :
  dialog object
Arguments :
  int : number : if specified, value is preserved : optional : if omitted, value is not preserved
If an arbitrary number is specified the value will be preserved, but it is possible for the value to conflict with another script.
IDs previously issued from the Shade Online Plugin/Script Developers Support page can be specified for arguments, in which case no conflict of values will occur.
Backwards compatibility
To preserve the value, using create_dialog_with_uuid is recommended.

dlg = xshade.create_dialog()

create_dialog_with_uuid

Creates a dialog object with the specified uuid.
Return value :
  dialog object
Arguments :
  uuid : 128 bit value : if specified, value is preserved : optional : if omitted, value is not preserved
See also :
  uuid

#Create a dialog, specifying uuid 583DA72C-F329-469E-BEDE-A0349DEAC74B
dlg = xshade.create_dialog_with_uuid('583DA72C-F329-469E-BEDE-A0349DEAC74B')

create_image

Creates an image of the specified size and color depth.
Return value :
  image object
Arguments :
  size : the image size
Arguments :
  int : the pixel color depth : optional
Available color depths :
  8 (byte/grayscale), 16 (half/grayscale), 32 (byte/RGBA), 64 (half/RGBA), 128 (float/RGBA)
See also :
  image
64 and 128 create an image with real color information.
64 and 128 create an image filled with black, whereas other options create an image with stripes or other noise.

#Create a image with color depth of 64 sized 100 by 200, and display it in a window
img = xshade.create_image((100, 200), 64)
img.create_window('sample')

create_image_from_file

Creates an image from the specified file.
Return value :
  image object
Arguments :
  file_path : extension (*.jpg, etc.) : If "None", opens a file dialog.
See also :
  image

#Create an image from a file and display it in a window
img = xshade.create_image_from_file(None)
img.create_window('sample')

create_joined_image

Creates a new image by combining multiple images horizontally.
Return value :
  image object
Arguments :
  images object
  The list of images to combine
See also :
  image

#Combine image_a and image_b and display in a window
image_a = xshade.create_image_from_file(None)
image_b = xshade.create_image_from_file(None)
img = xshade.create_joined_image([image_a,image_b])
img.create_window('sample')

empty_image

Creates an empty image object.
Return value :
  image object
See also :
  image

img = xshade.empty_image()

end_timing

Ends the timer.
See also :
  begin_timing

xshade.end_timing()

end_timing_figure_window

Ends timing Figure Window refreshes and returns the time required for the window refreshes.
Use together with begin_timing_figure_window.
Return value :
  The time required for the window refreshes
After calling begin_timing_figure_window() internally, runs figure_window paint (invalid for scripts) multiple times and returns the average time required.

print xshade.end_timing_figure_window()

euler_from_quaternion

Converts a quaternion to the Euler value.
Return value :
  float3
Arguments :
  quaternion
Because a unique conversion of quaternion and Euler values is not possible, a reverse conversion with quaternion_from_euler() does not result in the same value.

#Convert (1.0, 0.0, 0.0, 0.0) to Euler
print xshade.euler_from_quaternion((1.0, 0.0, 0.0, 0.0))

get_amat

Returns the transformation matrix for matching the directional vector A to the directional vector B.
Return value :
  mat4
Arguments :
  vec3 : directional vector A
Arguments :
  vec3 : directional vector B

#Output the transformation matrix for matching (1.0, 0.0, 0.0) to (0.0, 1.0, 0.0)
print xshade.get_amat((1.0, 0.0, 0.0),(0.0, 1.0, 0.0))

get_current_time

The time since Shade launched.
Return value :
  int : ms

#Output the time since Shade launched
print xshade.get_current_time()

get_shadeexplorer_data_path

Returns the path referenced by ShadeExplorer.
Return value :
  string

print xshade.get_shadeexplorer_data_path()

get_zmat

Returns the transformation matrix for matching the specified directional vector to the Z axis.
Return value :
  mat4
Arguments :
  vec3 : the directional vector to match to the Z axis

#Output the transformation matrix for matching (1.0, 0.0, 0.0) to the Z axis
print xshade.get_zmat((1.0, 0.0, 0.0))

idle

Puts Shade in Idle Mode for the specified time.
Arguments :
  ms : 1 sec is 1000 ms

#Output "Shade" 3 seconds later
xshade.idle(1800)
print 'Shade'

is_appstore_version

Determines whether the build is an AppStore build or not.
Return value :
  bool

#If the build is an AppStore version of Shade, display 1
print xshade.is_appstore_version()

is_full

Determines whether the build is a full build or not.
Return value :
  bool

#If the build is an full version of Shade, display 1
print xshade.is_full()

load_color_list_1

Loads color list settings file to Color List 1.
Arguments :
  file_path
See also :
  save_color_list_1

#Load settings file to Color List 1
dialog = xshade.create_dialog_with_uuid()
file_path = dialog.ask_path(True, '*.shdclt|shdclt')
xshade.load_color_list_1(file_path)

load_color_list_2

Loads color list settings file to Color List 2.
Arguments :
  file_path
See also :
  save_color_list_2

#Load settings file to Color List 2
dialog = xshade.create_dialog_with_uuid()
file_path = dialog.ask_path(True, '*.shdclt|shdclt')
xshade.load_color_list_2(file_path)

load_shortcut

Loads a shortcut settings file.
Arguments :
  file_path
See also :
  save_shortcut

#Load settings file to a shortcut
dialog = xshade.create_dialog_with_uuid()
file_path = dialog.ask_path(True, '*.shdshc|shdshc')
xshade.load_shortcut(file_path)

make_plane_equation

Returns parameters for an equation defining the plane.
Return value :
  float4
Arguments :
  vec3 : 3 tuples/lists

#Output parameters ((100.0, 0.0, 0.0), (200.0, 0.0, 0.0), (150.0, 100.0, 0.0))
print xshade.make_plane_equation(((100.0, 0.0, 0.0), (200.0, 0.0, 0.0), (150.0, 100.0, 0.0)))

make_tv

Returns a matrix that converts from global coordinates to perspective coordinates.
Return value :
  mat4
Arguments :
  f : vec3 : eye
Arguments :
  f : vec3 : target
Arguments :
  bank : float : bank
Arguments :
  shift : bool : tilt correction
Arguments :
  h_shift : float : shift
Arguments :
  v_shift : float : rise
Arguments :
  parallel : int : mode
Arguments :
  top_view : bool : parallel projection
As this is a legacy method, usingscene().world_to_view_matrix()is now recommended.

#Output the matrix from the current camera
camera = xshade.scene().camera
f = camera.eye
a = camera.target
bank = camera.bank
shift = False #Because this is a boolean, the current correction cannot be used
h_shift = camera.shift
v_shift = camera.rise
parallel = camera.camera_mode
top_view = camera.distant_camera
for i in (f,a,bank,shift,h_shift,v_shift,parallel,top_view):
	print i
print xshade.make_tv(f,a,bank,shift,h_shift,v_shift,parallel,top_view)

message

Outputs a text string to the Message Window.
Arguments :
  string

#Output "sample" to the Message Window
xshade.message('sample')

new_scene

Opens a new scene document.

xshade.new_scene()

open_scene

Opens a Shade file.
Return value :
  string
Arguments :
  file_path : extension (*.shd) : If "None", opens a file dialog.
See also :
  scene.save()

#Select a file to open
xshade.open_scene(None)

page_setup

Displays the Page Setup dialog.

xshade.page_setup()

play_sound

Plays a sound file.
Return value :
  bool
Arguments :
  file_path
Arguments :
  int : number of times to repeat (currently invalid)
See also :
  stop_sound

#Select a sound file to play
dialog = xshade.create_dialog_with_uuid()
file_path = dialog.ask_path(True, '*.wav|wav')
xshade.play_sound(file_path)

quaternion_from_euler

Converts a Euler value to quaternion.
Return value :
  quaternion
Arguments :
  float3 : Euler value
See also :
  euler_from_quaternion
Because a unique conversion of quaternion and Euler values is not possible, a reverse conversion with euler_from_quaternion() does not result in the same value.

#Output quaternion of (1.0, 0.0, 0.0)
print xshade.quaternion_from_euler((1.0, 0.0, 0.0))

quit

Quits Shade.

xshade.quit()

reset_timing

Resets the timer.
See also :
  begin_timing

xshade.reset_timing()

save_color_list_1

Saves Color List 1.
Arguments :
  file_path
See also :
  load_color_list_1

#Save Color List 1 settings
dialog = xshade.create_dialog_with_uuid()
file_path = dialog.ask_path(False, '*.shdclt|shdclt')
xshade.save_color_list_1(file_path)

save_color_list_2

Saves Color List 2.
Arguments :
  file_path
See also :
  load_color_list_2

#Save Color List 2 settings
dialog = xshade.create_dialog_with_uuid()
file_path = dialog.ask_path(False, '*.shdclt|shdclt')
xshade.save_color_list_2(file_path)

save_shortcut

Saves shortcut settings.
Arguments :
  file_path
See also :
  load_shortcut

#Save the shortcut settings
dialog = xshade.create_dialog_with_uuid()
file_path = dialog.ask_path(False, '*.shdshc|shdshc')
xshade.save_shortcut(file_path)

show_message_box

Displays the message box.
Return value :
  bool
Arguments :
  string : message
Arguments :
  bool : True : OK button and Cancel button are displayed. : False : Only OK button is displayed.

#Display a message box with sample string and OK/Cancel buttons
xshade.show_message_box('sample',True)

show_yesnocancel_message_box

Displays a dialog with "Yes", "No", and "Cancel".
Return value :
  int : 1: Yes, 0: No, -1: Cancel
Arguments :
  string

xshade.show_yesnocancel_message_box('Are you ready?')

sleep

Puts Shade in Sleep Mode for the specified time.
Arguments :
  ms : 1 sec is 1000 ms

#Output "hello" after 3 seconds
xshade.sleep(3000)
print 'hello'

stop_sound

Stop sound currently-playing.
See also :
  play_sound

xshade.stop_sound()

uniscale_rectangle

Adjoins the inside of the circumscribed rectangle, and returns a rectangle with (nearly) the same aspect ratio as the reference rectangle.
Return value :
  rectangle
Arguments :
  rectangle : the rectangle to circumscribe
Arguments :
  rectangle : the reference rectangle

#Output a rectangle from rectangle (0,0,100,200) and aspect ratio (0,0,1,3)
print xshade.uniscale_rectangle((0,0,100,200),(0,0,1,3))

unmatrix

Extracts scale, knife, rotation, and translation values from the transformation matrix.
Return value :
  vec3
Arguments :
  mat4

#Extract and output scale, knife, rotation, and translation values from the transformation matrix of the selected object
print xshade.unmatrix(xshade.scene().active_shape().transformation)