Get file path of recently exported file

Get file path of recently exported file

Anonymous
Not applicable
1,503 Views
7 Replies
Message 1 of 8

Get file path of recently exported file

Anonymous
Not applicable

Say I export a file as a fbx, I would like to store its file path as a string. How do I accomplish this?

0 Likes
Accepted solutions (1)
1,504 Views
7 Replies
Replies (7)
Message 2 of 8

jeremytammik
Autodesk
Autodesk

I don't quite understand your question.

 

Or is it as simple as it seems?

 

Look at the Document Export Method (String, String, ViewSet, FBXExportOptions):

 

 

http://www.revitapidocs.com/2018/02b2efba-9d7c-88bc-b43e-a541e169d832.htm

 

In the FBX export options, you can set the properties defining the export folder and filename or prefix.

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 8

Anonymous
Not applicable

Hi Jeremy,

 I used 

 

RevitCommandId id = RevitCommandId.LookupPostableCommandId(PostableCommand.ExportFBX); 
uiapp.PostCommand(id); 

 

so I can select the folder where I want to save the fbx file in. What I want to do is after it exports, I want to store the directory of where the fbx file was saved in a string.

 

0 Likes
Message 4 of 8

Revitalizer
Advisor
Advisor
Accepted solution

Hi,

 

there is an Application.FileExported event, providing a Path property in its FileExportedEventArgs argument.

Also ControlledApplication has this FileExported event.

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 5 of 8

Anonymous
Not applicable

Hello,

I tried using what you suggested and expected a dialog box to pop up after exporting the fbx file that prints the file location but unfortunately nothing happens after the export completes. This is what my code looks like:

 

public class Command : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Application app = uiapp.Application;
Document doc = uidoc.Document;

app.FileExported += App_FileExported;
RevitCommandId id = RevitCommandId.LookupPostableCommandId(PostableCommand.ExportFBX); 
uiapp.PostCommand(id);
app.FileExported -= App_FileExported;
return Result.Succeeded;
}// end Execute

private void App_FileExported(object sender, FileExportedEventArgs e)
{
TaskDialog.Show("Test", e.Path);
}
}

 

I'm not getting any errors though, what am I doing wrong?

 

Thanks!

0 Likes
Message 6 of 8

Anonymous
Not applicable

I realized I was supposed to subscribe to the event in IExternalApplication instead of IExternalCommand. The task dialog pops up now after exporting the fbx. However, it only works when I choose "FBX files (*.fbx)" under "Files of type:" in the fbx export dialogue box but doesn't when "FBX 2015 and Previous (*.fbx)" (default option) is selected. Any reason why this is?

0 Likes
Message 7 of 8

jeremytammik
Autodesk
Autodesk
Thank you for the info. I asked the development team for you whether this is expected behaviour.


Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 8 of 8

Anonymous
Not applicable

Thanks Jeremy!

0 Likes