T O P I C R E V I E W |
alain |
Posted - Feb 06 2018 : 10:35:54 Hey guys,
I'm currently using FreeCAD Version 0.16 and wanted to use the EM workbench offered here: ht*ps://github.com/ediloren/EM-Workbench-for-FreeCAD
So I created a new user macro by copying the code from "Export_mesh.py" into the macros window. When executing the macro nothing happens though, am I missing something? Do I have to modify the code myself? Or why doesn't it work?
I created a simple test mesh for a sphere, so the mesh shouldn't be a problem.
I'd be thankful for some advice... |
4 L A T E S T R E P L I E S (Newest First) |
markfilan |
Posted - Oct 11 2019 : 08:47:50 try this...Python Tutorial
ht*p://net-informations.com/python/default.htm |
Enrico |
Posted - Feb 16 2018 : 18:17:56 The export_mesh() function assumes you have already created a mesh in FreeCAD. It assumes you are a bit proficient in FreeCAD and are able to work in the environment. Generating a mesh is done using the standard FreeCAD Mesh workbench (this is fully via GUI).
I suggest you use the other function. You just need to select in the model window the parts you want to export, and then call the function with the proper parameters. Note that at present the function assumes that all faces are planar.
def export_faces(filename, isDiel=False, name="", showNormals=False, forceMesh=False, folder=DEF_FOLDER):
'''export faces in FasterCap format as conductor or dielectric interface
The function operates on the selection. The selection can be a face, a compound or a solid.
'filename' is the name of the export file
'isDiel' specifies if the mesh is a dielectric, so the function will add
a reference point to each panel to indicate which is the external side (outside)
'name' is the name of the conductor created in the file. If not specified, defaults
to the label of the first element in the selection set
'showNormals' will add a compound object composed by a set of arrows showing the
normal direction for each panel
'folder' is the folder in which 'filename' will be saved
Example:
export_faces("mymesh.txt", folder="C:/temp")
'''
In general, the following remarks apply for using the Macro:
Are you able to code in Python? If not, I suggest you to follow the official Python tutorial at ht*ps://docs.python.org/3/tutorial/index.html It is called tutorial, but actually it is comprehensive enough to make you go for a long while. The beauty of FreeCAD is that you can use Python, and run the whole tutorial as well, from within FreeCAD. You can look at ht*ps://w*w.freecadweb.org/wiki/Python_scripting_tutorial for basic instructions; but apart showing the Python console in FreeCAD (it is hidden by default) I suggest you run first the Python tutorial and then the FreeCAD Python tutorial. If you are quick and know how to code in other languages a couple of days should suffice.
After that, you should be able to run the macro (sorry for the complexity, will make things easier in the future, but we don't have a committed plan, unless we get some sponsorship here to improve the roadmap)
Best Regards, Enrico
|
alain |
Posted - Feb 14 2018 : 18:13:42 Hey Enrico,
From what I understand there a 3 functions defined in that Python script:
export_mesh(...) make_arrow(...) export_faces(...)
So do I have to save the whole script as a FreeCAD macro? Let's say I want to call export_mesh. There's an example in the function description:
mymeshGui = Gui.ActiveDocument.Mesh mymeshObj = mymeshGui.Object export_mesh("mymesh.txt", meshobj=mymeshObj, folder="C:/temp")
So I'd have to use the Python console in order to define mymeshGui, mymeshObj, filename and folder, then call export_mesh with the right parameters, and it should then export the mesh? Because that doesn't work for me.
Or do I have to save the functions differently, not as a macro, to call them through the Python console?
Thanks, Alain |
Enrico |
Posted - Feb 06 2018 : 18:00:35 Hi Alain,
you should share some additional details here. How are you using the macro? I'm afraid that the macro is still very rough; you should call the internal functions through the FreeCAD Python interface. In the function description there are comments about the parameters and the expected input, as well as an example of how to call the functions. Please be sure to understand how FreeCAD, and its Python interface, works.
Best Regards, Enrico
|
|
|