qgisred / QGISRed

GNU General Public License v2.0
23 stars 8 forks source link

Error in .inp import #126

Open ankitbista1 opened 3 months ago

ankitbista1 commented 3 months ago

Hello I get this error when trying to import .inp file

An error has occurred while executing Python code:

TypeError: QgsLineSymbolLayer.setWidthUnit(): argument 1 has unexpected type 'int' Traceback (most recent call last): File "C:\Users/Ankit/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QGISRed\ui\qgisred_import_dialog.py", line 215, in importInpProject self.parent.processCsharpResult(resMessage, "") File "C:\Users/Ankit/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QGISRed\qgisred_plugins.py", line 2207, in processCsharpResult QGISRedUtils().runTask("update layers", self.removeLayers, self.runOpenTemporaryFiles) File "C:\Users/Ankit/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QGISRed\tools\qgisred_utils.py", line 511, in runTask postprocess() File "C:\Users/Ankit/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QGISRed\qgisred_plugins.py", line 2160, in runOpenTemporaryFiles QGISRedUtils().runTask("update layers", self.openElementLayers, self.setExtent) File "C:\Users/Ankit/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QGISRed\tools\qgisred_utils.py", line 510, in runTask process(None) File "C:\Users/Ankit/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QGISRed\qgisred_plugins.py", line 1764, in openElementLayers utils.openElementsLayers(inputGroup, self.ownMainLayers) File "C:\Users/Ankit/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QGISRed\tools\qgisred_utils.py", line 74, in openElementsLayers self.openLayer(group, fileName) File "C:\Users/Ankit/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QGISRed\tools\qgisred_utils.py", line 96, in openLayer self.setStyle(vlayer, name.lower()) File "C:\Users/Ankit/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QGISRed\tools\qgisred_utils.py", line 261, in setStyle lineSymbol.setWidthUnit(2) # Pixels TypeError: QgsLineSymbolLayer.setWidthUnit(): argument 1 has unexpected type 'int'

Python version: 3.9.18 (heads/master:5eba59e, Feb 1 2024, 20:02:10) [MSC v.1929 64 bit (AMD64)] QGIS version: 3.36.0-Maidenhead Maidenhead, 09951dc0

Python Path: C:\Users/Ankit/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\wnt C:/PROGRA~1/QGIS33~1.0/apps/qgis/./python C:/Users/Ankit/AppData/Roaming/QGIS/QGIS3\profiles\default/python C:/Users/Ankit/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins C:/PROGRA~1/QGIS33~1.0/apps/qgis/./python/plugins C:\PROGRA~1\QGIS33~1.0\apps\grass\grass83\etc\python C:\Users\Ankit\Documents C:\Program Files\QGIS 3.36.0\bin\python39.zip C:\PROGRA~1\QGIS33~1.0\apps\Python39\DLLs C:\PROGRA~1\QGIS33~1.0\apps\Python39\lib C:\Program Files\QGIS 3.36.0\bin C:\PROGRA~1\QGIS33~1.0\apps\Python39 C:\PROGRA~1\QGIS33~1.0\apps\Python39\lib\site-packages C:\PROGRA~1\QGIS33~1.0\apps\Python39\lib\site-packages\win32 C:\PROGRA~1\QGIS33~1.0\apps\Python39\lib\site-packages\win32\lib C:\PROGRA~1\QGIS33~1.0\apps\Python39\lib\site-packages\Pythonwin C:/Users/Ankit/AppData/Roaming/QGIS/QGIS3\profiles\default/python C:\Users/Ankit/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ImportEpanetInpFiles/impcount.py

balks commented 3 months ago

Hi there, I replaced the integer '1' with Qgis.RednerUnit.RenderPixels in the file qgisred_utils.py in other words: open the file C:\Users/Ankit/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QGISRed\tools\qgisred_utils.py (using notepad++ or similar) and replace line 261 with the following, that should help I think: lineSymbol.setWidthUnit(Qgis.RenderUnit.RenderPixels) # Pixels

fmartine commented 3 months ago

For those who want to use QGISRed with new QGIS versions after 3.28 and avoid the previous error you can download a new testing beta version 0.16.11 of QGISRed from the following link: https://qgisred.upv.es/files/plugin/QGISRed_v0.16.11.zip

If you have a previous version (included 0.16.0):

  1. Uninstall the QGISRed plugin from the QGis plugin manager.
  2. Close QGis
  3. Go to Windows Applications and Features and uninstall the application named QGISRed (I guess version 1.0.16.0)).
  4. Follow the next steps.

If you have installed a version greater or equal than 0.16.1:

  1. Download the zip from previous link
  2. Open QGis and go to the Plugin Manager
  3. Install the QGISRed plugin from ZIP (use the downloaded zip file)
  4. When using it for first time, it will ask to install the new dependencies.
  5. After installing them the webpage of QGISRed will be shown
  6. Subscribe to the newsletter if desired and close de page.
  7. If QGISRed icons are not shown in the toolbars, go again to the Plugin Manager, select the Installed tab and ensure that the checkbox of QGISRed is activated.

Good luck

balks commented 3 months ago

Wow, thanks, that is a nice update!

For me (QGIS 3.34.3) the installation was fine. Some small issues still remain though:

fmartine commented 3 months ago

Thank you @balks for your comment y the missing letter on .setPlacements.

The disappearance of nodes and pipes with the zoom level has intrigued me. The reason is that QGIS creates a spatial index automatically to visualise these elements depending on the zoom level, which is very useful when there is a lot of graphical information, but not in this case.

The spatial indexes created are stored in the files projectname_pipes.qix and projectname_nodes.qix. If you delete them, they are fine. But when you move nodes they reappear and for now I don't know how to avoid it, except to program the deletion of those files every time a node is moved, in case they are created.