Q100158: உங்கள் Nuke ஸ்கிரிப்ட்டுக்கு பல ஆட்டோசேவ்களை உருவாக்குகிறது.

சுருக்கம்

உருளும் மற்றும் அதிகரிக்கும் ஆட்டோசேவ் அமைப்பை செயல்படுத்த Nuke ஆட்டோசேவ் செயல்பாட்டை எவ்வாறு தனிப்பயனாக்கலாம் என்பதை இந்தக் கட்டுரை விளக்குகிறது.

மேலும் தகவல்

இயல்பாக, நீங்கள் பணிபுரியும் தற்போதைய கோப்பிற்கு Nuke ஒரு தானியங்கி சேமிப்பை மட்டுமே வைத்திருக்கும். கோப்பு <scriptname>.nk.autosave என்று அழைக்கப்படும், மேலும் உங்கள் Nuke விருப்பத்தேர்வுகளில் அமைக்கப்பட்ட அதிர்வெண்ணில் புதுப்பிக்கப்படும்/மேலெழுதப்படும்.

உங்கள் சொந்த ஆட்டோசேவ் பைதான் செயல்பாடுகளை அமைப்பதன் மூலம் Nuke ஆட்டோசேவ் நடத்தையை நீங்கள் தனிப்பயனாக்கலாம். கீழே உள்ள எடுத்துக்காட்டு ( Nuke பைதான் டெவலப்பர் வழிகாட்டியிலிருந்து ) உங்கள் வேலையின் பல அதிகரிக்கும் காப்புப்பிரதிகளை செயல்பாட்டில் உள்ள ஸ்கிரிப்டைச் சேமிக்க ஒரு ரோலிங் ஆட்டோசேவை அமைக்கும்.

பின்வருவனவற்றைச் செய்வதன் மூலம் இதை அமைக்கலாம்.

  1. இணைக்கப்பட்ட autosave.py கோப்பைப் பதிவிறக்கி, செயலில் உள்ள பயனரின் .nuke கோப்பகத்தில் வைக்கவும்: Q100048: Nuke கோப்பக இருப்பிடங்கள்

  2. உங்கள் .nuke கோப்பகத்தில் உள்ள init.py கோப்பில் பின்வரும் வரியைச் சேர்க்கவும்: import autosave
    குறிப்பு: உங்கள் .nuke கோப்பகத்தில் ஏற்கனவே init.py கோப்பு இல்லையென்றால், நீங்கள் ஒன்றை உருவாக்க வேண்டும்.

அடுத்த முறை நீங்கள் Nuke தொடங்கும்போது, அது பல அதிகரிக்கும் தானியங்கி சேமிப்புக் கோப்புகளை உருவாக்கும், இது போன்றது:

<scriptname>.nk.தானியங்கி சேமிப்பு

<scriptname>.nk.autosave1

<scriptname>.nk.autosave2

<scriptname>.nk.தானியங்கிசேமி3

வரை

<scriptname>.nk.autosave9

Nuke இல் ஏதேனும் சிக்கல்கள் ஏற்பட்டால், க்ராஷ் செய்தல் அல்லது சிதைந்த ஸ்கிரிப்ட்கள் போன்றவை ஏற்பட்டால், சிக்கல் ஏற்படுவதற்கு முன்பு ஒரு ஸ்கிரிப்டைக் கண்டுபிடிக்க ஒவ்வொரு ஆட்டோசேவையும் ( File > Open ஐப் பயன்படுத்தி) ஏற்றலாம்.

மேலும் படிக்க

தனிப்பயன் பைதான் ஸ்கிரிப்ட்களை எவ்வாறு ஏற்றுவது மற்றும் பிற தனிப்பயனாக்கங்கள் பற்றிய கூடுதல் தகவல்களை Nuke ஆன்லைன் ஆவணங்கள் கொண்டுள்ளன.
onAutoSave போன்ற Python callbacks ஐ எவ்வாறு பயன்படுத்துவது என்பது பற்றிய கூடுதல் தகவல்களை Nuke Python டெவலப்பர் வழிகாட்டி கொண்டுள்ளது.

எடுத்துக்காட்டு குறியீடு

கீழே உள்ள autosave.py கோப்பின் உள்ளடக்கங்கள் இங்கே.

import nuke
import glob
import time
import os

### Example that implements a rolling autosave using the autoSaveFilter callbacks
###
## autosaves roll from 0-9 eg myfile.autosave, myfile.autosave1, myfile.autosave2...
#
## To use just add 'import nuke scripts.autosave' in your init.py


def onAutoSave(filename):

  ## ignore untiled autosave
  if nuke .root().name() == 'Root':
    return filename

  fileNo = 0
  files = getAutoSaveFiles(filename)

  if len(files) > 0 :
    lastFile = files[-1]
    # get the last file number

    if len(lastFile) > 0:
      try:
        fileNo = int(lastFile[-1:])
      except:
        pass

      fileNo = fileNo + 1

  if ( fileNo > 9 ):
    fileNo = 0

  if ( fileNo != 0 ):
    filename = filename + str(fileNo)

  return filename


def onAutoSaveRestore(filename):

  files = getAutoSaveFiles(filename)

  if len(files) > 0:
    filename = files[-1]

  return filename

def onAutoSaveDelete(filename):

  ## only delete untiled autosave
  if nuke .root().name() == 'Root':
    return filename

  # return None here to not delete auto save file
  return None

  
def getAutoSaveFiles(filename):
  date_file_list = []
  files = glob.glob(filename + '[1-9]')
  files.extend( glob.glob(filename) )

  for file in files:
      # retrieves the stats for the current file as a tuple
      # (mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime)
      # the tuple element mtime at index 8 is the last-modified-date
      stats = os.stat(file)
      # create tuple (year yyyy, month(1-12), day(1-31), hour(0-23), minute(0-59), second(0-59),
      # weekday(0-6, 0 is monday), Julian day(1-366), daylight flag(-1,0 or 1)) from seconds since epoch
      # note:  this tuple can be sorted properly by date and time
      lastmod_date = time.localtime(stats[8])
      #print image_file, lastmod_date   # test
      # create list of tuples ready for sorting by date
      date_file_tuple = lastmod_date, file
      date_file_list.append(date_file_tuple)
   
  date_file_list.sort()
  return [ filename for _, filename in date_file_list ]


nuke .addAutoSaveFilter( onAutoSave )
nuke .addAutoSaveRestoreFilter( onAutoSaveRestore )
nuke .addAutoSaveDeleteFilter( onAutoSaveDelete )

### As an example to remove the callbacks use this code
#nuke.removeAutoSaveFilter( onAutoSave )
#nuke.removeAutoSaveRestoreFilter( onAutoSaveRestore )
#nuke.removeAutoSaveDeleteFilter( onAutoSaveDelete )

We're sorry to hear that

Please tell us why