Attaching hyperlinks to objects from data from a excel file

Attaching hyperlinks to objects from data from a excel file

Anonymous
Not applicable
539 Views
1 Reply
Message 1 of 2

Attaching hyperlinks to objects from data from a excel file

Anonymous
Not applicable

I have an excel file, one column contains a list of hyperlinks. Can I link these hyperlinks directly to the Navisworks model objects, without linking one by one manually. Assume one excel column has a respective property of the model that I can use that matches the hyperlinks.
Please can someone provide me the code, I am new here. 

0 Likes
540 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

Autodesk.Navisworks.Api.Interop.ComApi.InwOpState10 state = Autodesk.Navisworks.Api.ComApi.ComApiBridge.State;
ModelItem modelItem = Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.SelectedItems.First;
ModelItemCollection modelItemCollection = new ModelItemCollection();
modelItemCollection.Add(modelItem);
Autodesk.Navisworks.Api.Interop.ComApi.InwOpSelection opSelection = Autodesk.Navisworks.Api.ComApi.ComApiBridge.ToInwOpSelection(modelItemCollection);
if (modelItem.PropertyCategories.FindCategoryByName("LcOaExURLAttribute")==null)
{
Autodesk.Navisworks.Api.Interop.ComApi.InwURLOverride oMyURLOoverride =
(Autodesk.Navisworks.Api.Interop.ComApi.InwURLOverride)state.ObjectFactory
(Autodesk.Navisworks.Api.Interop.ComApi.nwEObjectType.eObjectType_nwURLOverride, null, null);
Autodesk.Navisworks.Api.Interop.ComApi.InwURL2 newURL = (Autodesk.Navisworks.Api.Interop.ComApi.InwURL2)state.ObjectFactory(Autodesk.Navisworks.Api.Interop.ComApi.nwEObjectType.eObjectType_nwURL, null, null);
newURL.name = "NewLink";
newURL.URL = "NewLinkURL";
newURL.SetCategory("Hyperlink", "LcOaURLCategoryHyperlink");
oMyURLOoverride.URLs().Add(newURL);
state.SetOverrideURL(opSelection, oMyURLOoverride);
}

 

This is the code that changes the hyperlink of the first model of the selected model.

 

If you can find the model with each respective property of the model

You can change the hyperlink using the above code.

 

0 Likes