CfdPreferencePage is not a preference page

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
KAKM
Posts: 112
Joined: Tue May 04, 2021 12:17 am

CfdPreferencePage is not a preference page

Post by KAKM »

I'm trying to get the cfdOF workbench running, and I'm fairly certain the reason it currently doesn't work is that it can't find my OpenFOAM installation. So I went in to preferences to try and set the path, but the cfdOF preferences pane was blank. I checked to make sure the workbench was loaded, and it was. When I looked at the Report View, it showed these error messages:
Traceback (most recent call last):
10:11:04 File "/Users/Katy/Library/Preferences/FreeCAD/Mod/CfdOF/CfdPreferencePage.py", line 121, in __init__
10:11:04 self.setDownloadURLs()
10:11:04 File "/Users/Katy/Library/Preferences/FreeCAD/Mod/CfdOF/CfdPreferencePage.py", line 180, in setDownloadURLs
10:11:04 if self.testGetRuntime() == "MinGW":
10:11:04 File "/Users/Katy/Library/Preferences/FreeCAD/Mod/CfdOF/CfdPreferencePage.py", line 171, in testGetRuntime
10:11:04 runtime = CfdTools.getFoamRuntime()
10:11:04 File "/Users/Katy/Library/Preferences/FreeCAD/Mod/CfdOF/CfdTools.py", line 398, in getFoamRuntime
10:11:04 installation_path = getFoamDir()
10:11:04 File "/Users/Katy/Library/Preferences/FreeCAD/Mod/CfdOF/CfdTools.py", line 389, in getFoamDir
10:11:04 installation_path = detectFoamDir()
10:11:04 File "/Users/Katy/Library/Preferences/FreeCAD/Mod/CfdOF/CfdTools.py", line 438, in detectFoamDir
10:11:04 for d in FOAM_DIR_DEFAULTS[platform.system()]:
10:11:04 KeyError: 'Darwin'
10:11:04 CfdPreferencePage is not a preference page
and that looks to me like it needs to know where OpenFOAM is to set where OpenFOAM is. Can I just add the path to FOAM_DIR_DEFAULTS under "Darwin"? Will I need to recompile FreeCAD to get that change to take effect?

In case it matters, I'm running both FreeCAD and OpenFOAM-v2012 on a Mac via Homebrew.
OS: macOS 10.15
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24291 (Git)
Build type: Release
Branch: (HEAD detached at 0.19.2)
Hash: 7b5e18a0759de778b74d3a5c17eba9cb815035ac
Python version: 3.8.8
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.4.0
Locale: C/Default (C)
KAKM
Posts: 112
Joined: Tue May 04, 2021 12:17 am

Re: CfdPreferencePage is not a preference page

Post by KAKM »

Fixed it. I added Darwin as a key to the FOAM_DIR_DEFAULTS and PARAVIEW_PATH_DEFAULTS dictionaries in CfdTools.py.
I don't know if the PARAVIEW_PATH_DEFAULTS was going to contribute to the immediate problem, but it was easier to fix it at the same time than wait for it to pop up and make my life difficult later.
Restarted FreeCAD and the CfdOF preferences page came up fine.
techGuy
Posts: 126
Joined: Sat Jun 18, 2022 12:48 am

Re: CfdPreferencePage is not a preference page

Post by techGuy »

BTW... the "not a preference page" error is generated in src/Gui/DlgPreferencesImp.cpp:

Code: Select all

/**
 * Create a new preference page called \a pageName on the group tab \a tabWidget.
 */
void DlgPreferencesImp::createPageInGroup(QTabWidget *tabWidget, const std::string &pageName)
{
    PreferencePage* page = WidgetFactory().createPreferencePage(pageName.c_str());
    if (page) {
        tabWidget->addTab(page, page->windowTitle());
        page->loadSettings();
        page->setProperty("GroupName", tabWidget->property("GroupName"));
        page->setProperty("PageName", QVariant(QString::fromStdString(pageName)));
    }
    else {
        Base::Console().Warning("%s is not a preference page\n", pageName.c_str());
    }
}
You will receive this error if you use anything other than a page (ie QWidget) for a preferencePage.
Post Reply