Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 3189

Re: How to distinguish unique node IDs among browsers?

$
0
0

Hello Shinya,

 

 

About your question "how to apply unique metadata to each node": The Generic Conversion API lets you set "component" metadata. However, a node in your VDS file may be an "instance" of a component, so using that feature of the API would result in multiple nodes having the same metadata.

 

 

First, I'd like to understand your use case a little more, so I can give a better recommendation.

 

Which one of the two scenarios below can satisfy your requirement?

 

 

1. The unique ID is saved in the VDS file and every time you create a new VDS file from the same input file using Generic Conversion, that node has the same unique ID.

 

 

 

2. The unique ID is saved in the VDS file, and every time you open the VDS file, it will be the same. But if you create a new VDS file from the same input file using Generic Conversion, that node will have a different unique ID.

 

 

 

Scenario #1 can be difficult to achieve reliably. It requires that the input file and input file format support this capability, as VE Generator does not have sufficient information to create a unique ID with these properties: a stable unique ID that remains the same across multiple conversions.

 

 

Scenario #2 can be achieved today, but will require more advanced customization of your VE Generator workflow than you may have done so far.

 

 

I will describe the steps to follow to achieve scenario #2:

 

 

You need to customize the VE Generator "process" that creates the VDS file, and add a custom Python operation that modifies the nodes to add a unique ID just before the VDS file is saved to disk. The custom operation will be using some of the APIs described here: http://wiki.scn.sap.com/wiki/display/SVE/VDI+SDK+Reference

 

 

For your reference, I have created a custom VE Generator process and Python script, attached as a ZIP file to this post (BuildViewables_VDS_UniqueIds_Example.zip).

 

Edit: It seems I cannot attach ZIP files directly to the forum. As a workaround, open the attached ZIP file, extract the .asc file inside, then run the following command from a command-prompt:

 

certutil -decode BuildViewables_VDS_UniqueIds_Example.asc BuildViewables_VDS_UniqueIds_Example.zip

 

DecodeZIP.png

 

You can import this custom process into your VE Generator by opening VEG Administration, browsing to the Processes node of Server Configuration, right-clicking Processes, then selecting Import Processes, and selecting the ZIP file BuildViewables_VDS_UniqueIds_Example.zip that you created using the certutil command:

 

ImportProcesses.png

 

 

This will create a new process in VEG (Refresh the Processes list), named Build Viewables - Build VDS Viewable (Unique IDs). Right-click this process, and Load it.

 

 

LoadProcess.png

 

 

Now go to Workflows, select Build Viewables, and click Edit. In the Processes tab, select Build Viewables - Build VDS Viewable (Unique IDs) for the Build Viewable - VDS drop-down:

 

ChangeBVProcess.png

 

 

After making this change, all VDS files that your VE Generator builds will have a unique ID for the node in the CUSTOM metadata category named UID.

 

If you edit the process Build Viewables - Build VDS Viewable (Unique IDs), you will see the custom operation I created, named z_assign_unique_node_ids, this is the Python code I put into that operation:

 

 

# generates and sets a unique ID on a node
def set_unique_id(node):    uid = System.Guid.NewGuid().ToString('N')    node.ChangeMetadata('CUSTOM', 'UID', uid, False)
# sets unique ID on node and all children (recursively)
def traverse_and_set_unique_id(node):    set_unique_id(node)    for child_node in node.Children:        traverse_and_set_unique_id(child_node)
scene = sap.graphics.factory.ActiveSceneManager
with scene.BeginChanges():    for node in scene.RootNodes:        traverse_and_set_unique_id(node)

 

 

 

This should give you an idea of what is possible using Python APIs if the default behavior is not flexible enough for you.

 

 

The reference for the Python APIs is here: http://wiki.scn.sap.com/wiki/display/SVE/VDI+SDK+Reference

And some getting started documentation is here: http://wiki.scn.sap.com/wiki/display/SVE/Python+Cookbook

 

 

Hope this helps, let us know if you have any questions.

Leon


Viewing all articles
Browse latest Browse all 3189

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>