Say I export a file as a fbx, I would like to store its file path as a string. How do I accomplish this?
Solved! Go to Solution.
Solved by Revitalizer. Go to Solution.
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
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.
Hi,
there is an Application.FileExported event, providing a Path property in its FileExportedEventArgs argument.
Also ControlledApplication has this FileExported event.
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!
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?