v4.0
Softimage にカスタムフィルタを登録します。
PluginItem PluginRegistrar.RegisterFilter( String in_name, siFilterType in_Type ); |
oReturn = PluginRegistrar.RegisterFilter( Name, Type ); |
パラメータ | タイプ | 説明 |
---|---|---|
Name | String |
登録するカスタムフィルタの名前文字から開始し、英数字とアンダースコア(_)記号のみを使用する必要があります。 フィルタ名は、フィルタのコールバック関数(Match や Subset など)の名前を付ける場合に使用されますたとえば、"My3DObjectFilter"という名前の Match コールバックは"My3DObjectFilter_Match"になります。フィルタ名にスペースが含まれている場合("My 3D Object Filter"など)は、コールバック関数名ではスペースを削除する必要があります("My3DObjectFilter_Match"など)。 これは Softimage ユーザインターフェイスにも表示される名前でもあり、スクリプト内または C++コード内でフィルタの参照に使われる名前でもあります。フィルタ名にスペースが含まれている場合は、スペースをアンダースコアで置換してからでないと、スクリプティングコマンドまたはオブジェクトモデルにフィルタを使用できません。たとえば、「My Custom Filter」という名前のフィルタを登録する場合に、FiltersCollection からフィルタを取得するには、次のようにスペースをアンダースコア(_)に置き換える必要があります。 var oFilter = Application.Filters.Item( "My_Custom_Filter" ); |
Type | siFilterType | 登録するフィルタのタイプ |
/*------------------------------------------------------------------- This example shows how to register, implement and use a custom filter. README: Copy and paste the example into the script editor and run (F5). The filter will now be listed in the Scene Explorer filter list when the "Source/Clips" view context is selected. -------------------------------------------------------------------*/ function XSILoadPlugin( in_reg ) { in_reg.Author = "Softimage Co." in_reg.Name = "PluginRegistrar.RegisterFilter Example" // register the cone filter plug-in item in_reg.RegisterFilter( "ExRegisterFilter_ConePrimitive", siFilterObject ); // register a command to illustrate usage in_reg.RegisterCommand( "ExRegisterFilterDemo", "ExRegisterFilterDemo" ); return true; } function ExRegisterFilter_ConePrimitive_Match( in_context ) { var obj = in_context.GetAttribute("Input"); return obj.IsKindOf( siConePrimType ); } // This command shows how to use the ConePrimitive filter function ExRegisterFilterDemo_Execute() { Application.LogMessage("Running ExRegisterFilterDemo"); var filter = Application.Filters( "ExRegisterFilter_ConePrimitive" ); Application.LogMessage( "Filter: " + filter.Name + " type=" + filter.Type ); var sphere = ActiveSceneRoot.AddGeometry( "Sphere", "MeshSurface", "sphere" ); var cone = ActiveSceneRoot.AddGeometry( "Cone", "MeshSurface", "cone" ); // log all objects that match the filter var eChildren = new Enumerator(ActiveSceneRoot.Children); for (;!eChildren.atEnd();eChildren.moveNext()) { var child = eChildren.item(); Application.LogMessage( child.name + " is a cone: " + filter.Match( child ) ); } } //-------------------------------------------------------------------- // Code to bootstrap example into system //-------------------------------------------------------------------- function ExampleSourceCode() { return "//XSISDK Doc Example\n" + ExRegisterFilter_ConePrimitive_Match.toString() + "\n" + ExRegisterFilterDemo_Execute.toString() + "\n" + XSILoadPlugin.toString(); } // if we are running from script editor save code to // examples addon folder in the user's directory. if (GetUserPref("ScriptingSessionActive")) { var ex_name = "ExPluginRegistrarRegisterFilter"; var ex_subfolder = "Plugins"; var ex_folder = "XSISDKDocExamples"; var ex_langsuffix = ".js"; CreateAddonDirectories( InstallationPath(siUserPath), ex_folder ); var fso = XSIFactory.CreateActiveXObject("Scripting.FileSystemObject"); var filename = XSIUtils.BuildPath( InstallationPath(siUserAddonPath), ex_folder, "Application", ex_subfolder, ex_name+ex_langsuffix ); if (!fso.FileExists(filename)) { var f = fso.CreateTextFile ( filename ); f.write( ExampleSourceCode() ); f.close(); Application.LoadPlugin(filename); } // run demo ExRegisterFilterDemo(); } |