Any way to as an SIProxy to print it's server-side VTK object?

This seems like a fairly obvious thing to want to do during development. I have a client-side SMProxy object in Python, and I’d like to ask the server-side vtkObject to PrintSelf(), for debugging purposes.

Adding a <Property name="Print" command="Print" /> to the proxy definition and then calling that using vtkSMProxy::InvokeCommand("Print") is one of the ways to do it.

1 Like

Hmm, this doesn’t seem to work. vtkObjectBase::Print(…) needs a parameter, doesn’t it?

Also, if this did work, it would call print on the SMProxy, not on the SIProxy-wrapped vtkObject?

Hmm actually no, I got confused, this should in theory work.

Seems like vtkClientServerStream wrapping has specially handled Print to return the result as reply.

// from vtkObjectBaseClientServer.cxx
if (!strcmp("Print",method) && msg.GetNumberOfArguments(0) == 2)                 
{                                                                                 
  std::ostringstream buf_with_warning_C4701;                                        
  op->Print(buf_with_warning_C4701);                                                
  resultStream.Reset();                                                             
  resultStream << vtkClientServerStream::Reply                                      
    << buf_with_warning_C4701.str().c_str()                              
    << vtkClientServerStream::End;                                       
  return 1;                                                                         
}                                   `

Not entirely sure why that was done.

A workaround is to add a new method to your vtkObject subclass that simply calls Print and expose that one instead in the XML.

1 Like