I’m trying to make a function that will put automatically a label on different elements in the Navisworks document, by using the API. The problem is that sometime, I’m not able to put the label directly on the element.
Generally, the API seems to give to the active element the coordinate (0,0,0) when it’s time to put the label on it, but for some elements, when I try to but the label at the coordinate (0,0,0), the label appears at the point (0,0,0) of the Revit project internal coordinate and not on the element?
For others elements, when I try to put the label at the coordinate (0,0,0), the label is in the right place in X and Y, but the label is to high or to low on the Z axis?
I don't know if it is for something but I noticed that for the element where the label appears at the point (0,0,0) of the Revit project internal coordinate, the element appears like that in the selection tree:
And for the same element where the label appears at the right place in X and Y but not in Z, the element appears like that in the selection tree:
The same type of element appears in 2 different ways in the selection tree. Is there a way to solve this problem?
I am afraid this information may not be enough for the peers to share a comment. Is it possible to provide a reproducible model and test code? In addition, the 'label' meants 'tag'. Is my understanding correct?
I hope this will clarify my problem. Here is an image of label (tag) on an object in Navisworks. This tag can be had manually, but I want to automate the task by using a property from the object.
Here is some images of what happen when I try to had a tag with the code:
2. And sometime, when I try to put the label at the coordinate (0,0,0), the label is in the right place in X and Y, but the label is to high on the Z axis?
This is a part of my code that is giving me some problems:
using ComApi = Autodesk.Navisworks.Api.Interop.ComApi;
using ComApiBridge = Autodesk.Navisworks.Api.ComApi;
[PluginAttribute("Navisworks Label", "Navisworks Label", ToolTip = "Label - Nom", DisplayName = "Ajouter 'Name Tag' des éléments sélectionnés")]
public class MyAddIn : AddInPlugin
public override int Execute(params string parameters)
private void AddURL()
//Accès au document Navisworks et Api .Com
Document oDoc = Autodesk.Navisworks.Api.Application.ActiveDocument
//Boucle servant à accéder chacun des éléments sélectionnés dans le document
foreach (ModelItem oItem in oDoc.CurrentSelection.SelectedItems)
//Accès Api .Com
state = ComApiBridge.ComApiBridge.State;
ComApi.InwURLOverride oMyURLOoverride = (ComApi.InwURLOverride)state.ObjectFactory(ComApi.
//Préparation du label
ComApi.InwURL2 label = (ComApi.InwURL2)state.ObjectFactory(ComApi.nwEObje
//Ajouter le nom au label
label.name = "Name of the object";
//Création du point servant à la localisation du label
ComApi.InwLPos3f oNewP = (ComApi.InwLPos3f)state.ObjectFactory(ComApi.nwEOb
oNewP.data1 = 0;
oNewP.data2 = 0;
oNewP.data3 = 0;
//Insertion du label dans Navisworks
ComApi.InwURLColl oURLColl = oMyURLOoverride.URLs();
ModelItemCollection modelItemCollectionIn = new ModelItemCollection();
//convert to InwOpSelection of COM API
ComApi.InwOpSelection comSelectionOut = ComApiBridge.ComApiBridge.ToInwOpSelection(modelIt
state.URLsEnabled = true;
Thanks for the detailed info. I can reproduce this issue. The second scenario is problematic to me. It should also locate on (0,0,0).
At my side, it looks all smaller pillar (in white color) has the problem. no matter where the point locates, the tag (URL) always locates above the element. While other elements (such as the bigger pillar in grey color) are correct.
Sorry, I cannot find what caused the issue. I have to log it with our engineer team.
Sorry I cannot guarantee anything or provide further info. The only information I can tell is the issue has been logged.