The document https://aps.autodesk.com/en/docs/viewer/v7/developers_guide/overview/ said:
If the file is in a BIM 360 or ACC workspace, the SVF/SVF2 file is automatically generated.
but I don't know how to do.
I used the api
https://developer.api.autodesk.com/data/v1/projects/:project_id/items/:item_id
Obtained file details:
......
["storage"] => array(2) {
["data"] => array(2) {
["type"] => string(7) "objects"
["id"] => string(81) "urn:adsk.objects:os.object:wip.dm.emea.2/8310b164-80ba-4837-bc4c-434626dae124.pdf"
}
["meta"] => array(1) {
["link"] => array(1) {
["href"] => string(186) "https://developer.api.autodesk.com/oss/v2/buckets/wip.dm.emea.2/objects/8310b164-80ba-4837-bc4c-434626dae124.pdf?scopes=b360project.0ba0f51f-b130-427a-b8cb-4a013982f81c,O2tenant.22909090"
}
}
}
}
}
}
}
then use the following interface(
$urn is the return from the above: $result["included"][0]["relationships"]["storage"]["data"]['id']
)sent the request:
// Step 2 - Check the Status of the translation job
public static function checktranslationJob($AccessToken, $urn)
{
$urn = base64_encode($urn);
// halt($urn);
$url = "https://developer.api.autodesk.com/modelderivative/v2/designdata/$urn/manifest";
$signedurl = Session::get("signedurl");
$head = [
'Authorization: Bearer ' . $AccessToken,
];
$result = self::curlsent($url, '', $head, $method='get');
return $result;
}
Results can only be returned "null"
What will I do?
Additionally, I have done this job by Uploading Source File to OSS:
// STask 3, Option 2 – Translate to SVF2
public static function translateSvf2($AccessToken, $urn, $region)
{
// 以下是测试数据:
// $urn = 'urn:adsk.objects:os.object:mo34_cheng_emea3/2731-00-10-01A.dwg';
// $region = 'EMEA';
//
// 下面是通过您的 uploadToBucket($AccessToken, $bucket_key, $object_key, $path_to_upload) 返回的数据:
// array(3) {
// ["status"] => int(200)
// ["header"] => string(367) "HTTP/1.1 200 OK
// Access-Control-Allow-Headers: Authorization, Accept-Encoding, Range, Content-Type
// Access-Control-Allow-Methods: GET
// Access-Control-Allow-Origin: *
// Content-Type: application/json
// Date: Thu, 06 Jul 2023 02:55:18 GMT
// Strict-Transport-Security: max-age=31536000; includeSubDomains
// x-ads-region: EMEA
// Content-Length: 304
// Connection: keep-alive
// "
// ["body"] => string(304) "{"bucketKey":"mo34_cheng_emea3","objectId":"urn:adsk.objects:os.object:mo34_cheng_emea3/2731-00-10-01A.dwg","objectKey":"2731-00-10-01A.dwg","size":4773732,"contentType":"application/octet-stream","location":"https://developer.api.autodesk.com/oss/v2/buckets/mo34_cheng_emea3/objects/2731-00-10-01A.dwg"}"
// }
//下面是通过 https://developer.api.autodesk.com/oss/v2/buckets?region=EMEA 得到的bucket详细信息:
// array(5) {
// ["bucketKey"] => string(16) "mo34_cheng_emea3"
// ["bucketOwner"] => string(32) "ZAjD4dwoHF3h3PcAiXKsB8r8BGFYQZ9t"
// ["createdDate"] => int(1688427749021)
// ["permissions"] => array(1) {
// [0] => array(2) {
// ["authId"] => string(32) "ZAjD4dwoHF3h3PcAiXKsB8r8BGFYQZ9t"
// ["access"] => string(4) "full"
// }
// }
// ["policyKey"] => string(10) "persistent"
// }
$path_parts = pathinfo($urn);
$filename_without_extension = $path_parts['filename'];
$body = array(
"input" => array(
"urn" => base64_encode($urn),
"rootFilename" => $filename_without_extension . ".iam",
"compressedUrn" => true
),
"output" => array(
"destination" => array(
"region" => $region
),
"formats" =>array(
array(
"type" =>"svf2",
"views" =>array(
"2d",
"3d"
)
)
)
)
);
// us
// $url = "https://developer.api.autodesk.com/modelderivative/v2/designdata/job";
// EMEA
$url = "https://developer.api.autodesk.com/modelderivative/v2/regions/eu/designdata/job";
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($body),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Authorization: Bearer " . $AccessToken,
"x-ads-force: true"
],
]);
$response = curl_exec($curl);
curl_close($curl);
halt($response);//返回 bool(false)
return $response;
}