使用PHP代码的SVF文件和SFV文件URN - Forge

时间:2017-02-14 09:53:07

标签: autodesk-data-management

我们正在尝试将Revit(.rvt)文件转换为SVF,以便我们可以在查看器中查看此文件,因为我们使用的是伪造API和PHP。但是当我们执行cURL命令来获取SVF时,得到NULL结果。

我们正在使用以下步骤 -

  1. 验证

    创建了一个应用

    使用3-legged Token

  2. 数据管理API

    我们正在使用“下载文件”教程来获取A360驱动器文件的URN。链接 - https://developer.autodesk.com/en/docs/data/v2/tutorials/download-file/ 在第五步,我们得到文件URN与版本 - $ revitFileURN ='urn:adsk.wipprod:fs.file:vf.2tIxruH7Qpuhai7__Z982g?version = 1'; 现在我们使用这个URN为Viewer准备这个文件,为此我们需要SVF文件。链接 - https://developer.autodesk.com/en/docs/model-derivative/v2/tutorials/prepare-file-for-viewer/

  3. 为查看器准备文件

    将源URN转换为Base64编码的URN:

    $revitFileURNEncoded = base64_encode (  $revitFileURN );
    

    创建数据数组

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

    标头数组创建

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

    cURL执行 -

    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);
    

    我们在$ curlTranslateFileToSVFResponse

    中得到NULL

    请指导 -

    1. 如何获取SVF文件
    2. 如何在浏览器中查看此SVF文件

1 个答案:

答案 0 :(得分:0)

Augusto explained类似,A360或BIM360会自动快速翻译,因此如果查看项目响应,您会发现SVF清单已经存在。但是,在支持时,您仍然可以开始转换为SVF或其他格式,如果您使用A360 / BIM360中的正确URN,则每个项目有多个URN,但含义不同。这是我用于测试的代码:

$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

希望能够解释它,