The current .NET API does not provide the related abilities. But you can take advantage of COM API by COM interop. The chapter 10 of \api\net\documentation\ NET Developers Guide.pdf to know more about COM interop. The following code snippet is based on the SDK sample \api\net\examples\PlugIns\APICallsCOMPlugin.
The object InwURL2 could be a ‘hyperlink’ or a ‘label’. Both of them link to a file or hyperlink.
hyperlink:
Label:
They are categorized to ‘label’ and ‘hyperlink’ separately. By API, we could know the corresponding category. In default, the InwURL2 is created as a label. So to set a URL as a hyperlink, we could use InwURL2.SetCategory.
ComApi.InwGlobalProperties oGlobalP = state.GlobalProperties();
ComApi.InwURLCategoriesColl oURLCategories = oGlobalP.URLsCategories();
foreach (ComApi.InwURLCategory oURLCas in oURLCategories)
{
System.Diagnostics.Debug.Write(oURLCas.InternalName + "-" + oURLCas.UserName);
}
private void AddURL()
{
ComApi.InwOpState10 state;
state = ComApiBridge.ComApiBridge.State;
// create the hyperlink collection
ComApi.InwURLOverride oMyURLOoverride =
(ComApi.InwURLOverride)state.ObjectFactory(
ComApi.nwEObjectType.eObjectType_nwURLOverride, null, null);
// some locations to add the hyperlink
double[] coordinate = { 10, 10, 0, 20, 20, 0, 30, 30, 0 };
for (int i = 0; i < 9; i += 3)
{
// create one hyperlink
ComApi.InwURL2 oMyURL =
(ComApi.InwURL2)state.ObjectFactory(
ComApi.nwEObjectType.eObjectType_nwURL, null, null);
// name of the hyperlink
oMyURL.name = "MyURL" + i;
// site of the hyperlink
oMyURL.URL = "http://www.google.com";
if (i == 0)
// create Hyperlink
oMyURL.SetCategory("Hyperlink", "LcOaURLCategoryHyperlink");
else
// create label
oMyURL.SetCategory("Label", "LcOaURLCategoryTag");
// Attachment Point of the hyperlink
ComApi.InwLPos3f oNewP =
(ComApi.InwLPos3f)state.ObjectFactory(
ComApi.nwEObjectType.eObjectType_nwLPos3f, null, null);
oNewP.data1 = coordinate[i];
oNewP.data2 = coordinate[i + 1];
oNewP.data3 = coordinate[i + 2];
// add the AttachmentPoint to
// AttachmentPoints collection
oMyURL.AttachmentPoints().Add(oNewP);
// add the new hyperlink to the hyperlink collection
ComApi.InwURLColl oURLColl = oMyURLOoverride.URLs();
oURLColl.Add(oMyURL);
// get current selected items
ModelItemCollection modelItemCollectionIn =
new ModelItemCollection(
Autodesk.Navisworks.Api.Application.ActiveDocument.
CurrentSelection.SelectedItems);
//convert to InwOpSelection of COM API
ComApi.InwOpSelection comSelectionOut =
ComApiBridge.ComApiBridge.ToInwOpSelection(modelItemCollectionIn);
// set the hyplerlink of the model items
state.SetOverrideURL(comSelectionOut, oMyURLOoverride);
// enable to the hyperlinks visible
state.URLsEnabled = true;
}
}