PhilC Designs :: View topic - Script to apply same MT5 to all materials


 

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  Plug-ins, Content & Tutorials for Poser
Script to apply same MT5 to all materials

 
Post new topic   Reply to topic    PhilC Designs Forum Index -> Python Scripting
View previous topic :: View next topic  
Author Message
PhilC
Site Admin


Joined: 23 Aug 2005
Posts: 4553
Location: Lawrenceburg Kentucky

PostPosted: Fri Oct 24, 2014 9:38 pm    Post subject: Script to apply same MT5 to all materials Reply with quote

Code:
# script to apply same MT5 to all materials
#
# METHOD:
# 1. Set up one material as required.
# 2. Save single material to the material library.
# 3. Run this script. You will be prompted to browse for the MT5 file
#    that you just saved. It will then be assigned to all the materials
#    in the figure.

import poser
import os
print

scene = poser.Scene()

def main():
    filepath = getMT5()
    fig = scene.CurrentFigure()
    print "Applying material library file:-"
    print filepath
    print "to %s." % fig.Name()
    for mat in fig.Materials():
        mat.LoadMaterialSet(filepath)
        shaderTree = mat.ShaderTree()
        shaderTree.UpdatePreview()
    scene.DrawAll()
    print "Task Completed"


def getMT5():
    type = poser.kDialogFileChooserOpen
    parentDialog = 1
    message = "Browse for MT5 file"
    print message
    startDir = os.path.join(os.curdir,'*.mt5')   
    browse = poser.DialogFileChooser(type, parentDialog, message, startDir)
    browse.Show()
    path = browse.Path()
    return path

main()

_________________
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    PhilC Designs Forum Index -> Python Scripting All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum software by p h p B_B © 2001, 2005 p h p_B B Gr0up