FreeCAD / FreeCAD-macros

A repository for FreeCAD macros
https://freecad.org/wiki/Macros_recipes
156 stars 139 forks source link

airfoil import and scale Doesn't work on linux #166

Closed warriorman8 closed 8 months ago

warriorman8 commented 10 months ago

As described in the title and when attempting to run it says: <class 'AttributeError'>: 'PySide2.QtCore.QCoreApplication' object has no attribute 'activeWindow'

galou commented 10 months ago

The title doesn't mention any macro.

warriorman8 commented 10 months ago

regardless it mentions a problem in line 38. I activate sketch editor, click the icon and it doesn't work because it is on linux.

warriorman8 commented 10 months ago

the problem refers to airfoil import and scale

warriorman8 commented 4 months ago

This fixed did not work at all, please actually test it on a linux distribution.

jpretori commented 1 month ago

I run Arch and am happy to help test. When I search the Addon manager for "airfoi" I get these results. Which of them are we talking about?

2024-08-09_scrot

warriorman8 commented 1 month ago

import and scale (second)

jpretori commented 1 month ago

import and scale (second)

Thanks @warriorman8. Please will you attach the .dat file you use when encountering the problem?

EDIT: I tried with 2 airfoil files I found here, both give me error messages unlike what you're getting: https://tracfoil.com/airfoils/index.php

warriorman8 commented 1 month ago

aerofoil.txt

jpretori commented 1 month ago

OK I tried to import this.

I was unable to even see the file in the load dialog until I changed its extension to .dat. So I did that.

  1. I renamed the file to aerofoil.dat so the dialog box could see it
  2. Made the chord length 100
  3. Left the radio button on DWire

I get this error message in the Report view:

10:29:17 /home/johan/.local/share/FreeCAD/Macro/AirfoilImport&Scale.FCMacro:89: DeprecationWarning: 'exec' will be removed in the future. Use 'exec' instead. self.dialog.exec_() 10:29:19 Error, not a valid .dat file

This is the same as I got for the other .dat files I tried.

So I fiddled around with the macro itself, and made it import the traceback module & print out more complete exception details. Here is the message it ended up giving:

10:49:02 Error, not a valid .dat file 10:49:54 (1)<class 'SyntaxError'>: '(' was never closed (AirfoilImport&_Scale.FCMacro, line 77) 10:50:16 Error, not a valid .dat file 10:50:16 Traceback (most recent call last): 10:50:16 File "/home/johan/.local/share/FreeCAD/Macro/AirfoilImport&_Scale.FCMacro", line 103, in proceed 10:50:16 importAirfoilDAT.insert(f1,"Unnamed") 10:50:16 File "/usr/lib/freecad/Mod/Draft/importAirfoilDAT.py", line 106, in insert 10:50:16 obj = process(filename) 10:50:16 ^^^^^^^^^^^^^^^^^ 10:50:16 File "/usr/lib/freecad/Mod/Draft/importAirfoilDAT.py", line 136, in process 10:50:16 afile = pythonopen(filename, 'r') 10:50:16 ^^^^^^^^^^ 10:50:16 NameError: name 'pythonopen' is not defined 10:50:16
10:50:16 During handling of the above exception, another exception occurred: 10:50:16
10:50:16 Traceback (most recent call last): 10:50:16 File "/home/johan/.local/share/FreeCAD/Macro/AirfoilImport&_Scale.FCMacro", line 113, in proceed 10:50:16 traceback.print_exception(sys.exc_info()) 10:50:16 File "/usr/lib/python3.12/traceback.py", line 123, in print_exception 10:50:16 value, tb = _parse_value_tb(exc, value, tb) 10:50:16 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10:50:16 File "/usr/lib/python3.12/traceback.py", line 104, in _parse_value_tb 10:50:16 raise TypeError(f'Exception expected for value, ' 10:50:16 TypeError: Exception expected for value, tuple found

Seems like the importAirfoilDAT module has some problem.

@galou could you please give some help at this point? Searching Github it seems like this is somehow part of Freecad? How do we proceed from here?

galou commented 1 month ago

import and scale (second)

It's stated that the second item on the list is from the wiki and the third is from git. Someone should update the git version (@quick61) .

galou commented 1 month ago

The error mentioned by @jpretori was changed (fixed?) with https://github.com/FreeCAD/FreeCAD/commit/ff11cd25ee99b5e959616f3805f0d9bfd3a0be76.

I was able to import the file above but I have the impression that the "Chord Length" parameter doesn't do anything. I also get the error message "Error, not a valid .dat file" though.

jpretori commented 1 month ago

I fiddled with it some more, but got nowhere. I'm willing to help, but don't know what to do. So for now I'm going to leave it alone until someone suggest something specific that might be helpful :)