Setting up an object/property link using Python

Continuing the discussion from How to set up an object or property link with python:

See working method below:

    def AddObjectLink(objProxy, objProxyOther, linkname):
    	""""Create a link between two proxies.  A name must be given
        so that the link can be referred to by name.  If a link with the given
        name already exists it will be removed first."""
    	objlink = servermanager.vtkSMProxyLink()
    	objlink.AddLinkedProxy(objProxy.SMProxy, 1)
    	objlink.AddLinkedProxy(objProxyOther.SMProxy, 2)
    	objlink.AddLinkedProxy(objProxyOther.SMProxy, 1)
    	objlink.AddLinkedProxy(objProxy.SMProxy, 2)
    	RemoveObjectLink(linkname)
    	servermanager.ProxyManager().RegisterLink(linkname, objlink)

    def RemoveObjectLink(linkName):
    	"""Remove a property link with the given name."""
    	servermanager.ProxyManager().UnRegisterLink(linkName)

For example, to link 2 slice planes together:
AddObjectLink(slice1.SliceType, slice2.SliceType, "link0")

2 Likes