Creating Simple 2D or 3D Geometries in PrePoMax

Hi! I am new to PrePoMax and wanted to model simple 2D problems like a plate with a hole. Instead of creating the geometry externally and brining it in, I wanted to check if I could create simple geometries within PrePoMax. A quick check of the menu revealed that that capability is not present. Could someone please confirm? If indeed absent, is it planned for an upcoming release?

Indeed, it’s not yet available or planned, from what I know, because PrePoMax currently focuses on the wide range of FEM features that still need to be implemented. Geometry can be easily generated in FreeCAD using primitives or Part workbench operations. Currently, it has to be exported as STEP files and imported to PrePoMax, but perhaps it would be possible to automate it with some script or plug-in. Both FreeCAD and PrePoMax use the same geometry kernel (OCC), so maybe primitives could be implemented also in PrePoMax. Another option would be to use Gmsh for that. It also supports some basic geometric features.

2 Likes

How do I do this? Can I also similarly create nodes and 1D elements such as truss or beam elements using Gmsh?

Sure, you can create 1D elements in Gmsh. Or e.g., draw some simple 2D shapes and extrude/revolve them along with the mesh to get hexahedral elements. Maybe try Gmsh in FreeCAD where 1D elements are supported. The newest version also has editable .geo scripts.

2 Likes

alternatively, a constructive solid geometry can take advantages for simple geometry models. There’s small apps OCC-CSG based text user interfaces available support Step files to be imported in PrePoMax.

-------------------------------------------------------------
----        CSG Tool based on the OCCT CAD Kernel        ----
----                    Version 0.9.9                    ----
---- 2018-2019 by Michael Hoffer (info@michaelhoffer.de) ----
----                   www.mihosoft.eu                   ----
-------------------------------------------------------------

USAGE: 

Help & Info:

 occ-csg --help
 occ-csg --version

Creating Primitives:

 occ-csg --create box x1,y1,z1,x2,y2,z2                            box.stp
 occ-csg --create sphere x1,y1,z1,r                                sphere.stp
 occ-csg --create cyl x1,y1,z1,r,h                                 cyl.stp
 occ-csg --create cone x1,y1,z1,r1,r2,h                            cone.stp
 occ-csg --create helix r,profile_r,pitch,num_revolutions          helix.stp
 occ-csg --create helix r,profile_face.stp,pitch,num_revolutions   helix.stp
 occ-csg --create polygons x1,y1,z1,x2,y2,z2,... p1v1,p1v2,p1v3,...:p2v1,p2v2,p2v3,... polygons.stp
 occ-csg --create 2d:circle x,y,r                                  2dcircle.stp
 occ-csg --create 2d:polygon x1,y1,x2,y2,...                       2dpolygon.stp
 occ-csg --create 2d:rect x1,y1,x2,y2                              2drectangle.stp
 occ-csg --create 2d:round-rect x,y,width,height,corner_r          2drectangle.stp
 occ-csg --create extrusion:polygon ex,ey,ez,x1,y1,z1,x2,y2,z2,... extrude.stp
 occ-csg --create extrusion:file ex,ey,ez                          2dpath.stp extrude.stp

Format Conversion:

 occ-csg --convert file1.stl file1.stp
 occ-csg --convert file1.stp file1.stl 0.1

Geometric Transformation:

 occ-csg --transform translate x,y,z                               file1.stp file1-translated.stp
 occ-csg --transform scale     sx,sy,sz                            file1.stp file1-scaled.stp
 occ-csg --transform rot       dir_x,dir_y,dir_z,angle file1.stp   file1-rotated.stp
 occ-csg --transform matrix    t1,t2,t3,...,t12 file1.stp          file1-transformed.stp

Boolean Operators, Constructive Solid Geometry (CSG):

 occ-csg --csg union file1.stp file2.stp file-out.stp
 occ-csg --csg difference file1.stp file2.stp file-out.stp
 occ-csg --csg intersection file1.stp file2.stp file-out.stp

Shape Editing:

 occ-csg --edit split-shape shape.stp stp
 occ-csg --edit round-edges radius shape.stp shape-rounded.stp
 occ-csg --edit chamfer-edges radius shape.stp shape-chamfered.stp


Shape Info:

 occ-csg --info bounds file.stp      
 occ-csg --info bounds file.stp      bounds.stp
 occ-csg --info volume file.stp tol

to modeling plate with hole, below few commands needed as example.

occ-csg --create box 0,0,0,100,100,10 plate.stp
occ-csg --create cyl 50,50,0,10,10 cyl.stp
occ-csg --csg difference plate.stp cyl.stp platehole.stp

2 Likes

And there’s also OpenSCAD where it’s easy to programmatically generate simple geometries:

FreeCAD has a workbench for OpenSCAD too.

OpenSCAD is definitely good but lack of standard format like Step files, so there’s another project exist called CadQuery to fulfill this limitation. However, since it’s Python based make the installation is not compact and simple, large also.

internally, Gmsh library being used in PrePoMax is capable to generate 2D or 3D Step files by calling script of *.geo files. Unfortunately, i previously heard about complication with history and hope some workaround is possible in the future.

