Jump to content
Mr. Arne Bergmann

Exporting custom file formats using Features [4.0 Update]

Recommended Posts

The attached project shows the export feature I presented at this year's User's Meeting.

 

Its purpose is to show how to use Features to export and import custom file formats using Features. Additionally, it shows how to connect such an export to a SoftwareConnector. [update 4.0]: Please read the second post in this topic to see the improvements regarding connecting your export feature with the Software connector.

 

The geometry is based on the "Basic Hull Model" sample. There are two FStructPanelMeshes (main and stem) that are grouped in a FPanelMeshGroup and transformed using the combination of FImagePanelMeshGroup and FScaling.

 

Running the Feature "exporter" will export the scaled PanelMeshes to a file (see the console output for the full path). The Feature "importer" will import files of the correct format (e.g. one that was exported using the "exporter") to structured panel meshes.

 

The "success" value that is calculated in the export Feature is added to the configuration of a SoftwareConnector, so that it is ran prior to running the external computation.  [update]: In 4.0 this is no longer necessary (see next post).

 

 

Notes:

  • The export feature is written to be used within a SoftwareConnector. In order to make sure that the feature is triggered before running the computation, it takes the file path as an argument with the value set to "getInputDir()". That command yields the input directory of the currently running computation. By setting that command as an argument value, the feature becomes dependent (i.e. a "client") of the so-called PathManager. This ensures, that the export will be triggered before running a computation. If you execute the feature outside of the computation-run the exported file will not be in the correct location for your external program. [update]: In 4.0 this is no longer necessary (see next post).
  • Using "getInputDir()" instead of "getResultsDir()" (which gets the actual working directory of the external process) will export the file to the "input" sub-directory of the computation's results directory. This is done in order to allow the feature to be used in conjunction with remote executions of computations using the SshResourceManager. [update]: In 4.0 this is no longer necessary, files referenced with a relative path are automatically written into the input directory (see next post).

featureExport.fdb

Share this post


Link to post
Share on other sites

Here's a little update including some new functionality that came with 4.0.

 

post-7-0-44709200-1439214399_thumb.png

 

In order to make the connection of your custom export feature to the Software Connector easier, it is now possible to use an "Export Feature Definition" directly in the Software Connector. After adding a new "Input Geometry" item (top-left pane of the Software Connector; no. 1 in the screenshot above), it is now possible to choose "FeatureDefinition" as the "Source" (2 in the screenshot). After selecting it, you will be able to select one of the feature definitions from your project that do one of the following:

  • Write a file (i.e. use one of the "write" commands of FFile, including "openWrite")
  • Use an FExportCmd (e.g. FTrimesh.exportSTL())
  • Use one of the FExport objects (e.g. FExportStep)

After selecting a feature definition that does one of the above (3 in the screenshot), its arguments can be filled directly in the object editor of the SoftwareConnector entry (4 in the screenshot).

After doing so, the selected feature definition will be executed just like a regular export when the Software Connector runs.

 

So, it is no longer needed to "connect" an instance of the feature definition with an entry of the Software Connector or to make sure that the feature goes out of date when a new design is created (see post above)!

 

Also, when writing files using the FFile type, it is now possible to just use a relative path (e.g. a file name only) in the export feature. If that is done, the file will automagically be written into the computation's input directory! So you do not have to worry about resolving the correct directory when writing your custom exports.

 

I think this makes exporting custom file formats through features a lot easier and way more convenient, so I hope you like it.

 

See the attached project to see a version of the project in the first post as it would be set-up in 4.0. The only two places to look at are the FeatureDefinition itself (which has not changed, except that it does not take the path to export to as an argument anymore, because it uses the file name only) and the "ExportAPF" entry of the software connector.

featureExport.fdb

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...