0

We are trying to convert Revit(.rvt) file to SVF so that we can view this file in viewer, for this we are using forge API and PHP. But when we execute cURL command to get SVF, getting NULL result.

We are using following steps -

  1. Authentication

    Created a app

    Using 3-Legged Token

  2. Data Management API

    We are using 'Download a File' tutorial to get URN of a file form A360 drive. Link - https://developer.autodesk.com/en/docs/data/v2/tutorials/download-file/ At fifth step we are getting file URN with version - $revitFileURN = 'urn:adsk.wipprod:fs.file:vf.2tIxruH7Qpuhai7__Z982g?version=1'; Now we are using this URN to prepare this file to Viewer, for this we need SVF file. Link - https://developer.autodesk.com/en/docs/model-derivative/v2/tutorials/prepare-file-for-viewer/

  3. Prepare a File for the Viewer

    Converted the source URN into a Base64-Encoded URN :

    $revitFileURNEncoded = base64_encode (  $revitFileURN );
    

    Creation Data array

    $dataValue = array("input" => array ("urn" =>$revitFileURNEncoded ), "output"=>array("formats"=>array(array("type"=>"svf","views"=>array("2d","3D")))));
    $data_string = http_build_query($dataValue);
    

    Header array creation

    $strHeader=array();
    $strHeader[]='Authorization: Bearer '.$AccessToken;
    $strHeader[]='Content-Type: application/json';
    

    cURL execution -

    curl_setopt_array($curlTranslateFileToSVF, array(
          CURLOPT_URL => $url,
          CURLOPT_POSTFIELDS =>$data_string,
          CURLOPT_POST => 1,
          CURLOPT_HTTPHEADER=>$strHeader,
          CURLOPT_RETURNTRANSFER=>true
    ));
    $curlTranslateFileToSVFResponse  = curl_exec($curlTranslateFileToSVF );
    curl_close($curlTranslateFileToSVF);
    

    We are getting NULL in $curlTranslateFileToSVFResponse

    Please guide -

    1. How to get SVF file
    2. How to view this SVF file in browser
kritikaTalwar
  • 1,730
  • 1
  • 17
  • 25
  • on a 3-legged context, you'll not need to convert o SVF yourself, all files on A360 are automatically converted. If you need another output, then you'll need model derivative. – Augusto Goncalves Feb 14 '17 at 10:08

1 Answers1

0

Like Augusto explained, A360 or BIM360 will quick off translation automatically, so if you look at the item response, you'll notice the SVF manifest is already present. However, you can still start translation to SVF or other formats when supported, if you use the correct URN as in A360/BIM360 there is multiple URN for each item but with different meaning. Here is my code I used for testing:

$access_token =ThreeLeggedController::access_token () ;
\Swagger\Client\Configuration::getDefaultConfiguration ()->setAccessToken ($access_token) ;

$api_instance =new \Swagger\Client\Api\HubsApi () ;
$data =$api_instance->getHubs () ;
//print_r ($data) ;
// Cyrille Fauvel Hub = a.cGVyc29uYWw6dWUyOWNkYzc4

$hub_id ="a.cGVyc29uYWw6dWUyOWNkYzc4" ;
$data =$api_instance->getHubProjects ($hub_id) ;
//print_r ($data) ;
// Forge project = a.cGVyc29uYWw6dWUyOWM4OWI3IzIwMTYwNjEzMzQ4ODgxMzE

$project_id ='a.cGVyc29uYWw6dWUyOWM4OWI3IzIwMTYwNjEzMzQ4ODgxMzE' ;
$api_projects =new \Swagger\Client\Api\ProjectsApi () ;
$data =$api_projects->getProject ($hub_id, $project_id) ;
//print_r ($data) ;
// Root folder = urn:adsk.wipprod:fs.folder:co.XRaMujM2Q-qQARnuF05FuA

$folder_id ='urn:adsk.wipprod:fs.folder:co.XRaMujM2Q-qQARnuF05FuA' ;
$api_folders =new \Swagger\Client\Api\FoldersApi () ;
$data =$api_folders->getFolderContents ($project_id, $folder_id) ;
//print_r ($data->data) ;
// V8 Engine.dwfx = urn:adsk.wipprod:dm.lineage:IzRTVrfDRq6-y8pDzpRZ1g
//               urn:adsk.wipprod:fs.file:vf.IzRTVrfDRq6-y8pDzpRZ1g?version=1

$item_id ='urn:adsk.wipprod:dm.lineage:IzRTVrfDRq6-y8pDzpRZ1g' ;
$file_id ='urn:adsk.wipprod:fs.file:vf.IzRTVrfDRq6-y8pDzpRZ1g?version=1' ;
$api_items =new \Swagger\Client\Api\ItemsApi () ;
$data =$api_items->getItem ($project_id, $item_id) ;
//print_r ($data) ;
//print_r ($data->included [0]->relationships->storage->data->id) ;
// id = urn:adsk.objects:os.object:wip.dm.prod/72f7d0a2-0727-4346-ba0f-33b69d0c2a99.dwfx
//print_r ($data->included [0]->relationships->derivatives->data->id) ;
// urn = dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLkl6UlRWcmZEUnE2LXk4cER6cFJaMWc_dmVyc2lvbj0x

$urn ='dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLkl6UlRWcmZEUnE2LXk4cER6cFJaMWc_dmVyc2lvbj0x' ;
$id ='urn:adsk.objects:os.object:wip.dm.prod/72f7d0a2-0727-4346-ba0f-33b69d0c2a99.dwfx' ;
$api_md =new \Swagger\Client\Api\DerivativesApi () ;
$data =$api_md->getManifest ($urn) ;
//print_r ($data) ;

// This is what the viewer is using, so as long you get a descent
// response here, you're good


// Let's try to quick a new translation
$urn2 =base64url_encode ($id) ;
$formats =array ( (object)[ 'type' => 'svf', 'views' => [ "2d", "3d" ] ] ) ;
$job =(object)[ 'input' => (object)[ 'urn' => $urn2 ], 'output' => (object)[ 'formats' => $formats ] ] ;
$data =$api_md->translate ($job, true) ;
print_r ($data) ;

// Done! -> [result] => created

Hope that explains it,

Community
  • 1
  • 1
cyrille
  • 2,616
  • 1
  • 10
  • 18