Universite-Gustave-Eiffel / I-Simpa

An Open Source software for 3D sound propagation modelling
https://i-simpa.univ-gustave-eiffel.fr/
GNU General Public License v3.0
227 stars 56 forks source link

Changing Surface Material through Python script #303

Closed Kyle-F-Brooks closed 2 years ago

Kyle-F-Brooks commented 2 years ago

I am trying to write a script that will change the linked material of a surface. I have found in the C++ code what I believe is the function used to create it this->AppendPropertyInteger("idmat","idmateriau",0,true)->Hide(); found in e_scene_groupsurfaces_groupe.cpp.

I have tried to use the functions updateentierconfig(const std::string & name, int newValue) and updatelistconfig(const std::string & name, int newIndex) but I get the issue:

Boost.Python.ArgumentError: Python argument types in
    element.__init__(element, list)
did not match C++ signature:
    __init__(struct _object * __ptr64, class uictrl::element)
    __init__(struct _object * __ptr64, int)

Can you advise me on how I can change the linked material. Cheers

nicolas-f commented 2 years ago

Hi,

You need to retrieve the material index in your database (integer: example 100 here) then call

surfaceGroup.updatelistconfig("idmateriau",  ui.element(100))
Kyle-F-Brooks commented 2 years ago

Still getting the same issue. Is surfaceGroup based on ui.element(surface group index) as that is how I currently have it.

nicolas-f commented 2 years ago

Do you have a link to your non working script ?

Kyle-F-Brooks commented 2 years ago

Script is here, thanks for helping

nicolas-f commented 2 years ago

I think the Python binding can't handle the E_Data_Tree element

https://github.com/Ifsttar/I-Simpa/blob/v1.3.4/src/isimpa/data_manager/e_data_tree.h#L112

This is where the material attribute is added:

https://github.com/Ifsttar/I-Simpa/blob/v1.3.4/src/isimpa/data_manager/tree_scene/e_scene_groupesurfaces_groupe.cpp#L222

Missing bindings method should be in this class

https://github.com/Ifsttar/I-Simpa/blob/v1.3.4/src/isimpa/data_manager/python_interface/py_ui_module/element_pywrap.cpp#L169

An update to the source code of I-Simpa need to be done

Kyle-F-Brooks commented 2 years ago

Cheers