zoukankan      html  css  js  c++  java
  • MaxScript重启Max

    这个需要用另外的进程来做,不然执行到关闭就会终止脚本的执行。简单的范例如下

    Fn ReStartMax inputSecond = 
    (
        local CSharpProvider,CompilerParams,CompilerResults,errorMessage
        CSharpCodeSource ="
        using System;
        using System.Diagnostics;
        using System.Threading;
        
        namespace Temp
        {
            static class Program
            {
                public static void Main(string[] args)
                {
                    Thread.Sleep(" + ((inputSecond * 1000 ) as Integer) as string + ");
                    Process.Start(@\""+ GetDir #MaxRoot + "3dsmax.exe" + "\");
                }
            }
        }
        "
        CSharpProvider = DotnetObject "Microsoft.CSharp.CSharpCodeProvider"
        CompilerParams = DotnetObject "System.CodeDom.Compiler.CompilerParameters"
    
        CompilerParams.ReferencedAssemblies.Add("System.dll")
        CompilerParams.GenerateExecutable = true
        CompilerParams.GenerateInMemory = false
        CompilerParams.OutputAssembly  = GetDir #MaxRoot + "ReStartMax.exe"
        CompilerParams.CompilerOptions  = "/target:winexe"
        CompilerResults = CSharpProvider.CompileAssemblyFromSource CompilerParams #(CSharpCodeSource)
        if CompilerResults.errors.HasErrors then
        (
            for i = 0 to CompilerResults.errors.count - 1 do
            (
                errorMessage =  (CompilerResults.errors.item i).line as string + ": " +  (CompilerResults.errors.item i).errorText
                print errorMessage
            )
        )
        else
        (
            ShellLaunch (GetDir #MaxRoot+"ReStartMax.exe") ""
            QuitMax #noPrompt
        )
    )
    
    ReStartMax(60)
  • 相关阅读:
    将一个dropdownlist从一个div复制到另一个div
    【转】AOP 那点事儿(续集)
    【转】AOP 那点事儿
    spring 简单配置
    spring 基础原理
    jvm简介
    jre、jdk和jvm的关系
    【转】Jvm工作原理
    servlet简述
    Filter简述
  • 原文地址:https://www.cnblogs.com/sitt/p/3065201.html
Copyright © 2011-2022 走看看