Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® MotionBuilder® / Python / figure out file name and create log.txt
  RSS 2.0 ATOM  

figure out file name and create log.txt
Rate this thread
 
31229
 
Permlink of this thread  
avatar
  • Total Posts: 9
  • Joined: 10 November 2008 07:55 PM

Hi, guys

I’m mixed up with this problem.
I wrote rename script and I wonder if it create memo log.txt at same time
maybe it gonna be much more usefull to use.

This is limited but if I named file like ‘test_v001_05.fbx’
when I use this script, it create ‘test_v002_01’ and ‘log.txt’.

The probrem is… this script ran first time but not second time…
Are there someway to fix this probrem?

this is my script↓
-------------------------------------------------------------------------------------------------
from pyfbsdk import*
import os

lApp = FBApplication()
lFileFullName = lApp.FBXFileName
lFilePath = os.path.dirname(lFileFullName)
lFileName = os.path.basename(lFileFullName)
lFileVerNumber = lFileName[-10:-7]
lFileNumber = lFileName[-6:-4]
lNumbers = ‘v’ + lFileVerNumber + ‘_’ + lFileNumber + ‘.fbx’
lName = lFileName.replace(lNumbers, ‘’)

lFileNewName = lName + ‘v’ + ‘d’%(1 + int(lFileVerNumber))+ ‘_01.fbx’

lMemo = FBMessageBoxGetUserValue( ‘memo’, ‘in English:’, ‘’, FBPopupInputType.kFBPopupString, ‘OK’, ‘Cancel’ )
lLog = ‘\n\n’ + lFileNewName + ‘\n’ + lMemo[1]
lLogPath = lFilePath + ‘\log.txt’
lLogOpen = open(lLogPath,’a’)

if str(lMemo[0]) == ‘1’:
if len(lMemo[1]) != 0:
lLogOpen.write(lLog)
lLogOpen.close()

lApp.FileSave(lFileNewName)

else:
FBMessageBox(’error’, ‘blank’, ‘OK’,None,None)
lLogOpen.close()

else:
FBMessageBox(’error’, ‘Cancel’, ‘OK’,None,None)

Del (lApp,lFileFullName, lFilePath, lFileName, lFileVerNumber, lFileNumber, lNumbers, lName, lFileNewName, lMemo, lLog, lLogPath)
-------------------------------------------------------------------------------------------------
motionbuilder 7.5ex2b
Python 2.5

named like this ‘test_v001_05.fbx’ and
Please drop this twice.

Thank you!
HATTORI00

p.s.
if there much easy way to write this script please
show me.. I have only self-taught knowledge.



Replies: 0
avatar

I am not able to repeat the problem you are describing, I was able to have the script run twice, sorry I can’t be of more help, it is not clear to me what the problem is.

~Kristine



KRISTINE MIDDLEMISS | SENIOR DEVELOPER CONSULTANT
AUTODESK DEVELOPER NETWORK Media & Entertainment
http://www.autodesk.com/joinadn

Replies: 0