3ds max で .NET
3ds Max 9 から MAXScript で .NET Framework が利用できるようになりました。
今まで 8 しか使っていなかったので、Max 9の検証を兼ねていろいろ弄っていきたいと思います。
参考書はmax9パッケージに付属していた MAXScript リファレンス 9.0 を使用します。
ということで、System.Stringクラスを利用してメソッドを列挙するスクリプトを書いてみました。
(参考:MAXScript ツールおよび 3ds Max との連携 >> MAXScript における DotNet >> dotNetObject)
o1 = dotNetObject "System.String" "hello,world!" -- System.String オブジェクトの生成
showMethods o1 -- リスナーに結果を列挙
.<System.Object>Clone()
.[static]<System.Int32>Compare <System.String>strA <System.String>strB
.[static]<System.Int32>Compare <System.String>strA <System.String>strB <System.Boolean>ignoreCase
.[static]<System.Int32>Compare <System.String>strA <System.String>strB <System.StringComparison>comparisonType
.[static]<System.Int32>Compare <System.String>strA <System.String>strB <System.Boolean>ignoreCase
<System.Globalization.CultureInfo>culture
.[static]<System.Int32>Compare <System.String>strA <System.Int32>indexA <System.String>strB <System.Int32>indexB <System.Int32>length
.[static]<System.Int32>Compare <System.String>strA <System.Int32>indexA <System.String>strB <System.Int32>indexB <System.Int32>length
<System.StringComparison>comparisonType
.[static]<System.Int32>Compare <System.String>strA <System.Int32>indexA <System.String>strB <System.Int32>indexB <System.Int32>length
<System.Boolean>ignoreCase
.[static]<System.Int32>Compare <System.String>strA <System.Int32>indexA <System.String>strB <System.Int32>indexB <System.Int32>length
<System.Boolean>ignoreCase <System.Globalization.CultureInfo>culture
.[static]<System.Int32>CompareOrdinal <System.String>strA <System.String>strB
.[static]<System.Int32>CompareOrdinal <System.String>strA <System.Int32>indexA <System.String>strB <System.Int32>indexB
<System.Int32>length
.<System.Int32>CompareTo <System.Object>value
.<System.Int32>CompareTo <System.String>strB
.[static]<System.String>Concat <System.Object>arg0
.[static]<System.String>Concat <System.String[]>values
.[static]<System.String>Concat <System.Object[]>args
.[static]<System.String>Concat <System.Object>arg0 <System.Object>arg1
.[static]<System.String>Concat <System.String>str0 <System.String>str1
.[static]<System.String>Concat <System.String>str0 <System.String>str1 <System.String>str2
.[static]<System.String>Concat <System.Object>arg0 <System.Object>arg1 <System.Object>arg2
.[static]<System.String>Concat <System.String>str0 <System.String>str1 <System.String>str2 <System.String>str3
.[static]<System.String>Concat <System.Object>arg0 <System.Object>arg1 <System.Object>arg2 <System.Object>arg3
.<System.Boolean>Contains <System.String>value
.[static]<System.String>Copy <System.String>str
.CopyTo <System.Int32>sourceIndex <System.Char[]>destination <System.Int32>destinationIndex <System.Int32>count
.<System.Boolean>EndsWith <System.String>value
.<System.Boolean>EndsWith <System.String>value <System.StringComparison>comparisonType
.<System.Boolean>EndsWith <System.String>value <System.Boolean>ignoreCase <System.Globalization.CultureInfo>culture
.<System.Boolean>Equals <System.Object>obj
.<System.Boolean>Equals <System.String>value
.[static]<System.Boolean>Equals <System.Object>objA <System.Object>objB
.[static]<System.Boolean>Equals <System.String>a <System.String>b
.<System.Boolean>Equals <System.String>value <System.StringComparison>comparisonType
.[static]<System.Boolean>Equals <System.String>a <System.String>b <System.StringComparison>comparisonType
.[static]<System.String>Format <System.String>format <System.Object[]>args
.[static]<System.String>Format <System.String>format <System.Object>arg0
.[static]<System.String>Format <System.IFormatProvider>provider <System.String>format <System.Object[]>args
.[static]<System.String>Format <System.String>format <System.Object>arg0 <System.Object>arg1
.[static]<System.String>Format <System.String>format <System.Object>arg0 <System.Object>arg1 <System.Object>arg2
.<System.CharEnumerator>GetEnumerator()
.<System.Int32>GetHashCode()
.<System.Type>GetType()
.<System.TypeCode>GetTypeCode()
.<System.Int32>IndexOf <System.String>value
.<System.Int32>IndexOf <System.Char>value
.<System.Int32>IndexOf <System.Char>value <System.Int32>startIndex
.<System.Int32>IndexOf <System.String>value <System.StringComparison>comparisonType
.<System.Int32>IndexOf <System.String>value <System.Int32>startIndex
.<System.Int32>IndexOf <System.Char>value <System.Int32>startIndex <System.Int32>count
.<System.Int32>IndexOf <System.String>value <System.Int32>startIndex <System.Int32>count
.<System.Int32>IndexOf <System.String>value <System.Int32>startIndex <System.StringComparison>comparisonType
.<System.Int32>IndexOf <System.String>value <System.Int32>startIndex <System.Int32>count <System.StringComparison>comparisonType
.<System.Int32>IndexOfAny <System.Char[]>anyOf
.<System.Int32>IndexOfAny <System.Char[]>anyOf <System.Int32>startIndex
.<System.Int32>IndexOfAny <System.Char[]>anyOf <System.Int32>startIndex <System.Int32>count
.<System.String>Insert <System.Int32>startIndex <System.String>value
.[static]<System.String>Intern <System.String>str
.[static]<System.String>IsInterned <System.String>str
.<System.Boolean>IsNormalized()
.<System.Boolean>IsNormalized <System.Text.NormalizationForm>normalizationForm
.[static]<System.Boolean>IsNullOrEmpty <System.String>value
.[static]<System.String>Join <System.String>separator <System.String[]>value
.[static]<System.String>Join <System.String>separator <System.String[]>value <System.Int32>startIndex <System.Int32>count
.<System.Int32>LastIndexOf <System.String>value
.<System.Int32>LastIndexOf <System.Char>value
.<System.Int32>LastIndexOf <System.String>value <System.StringComparison>comparisonType
.<System.Int32>LastIndexOf <System.Char>value <System.Int32>startIndex
.<System.Int32>LastIndexOf <System.String>value <System.Int32>startIndex
.<System.Int32>LastIndexOf <System.Char>value <System.Int32>startIndex <System.Int32>count
.<System.Int32>LastIndexOf <System.String>value <System.Int32>startIndex <System.StringComparison>comparisonType
.<System.Int32>LastIndexOf <System.String>value <System.Int32>startIndex <System.Int32>count
.<System.Int32>LastIndexOf <System.String>value <System.Int32>startIndex <System.Int32>count <System.StringComparison>comparisonType
.<System.Int32>LastIndexOfAny <System.Char[]>anyOf
.<System.Int32>LastIndexOfAny <System.Char[]>anyOf <System.Int32>startIndex
.<System.Int32>LastIndexOfAny <System.Char[]>anyOf <System.Int32>startIndex <System.Int32>count
.<System.String>Normalize()
.<System.String>Normalize <System.Text.NormalizationForm>normalizationForm
.<System.String>PadLeft <System.Int32>totalWidth
.<System.String>PadLeft <System.Int32>totalWidth <System.Char>paddingChar
.<System.String>PadRight <System.Int32>totalWidth
.<System.String>PadRight <System.Int32>totalWidth <System.Char>paddingChar
.[static]<System.Boolean>ReferenceEquals <System.Object>objA <System.Object>objB
.<System.String>Remove <System.Int32>startIndex
.<System.String>Remove <System.Int32>startIndex <System.Int32>count
.<System.String>Replace <System.Char>oldChar <System.Char>newChar
.<System.String>Replace <System.String>oldValue <System.String>newValue
.<System.String[]>Split <System.Char[]>separator
.<System.String[]>Split <System.String[]>separator <System.StringSplitOptions>options
.<System.String[]>Split <System.Char[]>separator <System.Int32>count
.<System.String[]>Split <System.Char[]>separator <System.StringSplitOptions>options
.<System.String[]>Split <System.Char[]>separator <System.Int32>count <System.StringSplitOptions>options
.<System.String[]>Split <System.String[]>separator <System.Int32>count <System.StringSplitOptions>options
.<System.Boolean>StartsWith <System.String>value
.<System.Boolean>StartsWith <System.String>value <System.StringComparison>comparisonType
.<System.Boolean>StartsWith <System.String>value <System.Boolean>ignoreCase <System.Globalization.CultureInfo>culture
.<System.String>Substring <System.Int32>startIndex
.<System.String>Substring <System.Int32>startIndex <System.Int32>length
.<System.Char[]>ToCharArray()
.<System.Char[]>ToCharArray <System.Int32>startIndex <System.Int32>length
.<System.String>ToLower()
.<System.String>ToLower <System.Globalization.CultureInfo>culture
.<System.String>ToLowerInvariant()
.<System.String>ToString()
.<System.String>ToString <System.IFormatProvider>provider
.<System.String>ToUpper()
.<System.String>ToUpper <System.Globalization.CultureInfo>culture
.<System.String>ToUpperInvariant()
.<System.String>Trim()
.<System.String>Trim <System.Char[]>trimChars
.<System.String>TrimEnd <System.Char[]>trimChars
.<System.String>TrimStart <System.Char[]>trimChars
はい、System.Stringの全メソッドが列挙されました。
次は、S で始まるメソッドのみを列挙させてみます
o1 = dotNetObject "System.String" "hello,world!" -- System.String オブジェクトの生成
showMethods o1 "s*" -- リスナーに結果を列挙
.<System.String[]>Split <System.Char[]>separator
.<System.String[]>Split <System.String[]>separator <System.StringSplitOptions>options
.<System.String[]>Split <System.Char[]>separator <System.Int32>count
.<System.String[]>Split <System.Char[]>separator <System.StringSplitOptions>options
.<System.String[]>Split <System.Char[]>separator <System.Int32>count <System.StringSplitOptions>options
.<System.String[]>Split <System.String[]>separator <System.Int32>count <System.StringSplitOptions>options
.<System.Boolean>StartsWith <System.String>value
.<System.Boolean>StartsWith <System.String>value <System.StringComparison>comparisonType
.<System.Boolean>StartsWith <System.String>value <System.Boolean>ignoreCase <System.Globalization.CultureInfo>culture
.<System.String>Substring <System.Int32>startIndex
.<System.String>Substring <System.Int32>startIndex <System.Int32>length
.NET のオブジェクトを作成するのは非常に簡単ですね。
dotNetObject のメソッドには以下のものが用意されています
- getProperty
- setProperty
- getPropNames
- shoProperties
- showMethods
- showEvents
メソッド名を見ればどういう動作をするのかわかりますね。
クラスのインスタンス方法がわかったので、次はロールアウトに.NETコントロールを配置してみたいと思います。
つづく...