0

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

我们正在使用以下步骤 -

  1. 验证

    创建了一个应用

    使用三足代币

  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 文件
4

1 回答 1

0

就像Augusto 解释的那样,A360 或 BIM360 将自动快速关闭翻译,因此如果您查看项目响应,您会注意到 SVF 清单已经存在。但是,如果您使用正确的 URN(如在 A360/BIM360 中),您仍然可以开始翻译为 SVF 或其他格式,每个项目都有多个 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

希望解释一下,

于 2017-02-14T13:20:25.587 回答