//
// This example demonstrates how to use the SetSelFilter command in C# to change
// the selection filter to limit selection to scene objects. Depending on the
// value of the inUseString input argument, either the string itself (true) or
// the string constant representing the string (false) will be used to call SetSelFilter.
//
// Tip: You need to compile the generated code before you can load the plug-in.
// After you compile the plug-in, you can load it by clicking Update All in the Plugin Manager.
//
using System;
using Softimage.XSIOM; // Softimage object model
using Softimage.XSIMath;
using Softimage.XSIUtil;
public class Base
{
CXSIApplicationClass m_xsi;
CXSIFactoryClass m_fact;
CXSIUtilsClass m_utils;
protected Base()
{
m_xsi = new CXSIApplicationClass();
m_fact = new CXSIFactoryClass();
m_utils = new CXSIUtilsClass();
}
protected XSIApplication GetXSI()
{
return m_xsi;
}
}
public class XSIPlugin : Base
{
public bool Load( PluginRegistrar in_reg )
{
in_reg.Author = "SDK Documentation";
in_reg.Name = "SetSceneObjectSelFilterPlugin";
in_reg.Major = 1;
in_reg.Minor = 0;
in_reg.RegisterCommand("SetSceneObjectSelFilter", "SetSceneObjectSelFilter");
return true;
}
public bool Unload( PluginRegistrar in_reg )
{
String strPluginName = null;
strPluginName = in_reg.Name;
return true;
}
}
public class SetSceneObjectSelFilter : Base
{
public bool Init( Context in_ctxt )
{
Command oCmd = null;
oCmd = (Command)in_ctxt.Source;
oCmd.Description = "Demonstrates how to set the Selection Filter in Softimage to Scene Object";
oCmd.Tooltip = "Set Selection Filter to SceneObject";
oCmd.SetFlag((int)siCommandCapabilities.siCannotBeUsedInBatch, true);
oCmd.ReturnValue = false;
ArgumentCollection oArgs = oCmd.Arguments;
oArgs.Add("inUseString", siArgumentFlags.siArgumentInput, false, siVariantType.siBool);
return true;
}
// In C# you have to use the XSIApplication.ExecuteCommand method to invoke
// a command, so we are just implementing a command stub to simplify the call
// in the Execute function.
public void SetSelFilter(String SelFilter)
{
XSIApplication app = this.GetXSI();
// The SetSelFilter command takes only one argument: 'SelFilter', which
// can be either the siObjectFilter string constant or the string to
// which it refers: 'sceneobject'
object[] oCmdArgs = new object[1];
oCmdArgs[0] = SelFilter;
app.ExecuteCommand("SetSelFilter", oCmdArgs);
}
public bool Execute(Context in_ctxt)
{
Command oCmd = null;
oCmd = (Command)in_ctxt.Source;
// Set the selection filter to scene object. Whether we use the string
// constant or the actual string depends on the value of inUseString.
ArgumentCollection oArgs = oCmd.Arguments;
if ((bool)oArgs[0].Value == true)
{
SetSelFilter("SceneObject");
}
else
{
// All string constants are members of the StringModule
SetSelFilter(StringModule.siObjectFilter);
}
return true;
}
} |