Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get file path of recently exported file

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
fredsonlag
804 Views, 7 Replies

Get file path of recently exported file

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

7 REPLIES 7
Message 2 of 8
jeremytammik
in reply to: fredsonlag

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

Message 3 of 8
fredsonlag
in reply to: jeremytammik

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.

 

Message 4 of 8
Revitalizer
in reply to: fredsonlag

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
fredsonlag
in reply to: Revitalizer

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!

Message 6 of 8
fredsonlag
in reply to: fredsonlag

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?

Message 7 of 8
jeremytammik
in reply to: fredsonlag

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

Message 8 of 8
fredsonlag
in reply to: jeremytammik

Thanks Jeremy!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community