Here’s a little addon that adds a Select Clone Object Master command to the viewport context menu for 3d objects.
The addon is a single self-installed plugin that includes a command, a menu, and a filter:
- The menu item calls the command.
- The filter controls whether or not the menu item is enabled…so that the Select Clone Object Master command is enabled only when you ALT+right click a clone.
# SelectCloneMasterObjectPlugin # Initial code generated by Softimage SDK Wizard # Executed Thu Jun 7 10:55:31 EDT 2012 by blairs # # Tip: To add a command to this plug-in, right-click in the # script editor and choose Tools > Add Command. import win32com.client from win32com.client import constants null = None false = 0 true = 1 def XSILoadPlugin( in_reg ): in_reg.Author = "blairs" in_reg.Name = "SelectCloneMasterObjectPlugin" in_reg.Major = 1 in_reg.Minor = 0 in_reg.RegisterCommand("SelectCloneMasterObject","SelectCloneMasterObject") in_reg.RegisterFilter("Clone",constants.siFilter3DObject) in_reg.RegisterMenu(constants.siMenu3DViewObjectSelectContextID,"SelectCloneMasterObject_Menu",false,false) #RegistrationInsertionPoint - do not remove this line return true def XSIUnloadPlugin( in_reg ): strPluginName = in_reg.Name Application.LogMessage(str(strPluginName) + str(" has been unloaded."),constants.siVerbose) return true # Match callback for the CloneFilter custom filter. def Clone_Match( in_ctxt ): Application.LogMessage("Clone_Match called",constants.siVerbose) o = in_ctxt.GetAttribute( "Input" ) c = win32com.client.Dispatch( "XSI.Collection" ) c.Items = '%s.%s' % (o.ActivePrimitive.FullName, 'CopyOp') return c.Count > 0 # Return value indicates if the input object matches the filter criterias. def SelectCloneMasterObject_Init( in_ctxt ): oCmd = in_ctxt.Source oCmd.Description = "" oCmd.ReturnValue = true oArgs = oCmd.Arguments # oArgs.AddWithHandler("Arg0","Collection") oArgs.AddWithHandler("Arg1","SingleObj") return true def SelectCloneMasterObject_Execute( Arg1 ): Application.LogMessage("SelectCloneMasterObject_Execute called",constants.siVerbose) Application.Selection.Clear() # by Vladimir Jankijevic # https://groups.google.com/forum/?fromgroups#!searchin/xsi_list/Finding$20the$20source$20mesh$20of$20a$20clone/xsi_list/cyUYARDMooA/J3JVxc6jJtIJ copyop = Arg1.ActivePrimitive.ConstructionHistory[0] Application.Selection.Add(copyop.InputPorts[0].Target2.Parent3DObject) # # TODO: Put your command implementation here. # return true def SelectCloneMasterObject_Menu_Init( in_ctxt ): oMenu = in_ctxt.Source oMenu.AddCommandItem("Select Clone Master Object","SelectCloneMasterObject") oMenu.Filter = "Clone" return true