how to get textfiles open into the freecad editor
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
how to get textfiles open into the freecad editor
To add more comfort I'm looking for a method to open and edit text- and yaml files with the text editor inside freecad.
I can open macros and py-files but other filetypes .txt, .yaml not
csv Files are opened as calculation sheets
how to configure freecad to open text files (and adding a tool for syntax highlighting)
I can open macros and py-files but other filetypes .txt, .yaml not
csv Files are opened as calculation sheets
how to configure freecad to open text files (and adding a tool for syntax highlighting)
Re: how to get textfiles open into the freecad editor
Code: Select all
FreeCAD.addImportType("Yaml file (*.yaml)","mymodule")
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: how to get textfiles open into the freecad editor
I have tested this, but it opens a3D window and not a text window
what is wrong with the open method to get a text window?
what is wrong with the open method to get a text window?
Code: Select all
import os
import FreeCAD
def open(filename):
docname=os.path.split(filename)[1]
doc=FreeCAD.newDocument(docname)
# fill content
return doc
Re: how to get textfiles open into the freecad editor
Code: Select all
FreeCAD.newDocument
If you want to have a text editor then create an instance of QTextEdit and add it to the mdi area.
- ebrahim raeyat
- Posts: 619
- Joined: Sun Sep 09, 2018 7:00 pm
- Location: Iran
- Contact:
Re: how to get textfiles open into the freecad editor
Thank for your reply. I found it useful, but i want to know if i want to open an existing file format (like *.xlsx), but I want to process my open function, not predefined function. I am writing pyconcrete workbench that reads exported excel file from CSI SAFE software and draw foundation and so on. how can i do that?wmayer wrote: ↑Tue Jun 23, 2015 3:56 pmThen mymodule is a Python module that implements the method "open(filename, documentname)". The second parameter can be ignored in your case.Code: Select all
FreeCAD.addImportType("Yaml file (*.yaml)","mymodule")
thanks for your help.
Re: how to get textfiles open into the freecad editor
With
you register your module "mymodule" to handle Excel files. When you load an Excel via File > Open then the system searches for the "open" function of the module that has registered the xlsx format and calls it.
Code: Select all
FreeCAD.addImportType("Excel file (*.xlsx)","mymodule")
Re: how to get textfiles open into the freecad editor
as an example see frd calculix result files in FEM:
https://github.com/FreeCAD/FreeCAD/blob ... nit.py#L37
and
https://github.com/FreeCAD/FreeCAD/blob ... py#L46-L49
https://github.com/FreeCAD/FreeCAD/blob ... nit.py#L37
and
https://github.com/FreeCAD/FreeCAD/blob ... py#L46-L49
- ebrahim raeyat
- Posts: 619
- Joined: Sun Sep 09, 2018 7:00 pm
- Location: Iran
- Contact:
Re: how to get textfiles open into the freecad editor
Thanks a lot. how can i overwrite default xlsx opening format? now it give me an option to select on of them, but i can't that.bernd wrote: ↑Wed Sep 04, 2019 8:04 pm as an example see frd calculix result files in FEM:
https://github.com/FreeCAD/FreeCAD/blob ... nit.py#L37
and
https://github.com/FreeCAD/FreeCAD/blob ... py#L46-L49