Finding externalId with a Forge API without loading viewer - autodesk-forge

I have been playing around with the C# DerivativesApi and I'm able to get model view meta data and properties. But I cannot find the externalId value. Is it possible to get this value without lodiang a viewer?
If the original model is from Revit this value contains the GUID of the element and it would be very useful for me to have easy access to this value.

As of now (April 2017) this information is only available on Viewer. We're currently investigating to have this exposed. A workaround is to download the Viewer JSON and extract the information.

To add a little more precisions to what Augusto mentioned, you can use take a look at what extract server is doing in downloadBubble and perform the same without viewer interaction. Once you downloaded the resources, you will find a *.db or *.sdb file which is an SQL lite database from where you can read mappings from dbIds to externalIds.
Unfortunately we don't have a sample that illustrates that workflow.
Hope that helps

Related

How to save data with JSON in a Xamarin app?

Good day dear developers, I really need your help. I want to make an app in Xamarin. In which I added some text data, and it is saved in this application. I need this information to be in the application, and I could get it without the Internet. I understand that you need to use JSON. I really want you to at least give a little hint on how I can store information using JSON in my Xamarin application. Thanks a lot!)
I tried to find information on Google, but there is a lot of superfluous and inappropriate
Depending on your data an easy way could be to use Preferences from Xamarin.Essentials which allows you to store key/value pairs: link to description
Another option would be to save files with JSON as you mentioned already. You create a class which holds your data and then serialize/deserialze the objects to files and from files. For this you can use the Newtonsoft.Json which is a nuget package that you can install.
If you have a MyData class and an data object it would look like this:
Serialize:
File.WriteAllText("fileName", JsonConvert.SerializeObject(data));
Deserialze:
var myData = JsonConvert.DeserializeObject<MyData>(File.ReadAllText("fileName"));
Different platforms has their own file system. For example, iOS limits our access to the file system, which is called Application sandbox. To save or load files, you could learn some basic info first:
for iOS, refer to File system access in Xamarin.iOS.
for Android, refer to File Storage and Access with Xamarin.Android
Xamarin forms provides several ways to use Xamarin forms local data storage. First is use File Handling just as Mario K mentioned. For Serializing JSON, you could refer to Serializing JSON.
Another is that you could use SQLite database engine which allows Xamarin.Forms applications to load and save data objects in shared code. More info, you could refer to Xamarin.Forms Local Databases.
I think you could first check these documentation and decide which method you prefer to use. If you still have questions, feel free to ask.
Hope it works for you.

Model Derivative API object ids don't match PropertyDatabase object ids

I have developed an application that gets the JSON object tree of a BIM 360 revit model's view, using the Forge Model Derivative endpoint, then downloads the SQLite PropertyDatabase to query properties of several object tree entities. That was working fine until now. Recently, I am having trouble with some models where the object tree derivative object ids don't match the PropertyDatabase object ids.
I have seen this post Temporary workaround for mapping between SVF1 and SVF2 IDs but this method is not valid in my case because my app works on the server side and not uses viewer API at all.
My question is: if there is a workaround using APIs from the server side, and if there are plans to solve this inconsistency between APIs shortly.
Unfortunately, this behaviour is expected with your approach. SVF and SVF2 do not share the same IDs, SVF2 IDs are optimised to process data faster and to try keeping them identical across versions. The article you make reference to is only working in the context of the Viewer, for server side processing you need to get the dbid.idx file to map IDs. This utility has a command to help you downloading the file. Try:
./forge.js version-svf2-idmap project_id version_id output_dbid.idx
This file is a gzip compressed file of a uint32 array.
What happened is that you did download the SVF SQLlite db using SVF ids. But when using the MD endpoints, you actually using the SVF2 ids because the target format is SVF2. If you did request a SVF target format, the MD endpoint would work with SVF ids. Unfortunately, you do not control BIM360 target format which could either be SVF or SVF2 depending of the source file format. For example, IFC, RVT, NWD, DWG are SVF2, but others are not. You can determine which format is used by reading the outputType and overrideOutputType. If overrideOutputType says 'svf2', then you should do the mapping.
The relevant code for the version-svf2-idmap is here
On the other hand, if you got the SQLite database, why do you need to call the MD endpoints, you got everything you need, and can extract the information much faster from there. See my example here. It has functions for properties extraction, and/or building the hierarchy tree.

How to export XML from Naviswork to Forge Viewer

