private async static Task <bool> Translate2Stl(string urn, string guid, JobObjOutputPayloadAdvanced.UnitEnum unit = JobObjOutputPayloadAdvanced.UnitEnum.Meter, JobPayloadDestination.RegionEnum targetRegion = JobPayloadDestination.RegionEnum.US) { try { Console.WriteLine("**** Requesting STL translation for: " + urn); JobPayloadInput jobInput = new JobPayloadInput(urn); JobPayloadOutput jobOutput = new JobPayloadOutput( new List <JobPayloadItem> ( new JobPayloadItem [] { new JobPayloadItem( JobPayloadItem.TypeEnum.Stl, null, new JobStlOutputPayloadAdvanced(JobStlOutputPayloadAdvanced.FormatEnum.Ascii, true, JobStlOutputPayloadAdvanced.ExportFileStructureEnum.Single) ) } ), new JobPayloadDestination(targetRegion) ); JobPayload job = new JobPayload(jobInput, jobOutput); bool bForce = true; ApiResponse <dynamic> response = await DerivativesAPI.TranslateAsyncWithHttpInfo(job, bForce); httpErrorHandler(response, "Failed to register file for STL translation"); return(true); } catch (Exception) { Console.WriteLine("**** Failed to register file for STL translation"); return(false); } }
private async static Task <bool> Translate2Obj(string urn, string guid, JobObjOutputPayloadAdvanced.UnitEnum unit = JobObjOutputPayloadAdvanced.UnitEnum.Meter, JobPayloadDestination.RegionEnum targetRegion = JobPayloadDestination.RegionEnum.US) { try { Console.WriteLine("**** Requesting OBJ translation for: " + urn); JobPayloadInput jobInput = new JobPayloadInput(urn); JobPayloadOutput jobOutput = new JobPayloadOutput( new List <JobPayloadItem> ( new JobPayloadItem [] { new JobPayloadItem( JobPayloadItem.TypeEnum.Obj, null, //new JobObjOutputPayloadAdvanced (null, guid, new List<int> () { -1 }, unit) // all new JobObjOutputPayloadAdvanced(null, guid, new List <int> () { 1526, 1527 }, unit) ) } ), new JobPayloadDestination(targetRegion) ); JobPayload job = new JobPayload(jobInput, jobOutput); bool bForce = true; ApiResponse <dynamic> response = await DerivativesAPI.TranslateAsyncWithHttpInfo(job, bForce); httpErrorHandler(response, "Failed to register file for OBJ translation"); return(true); } catch (Exception) { Console.WriteLine("**** Failed to register file for OBJ translation"); return(false); } }
private async static Task <bool> Translate2Svf2(string urn, JobPayloadDestination.RegionEnum targetRegion = JobPayloadDestination.RegionEnum.US) { try { Console.WriteLine("**** Requesting SVF2 translation for: " + urn); JobPayloadInput jobInput = new JobPayloadInput(urn); JobPayloadOutput jobOutput = new JobPayloadOutput( new List <JobPayloadItem> ( new JobPayloadItem [] { new JobPayloadItem( JobPayloadItem.TypeEnum.Svf2, new List <JobPayloadItem.ViewsEnum> ( new JobPayloadItem.ViewsEnum [] { JobPayloadItem.ViewsEnum._2d, JobPayloadItem.ViewsEnum._3d } ), null ) } ), new JobPayloadDestination(targetRegion) ); JobPayload job = new JobPayload(jobInput, jobOutput); bool bForce = true; ApiResponse <dynamic> response = await DerivativesAPI.TranslateAsyncWithHttpInfo(job, bForce); httpErrorHandler(response, "Failed to register file for SVF2 translation"); return(true); } catch (Exception) { Console.WriteLine("**** Failed to register file for SVF2 translation"); return(false); } }
/** * Example of how to send a translate to SVF job request. * Uses the oauth2TwoLegged and twoLeggedCredentials objects that you retrieved previously. * @param urn - the urn of the file to translate */ private static dynamic translateToSVF(string urn) { Console.WriteLine("***** Sending Derivative API translate request"); JobPayloadInput jobInput = new JobPayloadInput( System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(urn)) ); JobPayloadOutput jobOutput = new JobPayloadOutput( new List <JobPayloadItem> ( new JobPayloadItem [] { new JobPayloadItem( JobPayloadItem.TypeEnum.Svf, new List <JobPayloadItem.ViewsEnum> ( new JobPayloadItem.ViewsEnum [] { JobPayloadItem.ViewsEnum._3d } ), null ) } ) ); JobPayload job = new JobPayload(jobInput, jobOutput); dynamic response = derivativesApi.Translate(job, true); Console.WriteLine("***** Response for Translating File to SVF: " + response.ToString()); return(response); }
private async Task <bool> TranslateObject(ObservableCollection <ForgeObjectInfo> items, ForgeObjectInfo item) { try { string urn = URN((string)BucketsInRegion.SelectedItem, item, false); JobPayloadInput jobInput = new JobPayloadInput( urn, System.IO.Path.GetExtension(item.Name).ToLower() == ".zip", item.Name ); JobPayloadOutput jobOutput = new JobPayloadOutput( new List <JobPayloadItem> ( new JobPayloadItem [] { new JobPayloadItem( JobPayloadItem.TypeEnum.Svf, new List <JobPayloadItem.ViewsEnum> ( new JobPayloadItem.ViewsEnum [] { JobPayloadItem.ViewsEnum._2d, JobPayloadItem.ViewsEnum._3d } ), null ) } ) ); JobPayload job = new JobPayload(jobInput, jobOutput); bool bForce = true; DerivativesApi md = new DerivativesApi(); md.Configuration.AccessToken = accessToken; ApiResponse <dynamic> response = await md.TranslateAsyncWithHttpInfo(job, bForce); httpErrorHandler(response, "Failed to register file for translation"); item.TranslationRequested = StateEnum.Busy; item.Manifest = response.Data; JobProgress jobWnd = new JobProgress(item, accessToken); jobWnd._callback = new JobCompletedDelegate(this.TranslationCompleted); jobWnd.Owner = this; jobWnd.Show(); } catch (Exception /*ex*/) { item.TranslationRequested = StateEnum.Idle; return(false); } return(true); }
public async Task <dynamic> TranslateObject([FromBody] TranslateObjectModel objModel) { dynamic oauth = await OAuthController.GetInternalAsync(); // prepare the payload List <JobPayloadItem> outputs = new List <JobPayloadItem>() { new JobPayloadItem( JobPayloadItem.TypeEnum.Svf, new List <JobPayloadItem.ViewsEnum>() { JobPayloadItem.ViewsEnum._2d, JobPayloadItem.ViewsEnum._3d }) }; JobPayloadInput jobPayloadInput; if (objModel.ObjectType == "zipfile3D") { jobPayloadInput = new JobPayloadInput(objModel.ObjectName, true, "MyWallShelf.iam"); } else if (objModel.ObjectType == "zipfile2D") { jobPayloadInput = new JobPayloadInput(objModel.ObjectName, true, "WallShelfDrawings.idw"); } else { jobPayloadInput = new JobPayloadInput(objModel.ObjectName); } // start the translation JobPayload job = new JobPayload(jobPayloadInput, new JobPayloadOutput(outputs)); DerivativesApi derivative = new DerivativesApi(); derivative.Configuration.AccessToken = oauth.access_token; dynamic jobPosted = await derivative.TranslateAsync(job); return(jobPosted); }