// Initialize API.
HpdApi api = HpdApi.GetInstance();
api.Init();
// Open project and document.
Project project = api.OpenProject(@"D:\MyHpDproject.hxproj");
Variant variant = project.GetVariants()[0];
variant.Open(false, false);
Workdesk workdesk = variant.GetWorkdesks()[0];
// Alternatively select workdesk by name.
// Workdesk workdesk = variant.GetWorkdesks().FirstOrDefault(w => w.Name == "Workdesk_1");
workdesk.Open(false, false);
// Modify setting to select which objects to export.
DesignerExport exportSettings = workdesk.Settings.DataExchange.Export;
exportSettings.CableTies = true;
exportSettings.ExportBundles = true;
exportSettings.ExportCS = true;
exportSettings.ExportCables = true;
exportSettings.ExportConnectors = true;
exportSettings.ExportControlPoints = true;
exportSettings.ExportLabels = true;
exportSettings.ExportLeadingParts = true;
exportSettings.ExportParts = true;
exportSettings.ExportWires = true;
// Save document to apply settings.
workdesk.Save();
// Set file format options (available for .jt and .stp).
api.StudioSettings.DataExchange.Export.StepFormat = ApiStepExportFormat.AP203;
api.StudioSettings.Save();
// Export 3D file and close documents.
workdesk.Export3DFile(ApiExport3DFileType.StepFile, @"e:\", api-test);
workdesk.Close();
variant.Close();
project.Close();
// Close the API.
api.Close();