SOLVED : Passing a files system path to a FCMacro

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
keithsloan52
Veteran
Posts: 2755
Joined: Mon Feb 27, 2012 5:31 pm

SOLVED : Passing a files system path to a FCMacro

Post by keithsloan52 »

I wish to write a Macro that process a directory, is there a good way to pass a file system path to a FCmacro?

Thanks
keithsloan52
Veteran
Posts: 2755
Joined: Mon Feb 27, 2012 5:31 pm

Re: SOLVED : Passing a files system path to a FCMacro

Post by keithsloan52 »

Code: Select all

from PySide import QtGui
name=QtGui.QFileDialog.getOpenFileName()[0]
keithsloan52
Veteran
Posts: 2755
Joined: Mon Feb 27, 2012 5:31 pm

Re: SOLVED : Passing a files system path to a FCMacro

Post by keithsloan52 »

In the end went with

Code: Select all

import PySide
from PySide import QtGui ,QtCore
from PySide.QtGui import *
from PySide.QtCore import *
path = FreeCAD.ConfigGet("UserAppData")

#getExistingDirectory(QWidget *parent = nullptr, const QString &caption = QString(), const QString &dir = QString(), QFileDialog::Options options = ShowDirsOnly)
Directory = PySide.QtGui.QFileDialog.getExistingDirectory(None, "Select a directory",path)
print(f"Selected Directory {Directory}")
Post Reply