Since more complex geometry modeling and preparation tasks (including e.g. partitioning) will require CAD software anyway, I would still recommend FreeCAD since it can even run in no GUI mode: https://wiki.freecad.org/Headless_FreeCAD

This can be submitted from cmd with FreeCAD’s python binary.

2 Likes

sure FreeCAD can be great when they are focused on CAD only and direct modeling priority or BIM as addition, unfortunately many projects drive by community leads to parametric similar with SolveSpace. Another complexity is in extension workbench to capable doing CAE i.e finite element and computation fluid dynamics, etc. I’m looking out for this condition and found Macad3D is given promise, not yet complete and powerful due to year of development but usable in general, scripting also supported.

1 Like

There’s also BRL-CAD, but it looks dated. FreeCAD has a built-in FEM workbench (using CalculiX, Elmer, and some other solvers - even Code Aster might be added soon), not to mention technical drawings, AutoCAD-like drafts, and BIM. There’s also a very good add-on workbench for CFD with OpenFOAM.

2 Likes

I don’t know it is feasible, but how about FreeCAD and Prepromax talk with each other? Maybe it could work like a plugin.

Like Ansys has Spaceclaim.

I my case it would be highly nice to edit geometries I am working on. I thought about something like a right click in the geometry and “Open with FreeCAD”, something like that, so edit it and the geometry can be imported and updated with “history”. I think one challenge would be the fact that we draw in .FCStd and we import in .STEP (or similar).

I think it would be easier than implementing an integrated CAD.

1 Like

default installation of FreeCAD already have FEM workbench similar with plugins, it has capability in meshing, define boundary condition and viewing results all sharing similarity feature with PrePoMax. I think it would be separated project and goals, CAD capabilities.in PrePoMax maybe limited or start with constructive solid geometry (primitive shape, Boolean and transform) without sketch constraint features. So, a basic of FE simulation with simple geometry s available no relying on external CAD requirement.

1 Like

The below FreeCAD macro will export the selected object(s) to STEP and start PrePoMax with this STEP file already imported. You just have to adjust the path to PrePoMax installation directory and it should work. Note that it sets the SI(mm) unit system in PrePoMax, but you can change it if you want.

import FreeCAD
import FreeCADGui
import Part
import os
import subprocess

def export_and_run_prepomax():
    # 1. Get selected objects in the FreeCAD interface
    selection = FreeCADGui.Selection.getSelection()
    
    if not selection:
        FreeCAD.Console.PrintError("Error: Select at least one object in the tree view (or 3D view) to export.\n")
        return

    # 2. Define the destination path for the STEP file
    # By default, it will save the file on your Desktop as "FreeCAD_to_PrePoMax.step"
    desktop_path = os.path.join(os.path.expanduser("~"), "Desktop")
    step_file_path = os.path.join(desktop_path, "FreeCAD_to_PrePoMax.step")
    
    # 3. Export selected geometry to a STEP file
    try:
        Part.export(selection, step_file_path)
        FreeCAD.Console.PrintMessage(f"Successfully exported file to: {step_file_path}\n")
    except Exception as e:
        FreeCAD.Console.PrintError(f"Error during export: {e}\n")
        return

    # 4. Run PrePoMax from the command line
    # Using the PrePoMax.com file for easy handling from the Windows command line
    prepomax_executable = r"C:\Program Files\PrePoMax\PrePoMax v2.5.0\PrePoMax.com"
    
    if not os.path.exists(prepomax_executable):
        FreeCAD.Console.PrintError(f"Error: Executable file not found at path: {prepomax_executable}\n")
        return

    # Call the process using the -f flag to automatically import the geometry
    # and the -u flag to define the unit system
    try:
        subprocess.Popen([prepomax_executable, "-f", step_file_path, "-u", "MM_TON_S_C"])
        FreeCAD.Console.PrintMessage("Starting PrePoMax with MM_TON_S_C unit system...\n")
    except Exception as e:
        FreeCAD.Console.PrintError(f"Error while starting PrePoMax: {e}\n")

# Call the function
export_and_run_prepomax()
2 Likes

In PrePoMax, you can work with geometry that needs to be modified in the following way.

  • Open the geometry in CAD program and export it into .step.
  • In PrePomax, import it and prepare the model. If changes in the geometry are needed, go to CAD and make them. Export to .step again.
  • In PrePoMax, import new geometry (Part2), select the old and new parts, and use the feature Swap Part Geometries.
  • The geometries of the parts are replaced, and you can delete the old geometry (Part2)
3 Likes

@FEAnalyst nice! Thanks.

@Matej Thank you Matej. I didn’t know this workflow.

@Matej There’s no command to set the Model Space from cmd, right ?

The unit system can be defined, but only when the command line is used to import a file. So first option f with a file name to import and then option u with a unit system name.

1 Like

Yes, that’s what I have in the script posted above, but it always sets 3D Model Space while sometimes it would be useful to automatically import the geometry to one of the 2D spaces.

1 Like

Aaaa, model space. No, there is no option for that.