<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi,<div class=""><br class=""></div><div class="">I am trying to wrap a custom class derived from vtkImageData in python. And it works except for when i try to access my custom methods. For example:</div><div class=""><br class=""></div><font face="Courier New" class=""><span class="">import vtkNewDataPython as idp<br class=""></span><span class=""><br class="">mydata = idp.vtkNewData()<br class=""><br class="">print "\nvtkImageData functionality"<br class="">mydata.SetDimensions(2,3,1)<br class="">dims = mydata.GetDimensions()<br class="">print "image dimensions =",dims<br class="">print "Number of points: ",mydata.GetNumberOfPoints()<br class="">print "Number of cells: ",mydata.GetNumberOfCells()<br class=""><br class="">print "\ncustom functionality" <br class="">mydata.set_myvalue()<br class="">print "Myvalue = ", mydata.get_myvalue()<br class=""></span></font><span class=""><br class=""></span><span class=""><br class=""></span><div class="">Produces:</div><div class=""><div class=""><font face="Courier New" class="">vtkImageData functionality</font></div><div class=""><font face="Courier New" class="">image dimensions = (2, 3, 1)</font></div><div class=""><font face="Courier New" class="">Number of points: 6</font></div><div class=""><font face="Courier New" class="">Number of cells: 2</font></div><div class=""><font face="Courier New" class=""><br class=""></font></div><div class=""><font face="Courier New" class="">custom functionality</font></div><div class=""><font face="Courier New" class="">Traceback (most recent call last):</font></div><div class=""><font face="Courier New" class=""> File "./pytest.py", line 14, in <module></font></div><div class=""><font face="Courier New" class=""> mydata.set_myvalue()</font></div><div class=""><font face="Courier New" class="">AttributeError: set_myvalue</font></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Basically it is doing just fine up until I try to call a custom method</div><div class=""><br class=""></div><div class="">The class looks like this:</div><div class=""><br class=""></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">#include "vtkImageData.h"</font></div><div class="" style="margin: 0px; line-height: normal; min-height: 15px;"><font face="Courier New" class=""><br class=""></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">class VTK_EXPORT vtkNewData: public vtkImageData</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">{</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">public:</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""> static vtkNewData *New();</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""> void set_myvalue(){</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""><span class="Apple-tab-span" style="white-space: pre;"> </span> this->myvalue=3;</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""> }</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""> int get_myvalue(){</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""><span class="Apple-tab-span" style="white-space: pre;"> </span> return this->myvalue;</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""> }</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""> int myvalue;</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">};</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""><br class=""></font></div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;">The CmakeLists.txt is adapted mostly from <a href="https://github.com/paulmelis/vtk-wrapping-example" class="">https://github.com/paulmelis/vtk-wrapping-example</a> and looks like this</div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">#######################################</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""># Pre-requisites</font></div><div class="" style="margin: 0px; line-height: normal; min-height: 15px;"><font face="Courier New" class=""><br class=""></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""># C++11 flags</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11")</font></div><div class="" style="margin: 0px; line-height: normal; min-height: 15px;"><font face="Courier New" class=""><br class=""></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""># VTK</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">find_package(VTK REQUIRED</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""> vtkCommonCore</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""> vtkCommonDataModel</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""> vtkWrappingPythonCore </font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""> )</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">include(${VTK_USE_FILE})</font></div><div class="" style="margin: 0px; line-height: normal; min-height: 15px;"><font face="Courier New" class=""><br class=""></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""># Python and vtk wrapping</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">find_package(PythonLibs 2.7 EXACT REQUIRED)</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">include(vtkWrapPython)</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">include_directories("${PYTHON_INCLUDE_PATH}")</font></div><div class="" style="margin: 0px; line-height: normal; min-height: 15px;"><font face="Courier New" class=""><br class=""></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">#######################################</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""># Building vtkNewData</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">add_library(vtkNewData SHARED vtkNewData.cxx)</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">TARGET_LINK_LIBRARIES(vtkNewData ${VTK_LIBRARIES} )</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">if(APPLE) </font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""> set_target_properties(vtkNewData PROPERTIES SUFFIX ".so")</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">endif()</font></div></div><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""><br class=""></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">#######################################</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""># Wrapping vtkNewData</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">vtk_wrap_python3(vtkNewDataPython vtkNewDataPython_SRCS vtkNewData.cxx)</font></div><div class="" style="margin: 0px; line-height: normal; min-height: 15px;"><font face="Courier New" class=""><br class=""></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">add_library(vtkNewDataPythonD ${vtkNewDataPython_SRCS} vtkNewData.cxx)</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">target_link_libraries(vtkNewDataPythonD </font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""> ${VTK_LIBRARIES}</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""> vtkWrappingPythonCore </font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""> ${VTK_PYTHON_LIBRARIES})</font></div><div class="" style="margin: 0px; line-height: normal; min-height: 15px;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">add_library(vtkNewDataPython MODULE vtkNewDataPythonInit.cxx)</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""><br class=""></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">set(VTK_MODULES_USED vtkCommonDataModel vtkCommonCore) </font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">set(VTK_PYTHOND_LIBS)</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">foreach(TMP_LIB ${VTK_MODULES_USED})</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""> set(VTK_PYTHOND_LIBS ${VTK_PYTHOND_LIBS} ${TMP_LIB}PythonD)</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">endforeach() </font></div><div class="" style="margin: 0px; line-height: normal; min-height: 15px;"><font face="Courier New" class=""><br class=""></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">target_link_libraries(vtkNewDataPython vtkNewDataPythonD ${VTK_PYTHOND_LIBS})</font></div><div class="" style="margin: 0px; line-height: normal; min-height: 15px;"><font face="Courier New" class=""><br class=""></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">set_target_properties(vtkNewDataPython PROPERTIES PREFIX "")</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">if(WIN32 AND NOT CYGWIN)</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class=""> set_target_properties(vtkNewDataPython PROPERTIES SUFFIX ".pyd")</font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Courier New" class="">endif(WIN32 AND NOT CYGWIN)</font></div></div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;">I suspect there is something very simple I am missing here but cannot for the life of me think what. Any help would be appreciated.</div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;">Cheers</div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;">Kit</div></body></html>