Get coordinates of an imprinted point, or catch intersection error in Lua

Pamela Markland
Pamela Markland Altair Community Member
edited August 15 in Community Q&A

I am using FEKO 2024.1, Legacy.

I would like to use Lua to do some extra processing on my model in CADFEKO. In a Lua script, I would like to "imprint" a point on my object (easily done), and then retrieve the coordinates of the imprinted point.   I can get these coordinates by clicking on the imprinted point in the UI, but I don't see any way to get them in Lua.

Alternately, in a Lua script, I would like to take the intersection of one object with another, and take different actions depending on whether the intersection operation is "successful" or not.  Doing the intersection in Lua is easy, but I can't find a way to come back to the Lua script when the intersection fails (produces no object) - FEKO just stops with an error message.  The usual Lua error handling (pcall) doesn't work.

A way to either get imprinted point coordinates or catch an intersection operation error in Lua would be greatly appreciated.

Thanks,

Pam   

Tagged:

Answers

  • Johan_Huysamen
    Johan_Huysamen
    Altair Employee
    edited August 15

    Hi Pam

    I'm not aware of a way to retrieve the coordinates of the resulting imprinted points.

    Also, I do not think it is possible to catch the error from the invalid intersection operation, but there might be a way around this:

    If you were to mesh the two parts you would like to intersect, you could use the GetIntersectingMeshes() method to test if the (unlinked meshes of the) two parts intersect. If they do, then the intersect operation should complete without an error.

    The GetIntersectingMeshes() method returns a list mesh mesh parts that intersect.

    Assuming for example you have two geometry parts "cylinder1" and "sphere1" that have been meshed, the following code should work:

    -- UnlinkMeshes
    cylinder1_mesh = cylinder1:UnlinkMesh()
    sphere1_mesh = sphere1:UnlinkMesh()

    intersectingMeshes = project.Contents.Meshes.Find:GetIntersectingMeshes({cylinder1_mesh, sphere1_mesh})

     

    if #intersectingMeshes == 2 then
        -- Intersect as the list contains two parts 
        intersect1 = project.Contents.Geometry:Intersect({cylinder1, sphere1})
    else
        print("The parts do not intersect.")
    end

    -- Delete the unlinked meshes

    project.Contents.Meshes:DeleteEntities({cylinder1_mesh})
    project.Contents.Meshes:DeleteEntities({sphere1_mesh})

     

    Kind regards,

    Johan H