FastFieldSolvers Forum
FastFieldSolvers Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
 All Forums
 FastFieldSolvers
 FasterCap and FastCap2
 Export_mesh for FreeCAD
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

alain

2 Posts

Posted - Feb 06 2018 :  10:35:54  Show Profile  Reply with Quote
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...

Enrico

545 Posts

Posted - Feb 06 2018 :  18:00:35  Show Profile  Reply with Quote
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
Go to Top of Page

alain

2 Posts

Posted - Feb 14 2018 :  18:13:42  Show Profile  Reply with Quote
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

Edited by - alain on Feb 15 2018 11:23:20
Go to Top of Page

Enrico

545 Posts

Posted - Feb 16 2018 :  18:17:56  Show Profile  Reply with Quote
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

Go to Top of Page

markfilan

United Arab Emirates
1 Posts

Posted - Oct 11 2019 :  08:47:50  Show Profile  Reply with Quote
try this...Python Tutorial

ht*p://net-informations.com/python/default.htm

Edited by - markfilan on Oct 11 2019 08:49:25
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
FastFieldSolvers Forum © 2020 FastFieldSolvers S.R.L. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.06