Attached is fix, which will get merged in git/master soon. Thanks for reporting.
On Mon, Feb 2, 2015 at 12:23 PM, Utkarsh Ayachit <[email protected]> wrote: > This is indeed a bug. I've reported it here [1]. Attached script shows > how to overcome this issue in 4.3. You'll need to add the following > stub to your code. Note this is only a workaround. Once the bug is > fixed, one should not use this hack. > > #----------------------------------------------- > # HACK: Overcomes a bug# 15298 > conn = servermanager.ActiveConnection > misc = conn.Modules.misc > servermanager.createModule("exporters", misc) > #----------------------------------------------- > > > [1] http://www.paraview.org/Bug/view.php?id=15298 > > On Mon, Feb 2, 2015 at 10:11 AM, Elias Pipping > <[email protected]> wrote: >> Dear list, >> >> I'm trying to export vector graphics through paraview's python interface(*). >> To that end, from within paraview, I start a python trace, use the UI to >> export to an embedded postscript file (via File->Export scene), and stop the >> trace again. >> The relevant lines of the trace look something like this: >> >> renderView1 = GetActiveViewOrCreate('RenderView') >> ExportView('test.eps', view=renderView1) >> >> Now I can open a python interpreter, paste these lines and get the expected >> result. So far, so good. >> >> Now let me retrace the above steps: After selecting a location to save to, >> I'm presented with a setting of export options. In the above scenario, I >> left everything as-is. I can choose among "rasterize 3d geometry", "draw >> background", etc. (the latter is an advanced option). >> >> If I change those options, they're passed to ExportView, yielding a line >> like the following in the trace: >> >> ExportView('test.eps', view=renderView1, Drawbackground=0, >> Rasterize3Dgeometry=0) >> >> While saving from the UI continues to work even in this case, running the >> above from within the python interpreter does not. Here's what I get: >> >> File >> "[..]/ParaView-4.3.1-Linux-64bit/lib/paraview-4.3/site-packages/paraview/simple.py", >> line 1350, in ExportView >> SetProperties(proxy, **params) >> File >> "[..]/ParaView-4.3.1-Linux-64bit/lib/paraview-4.3/site-packages/paraview/simple.py", >> line 449, in SetProperties >> raise AttributeError("object has no property %s" % param) >> AttributeError: object has no property Drawbackground >> >> Neither the field Drawbackground nor Rasterize3Dgeometry is recognised. >> >> Is the python interface currently incomplete in this respect? Is this easily >> fixed or is there a workaround for this issue? >> >> >> Best regards, >> >> Elias Pipping >> >> (*) All of this concerns a paraview 4.3.1 binary for linux >> >> _______________________________________________ >> Powered by www.kitware.com >> >> Visit other Kitware open-source projects at >> http://www.kitware.com/opensource/opensource.html >> >> Please keep messages on-topic and check the ParaView Wiki at: >> http://paraview.org/Wiki/ParaView >> >> Search the list archives at: http://markmail.org/search/?q=ParaView >> >> Follow this link to subscribe/unsubscribe: >> http://public.kitware.com/mailman/listinfo/paraview >>
From d5f00b28cee69068fdd88a83796b5694f67889d1 Mon Sep 17 00:00:00 2001 From: Utkarsh Ayachit <[email protected]> Date: Mon, 2 Feb 2015 13:57:26 -0500 Subject: [PATCH] BUG #15298. Fixes exporters in Python. Proxies that were not made class-types for in updateModule/_createModule calls ended up not have the Python property API essential for SetProperties(...) call to work. One way is to ensure _createModule/updateModule initializes all proxy groups -- that's bound to fail if new groups get added. To make it more robust, instead we not create a class-type on demand (if one doesn't already exist) in _getPyProxy(). This fixes the issue reported in BUG #15298. Change-Id: Ib7099f0395c74c699878855378c7555cd5ca118a --- Wrapping/Python/paraview/servermanager.py | 143 +++++++++++++++++------------- 1 file changed, 83 insertions(+), 60 deletions(-) diff --git a/Wrapping/Python/paraview/servermanager.py b/Wrapping/Python/paraview/servermanager.py index eb2f648..be89d63 100644 --- a/Wrapping/Python/paraview/servermanager.py +++ b/Wrapping/Python/paraview/servermanager.py @@ -2423,7 +2423,20 @@ def _getPyProxy(smproxy, outputPort=0): if classForProxy: retVal = classForProxy(proxy=smproxy, port=outputPort) else: - retVal = Proxy(proxy=smproxy, port=outputPort) + # Since the class for this proxy, doesn't exist yet, we attempt to + # create a new class definition for it, if possible and then add it + # to the "misc" module. This is essential since the Python property + # variables for a proxy are only setup whne the Proxy class is created + # (in _createClass). + # NOTE: _createClass() takes the xml group and name, not the xml label, + # hence we don't pass xmlName variable. + classForProxy = _createClass(smproxy.GetXMLGroup(), smproxy.GetXMLName()) + if classForProxy: + global misc + misc.__dict__[classForProxy.__name__] = classForProxy + retVal = classForProxy(proxy=smproxy, port=outputPort) + else: + retVal = Proxy(proxy=smproxy, port=outputPort) return retVal def _makeUpdateCameraMethod(rv): @@ -2582,6 +2595,65 @@ class PVModule(object): def _make_name_valid(name): return paraview.make_name_valid(name) +def _createClass(groupName, proxyName, apxm=None): + """Defines a new class type for the proxy.""" + global ActiveConnection + pxm = ProxyManager() if not apxm else apxm + proto = pxm.GetPrototypeProxy(groupName, proxyName) + if not proto: + paraview.print_error("Error while loading %s/%s %s"%(groupName, i['group'], proxyName)) + return None + pname = proxyName + if paraview.compatibility.GetVersion() >= 3.5 and proto.GetXMLLabel(): + pname = proto.GetXMLLabel() + pname = _make_name_valid(pname) + if not pname: + return None + cdict = {} + # Create an Initialize() method for this sub-class. + cdict['Initialize'] = _createInitialize(groupName, proxyName) + iter = PropertyIterator(proto) + # Add all properties as python properties. + for prop in iter: + propName = iter.GetKey() + if paraview.compatibility.GetVersion() >= 3.5: + if (prop.GetInformationOnly() and propName != "TimestepValues" ) \ + or prop.GetIsInternal(): + continue + names = [propName] + if paraview.compatibility.GetVersion() >= 3.5: + names = [iter.PropertyLabel] + + propDoc = None + if prop.GetDocumentation(): + propDoc = prop.GetDocumentation().GetDescription() + for name in names: + name = _make_name_valid(name) + if name: + cdict[name] = property(_createGetProperty(propName), + _createSetProperty(propName), + None, + propDoc) + # Add the documentation as the class __doc__ + if proto.GetDocumentation() and \ + proto.GetDocumentation().GetDescription(): + doc = proto.GetDocumentation().GetDescription() + else: + doc = Proxy.__doc__ + cdict['__doc__'] = doc + # Create the new type + if proto.GetXMLName() == "ExodusIIReader": + superclasses = (ExodusIIReaderProxy,) + elif proto.IsA("vtkSMSourceProxy"): + superclasses = (SourceProxy,) + elif proto.IsA("vtkSMViewLayoutProxy"): + superclasses = (ViewLayoutProxy,) + else: + superclasses = (Proxy,) + + cobj = type(pname, superclasses, cdict) + return cobj + def createModule(groupName, mdl=None): """Populates a module with proxy classes defined in the given group. If mdl is not specified, it also creates the module""" @@ -2601,65 +2673,16 @@ def createModule(groupName, mdl=None): definitionIter = pxm.NewDefinitionIterator(groupName) for i in definitionIter: proxyName = i['key'] - proto = pxm.GetPrototypeProxy(groupName, proxyName) - if not proto: - paraview.print_error("Error while loading %s/%s %s"%(groupName, i['group'], proxyName)) - continue - pname = proxyName - if paraview.compatibility.GetVersion() >= 3.5 and\ - proto.GetXMLLabel(): - pname = proto.GetXMLLabel() - pname = _make_name_valid(pname) - if not pname: - continue - if pname in mdl.__dict__: - if debug: - paraview.print_warning("Warning: %s is being overwritten. This may point to an issue in the ParaView configuration files" % pname) - cdict = {} - # Create an Initialize() method for this sub-class. - cdict['Initialize'] = _createInitialize(groupName, proxyName) - iter = PropertyIterator(proto) - # Add all properties as python properties. - for prop in iter: - propName = iter.GetKey() - if paraview.compatibility.GetVersion() >= 3.5: - if (prop.GetInformationOnly() and propName != "TimestepValues" ) \ - or prop.GetIsInternal(): - continue - names = [propName] - if paraview.compatibility.GetVersion() >= 3.5: - names = [iter.PropertyLabel] - - propDoc = None - if prop.GetDocumentation(): - propDoc = prop.GetDocumentation().GetDescription() - for name in names: - name = _make_name_valid(name) - if name: - cdict[name] = property(_createGetProperty(propName), - _createSetProperty(propName), - None, - propDoc) - # Add the documentation as the class __doc__ - if proto.GetDocumentation() and \ - proto.GetDocumentation().GetDescription(): - doc = proto.GetDocumentation().GetDescription() - else: - doc = Proxy.__doc__ - cdict['__doc__'] = doc - # Create the new type - if proto.GetXMLName() == "ExodusIIReader": - superclasses = (ExodusIIReaderProxy,) - elif proto.IsA("vtkSMSourceProxy"): - superclasses = (SourceProxy,) - elif proto.IsA("vtkSMViewLayoutProxy"): - superclasses = (ViewLayoutProxy,) - else: - superclasses = (Proxy,) - - cobj = type(pname, superclasses, cdict) - # Add it to the modules dictionary - mdl.__dict__[pname] = cobj + cobj = _createClass(groupName, proxyName, apxm=pxm) + if cobj: + pname = cobj.__name__ + if pname in mdl.__dict__ and debug: + paraview.print_warning(\ + "Warning: %s is being overwritten."\ + " This may point to an issue in the ParaView configuration files"\ + % pname) + # Add it to the modules dictionary + mdl.__dict__[pname] = cobj return mdl -- 1.9.1
_______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView Search the list archives at: http://markmail.org/search/?q=ParaView Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/paraview
