Path to FeaturePython with PropertyFile
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Path to FeaturePython with PropertyFile
If I have created a FeaturePython with a Property of "App::PropertyFile" how do I obtain the Path to the file?
I assume it is one of the main FreeCAD calls.
I assume it is one of the main FreeCAD calls.
Re: Path to FeaturePython with PropertyFile
It is not available as a property of DocumentObject?keithsloan52 wrote: ↑Sat Feb 04, 2023 12:24 am If I have created a FeaturePython with a Property of "App::PropertyFile" how do I obtain the Path to the file?
I assume it is one of the main FreeCAD calls.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Path to FeaturePython with PropertyFile
Well it has created one, I assume it creates a file in the same directory that will be used when the freecad file is saved as a zip Fc? No?
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Path to FeaturePython with PropertyFile
Looking at property App::PropertyFileInclude https://wiki.freecad.org/FeaturePython_ ... leIncluded
I think it might be getDocTransientPath().
I will try when I get back to hotel this evening.
I think it might be getDocTransientPath().
I will try when I get back to hotel this evening.
Re: Path to FeaturePython with PropertyFile
From what I know, it usually reuse the last path, or probably the Home dir of the user, if you don't specify one, there is also a preference in Preferences, reachable withkeithsloan52 wrote: ↑Sat Feb 04, 2023 8:31 am Well it has created one, I assume it creates a file in the same directory that will be used when the freecad file is saved as a zip Fc? No?
Code: Select all
print(FreeCAD.ParamGet("User parameter:BaseApp/Preferences/General").GetString('FileOpenSavePath'))
Code: Select all
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/General").SetString('FileOpenSavePath', "<Your Desired Path>")
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: Path to FeaturePython with PropertyFile
keithsloan52 wrote: ↑Sat Feb 04, 2023 8:44 am Looking at property App::PropertyFileInclude https://wiki.freecad.org/FeaturePython_ ... leIncluded
I think it might be getDocTransientPath().
I will try when I get back to hotel this evening.
Code: Select all
DOC.getPropertyByName('FileName')
Code: Select all
DOC.getPropertyByName('TransientDir')
But I have tested them only on "standard objects" and not FeaturePython Objects.
Hope it helps.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: Path to FeaturePython with PropertyFile
App::PropertyFile and App::PropertyFileIncluded are quite different. You should not mix them up. Which are we talking about?
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Path to FeaturePython with PropertyFile
I know that, but the FileIncluded Doc mentioned getDocTransientPath() App::PropertyFile does not mention anything about where the file can be found.
I am trying to create a PythonFeature which has a property that has a File, that will get saved when the Object gets saved and I can add code to drive an external editor to edit the file.
York uses FileIncluded in the Arch workbench but think the usage is different
Re: Path to FeaturePython with PropertyFile
This will save a Txt file that I use as example to add "documentation" to a FCStd file, it is visible in when you open a FCStd document.keithsloan52 wrote: ↑Sat Feb 04, 2023 5:28 pmI know that, but the FileIncluded Doc mentioned getDocTransientPath() App::PropertyFile does not mention anything about where the file can be found.
I am trying to create a PythonFeature which has a property that has a File, that will get saved when the Object gets saved and I can add code to drive an external editor to edit the file.
York uses FileIncluded in the Arch workbench but think the usage is different
Code: Select all
info_txt = '''
Text file with new lines that
is saved in the final FCStd doc.
Regards
'''
txt_doc = out_doc.addObject("App::TextDocument","Text document")
txt_doc.Label = "Documentation"
txt_doc.Text = info_txt
viewtopic.php?t=38201
and
Embedding other files in: https://wiki.freecad.org/File_Format_FCStd
Hope it helps.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Path to FeaturePython with PropertyFile
Well if I use App::PropertyFile then I can achieve the desired functionality between the new OpenSCAD objects and an external editor (Emacs)
but the file is not saved with the FreeCAD file.
If I try App::PropertyFileIncluded then the file does not stay around long enough for me to use with an external editor.
A prototype replacement for the OpenSCAD work bench is at https://www.dropbox.com/scl/fo/m00vb2be ... 6o4gblubpo
The relevant source is OpenSCADFeatures.py class definition class SCADObject
External editor is hard coded EMACs on MacOS
Communication with Emacs uses pipes.
but the file is not saved with the FreeCAD file.
If I try App::PropertyFileIncluded then the file does not stay around long enough for me to use with an external editor.
A prototype replacement for the OpenSCAD work bench is at https://www.dropbox.com/scl/fo/m00vb2be ... 6o4gblubpo
The relevant source is OpenSCADFeatures.py class definition class SCADObject
External editor is hard coded EMACs on MacOS
Communication with Emacs uses pipes.