I following this tutorial
for import and work with viewpoint from Naviswork to Forge Viewer.
Do you know any solution or API on Naviswork to export this viewpoint data and saved it on my Database. Thank you in advance !
It sounds like a Navisworks API question, instead of Forge. Navisworks API does not provide a direct method to export to saved viewpoints like UI does. I happened to answer a similar question in the past. just copied here for your reference:
There is not a direct API, but with SavedViewpoint API, you could dump the data from the objects, and write to the XML yourself.
http://adndevblog.typepad.com/aec/2012/06/navisworks-net-api-2013-new-feature-saved-viewpoint.html
It might be possible not all properties in the standard xml have corresponding object with API, such as terminal_velocity, however it would not impact your workflow, as most properties (especially camera related) are available with API.
About data of redline, activate each saved viewpoint one by one (by DocumentSavedViewpoints.CurrentSavedViewpoint) , call Document.ActiveView.GetRedLines(). It can return all info of the annotations: line, eclipse, text etc in Json format.
About data of clip planes, you could use Document.ActiveView.GetClippingPlanes(). Similarly, in Json format.
Hope it helps.

Does Autodesk Viewer meet those requirements?

I've been asked to insert an .IFC viewer into a web page already built, to:
explode building visualization into floors
rotate the building
colour spaces based on their temperature
add labels to objects
load .ifc files stored on private servers
Does autodesk viewer meet those requirements? All of them?
Additionaly, is it feasible to change the viewer language through a config file or specific functions?
explode building visualization into floors
The built-in explosion is by model components and not floors and there's option right out of box to specify a granularity level.
Nonetheless you can use viewer.cutplanes (see doc here) to isolate the levels and go from there - see sample here.
rotate the building
This can be done by either THREE.js transformation or Viewer's model load options:
THREE.js: Perform transformation recursively by traversing all children components under the model's root dbid. See this great article here for enlightenment.
Load option - see live sample here:
var options = {
placementTransform:THREE.matrix4,
globalOffset:{x:0,y:0,z:0}
};
viewer.start(svfURL, options)
colour spaces based on their temperature
Use viewer.setThemingColor (see doc here) to apply temperature colors - find the parent dbid of the room or and use the recursive flag to apply color to all its children components. See code sample here.
add labels to objects
See here for details and a few helpful links at the start of the article.
load .ifc files stored on private servers
You can download the translated derivatives (SVF and its resources - obtain a manifest of them from GET :urn/manifest) to your own storage locations and load them by their URL directly. See my live code sample above for details and find the source code for our online extractor tool (http://extract.autodesk.io) here for ideas to download the derivatives.
is it feasible to change the viewer language through a config file or specific functions?
Viewer implements the i18n standards so you can do:
Autodesk.Viewing.i18n.setLng('fr');
Autodesk.Viewing.i18n.localize()

Autodesk Forge - Post Jobs - Must files be in buckets and proper URN

I am working on doing a post job and I am confused about where files need to be to run the job and the proper urn.
The examples all use a file that the user uploads to a bucket. I am trying to run the post job on a file that a user has created in Fusion 360 and that he has selected through a GUI I created. The urn in question is obtained by letting the user select the hub, project, folder(s), and file. I then use this file urn on the post job.
I keep getting back the response of :
Failed to download the design description for the input design.
My questions are:
Is it possible to do this from a users hub or do all items have to be in buckets?
Where are those translated files stored once created? If I want to get data like volume and mass without storing the translated file, is that possible?
I took the "urn:" off the front of the urn and got a different error, which I believe meant that it couldn't find any file.
Invalid 'design' parameter.
So, it looks like the urn I am using is finding a file but there is an issue somewhere that is preventing that file from being accessed or translated or something.
I keep getting back the response of : Failed to download the design description for the input design.
For Fusion 360 files make sure the extension name of the object is f2d/f3d. BTW Forge Viewer support these two formats directly so you don't have to translate to SVF for Viewer to visualize them.
Is it possible to do this from a users hub or do all items have to be in buckets?
For hub project items use the Data Management API to obtain the object ID - be sure to include the version parameter in your URN - see GET projects/:project_id/folders/:folder_id/contents and use the id of the item as your URN as well as tutorial here to help you understand how project folder items work.
Where are those translated files stored once created? If I want to get data like volume and mass without storing the translated file, is that possible?
The translated derivatives would be stored separately and you can access them through the derivative manifest. Use GET :urn/metadata/:guid/properties to query derivative properties but you will need to translate the model (to any format will do) in order to extract properties - see tutorial here.