Deleting Mesh generated during ExportFile call from API

57 views
Skip to first unread message

ajfi...@gmail.com

unread,
May 20, 2021, 1:38:01 PM5/20/21
to OpenVSP
Hi all,

I'm using the API to export a set to STL, which works great. But it generates a mesh in the model I would like to delete, and I can't find a good way to grab the mesh ID.

ExportFile doesn't return a results ID, but I was able to work around that with result_id = vsp.FindLatestResultsID( 'point' )

But a call to  vsp.PrintResults(result_id) reveals that the mesh ID isn't available:
                [result_name]       [type]      [#]     [current values-->]
                Ishell              1           1       727.386403 1438.322583 885.142673 -127.770374 350.868361 -232.136562
                Isolid              1           1       77.496166 139.316713 80.297749 -13.752644 37.784115 -24.795389
                area                1           1       124.388213
                areaWet             1           1       124.069195
                cgShell             3           1       52.090406,-7.842990,4.441839
                cgSolid             3           1       51.841593,-7.684754,4.006864
                vol                 1           1       15.546105
                volWet              1           1       15.537337

Am I missing something? Is there a convenient way to get this ID? Maybe like the Mesh_GeomID result from CompGeom?

Any help is appreciated :) 
-AJ

Rob McDonald

unread,
May 20, 2021, 2:27:27 PM5/20/21
to ope...@googlegroups.com
Looks like something that has been overlooked.  We should improve the API to make this easier.

I am not 100% convinced that the resultID you're getting is from the STL export -- it looks like the result of running CompGeom or MassProp rather than just a simple STL export.  Digging deeper, the only thing that creates a match to 'point' is write_degenGeomPointResultsManager() which makes me think that is a leftover from running DegenGeom before.  Perhaps you did not do it intentionally, it may have been triggered by VSPAERO or ParasiteDrag...

If you run CompGeom first - then STL export will not create a new MeshGeom and will export the results of the CompGeom (whose GeomID should be reported in CompGeom).

However, if there is no MeshGeom in the model, STL export will generate an STL of the model (without intersecting components) and will export that.  As you have noted, it does not delete the MeshGeom automatically.

I suspect that if you use a simple FindGeoms(), the new MeshGeom will be the last entry in the returned list.  You could also FindGeomsWithName("MeshGeom") and if you don't have any other Geoms with that name in your model, it will be the one just created.

If for some reason those don't work and you need an immediate solution, you could run FindGeoms() before you call export - and again after the export -- and then figure out which entry was added.

Rob




--
You received this message because you are subscribed to the Google Groups "OpenVSP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openvsp+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openvsp/499d5f89-080d-46a9-b9e2-36859fbea28cn%40googlegroups.com.

ajfi...@gmail.com

unread,
May 20, 2021, 3:51:27 PM5/20/21
to OpenVSP
Thanks Rob, the workarounds will get me where I need to go. I may add a feature request on github for the API improvement to make it easier for next time.
-AJ

ajfi...@gmail.com

unread,
May 20, 2021, 4:06:50 PM5/20/21
to OpenVSP
Figured I'd post my solution here, in case anyone runs into the same issue:

        allGeomsBeforeExport = vsp.FindGeoms()
        vsp.ExportFile(stlFullPath, set_id, vsp.EXPORT_STL)
        # ExportFile creates a mesh geom we want to delete
        # Not currently an easy way to grab this
        # So we are getting the full list of geometry items, and deleting any item that wasn't in the list
        for geom in vsp.FindGeoms():
            if not (geom in allGeomsBeforeExport):
                vsp.DeleteGeom(geom) 

ajfi...@gmail.com

unread,
Jun 10, 2021, 7:39:07 AM6/10/21
to OpenVSP
This is now available in the API as of 3.24. New code looks like:

        mesh_id = vsp.ExportFile(stlFullPath, set_id, vsp.EXPORT_STL)
        # Delete the resulting mesh
        vsp.DeleteGeomVec(mesh_id)

Reply all
Reply to author
Forward
0 new messages