Community
Navisworks API
Welcome to Autodesk’s Navisworks API Forums. Share your knowledge, ask questions, and explore popular Navisworks API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Position of labels in Navisworks

6 REPLIES 6
Reply
Message 1 of 7
dupuisj
2004 Views, 6 Replies

Position of labels in Navisworks

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:

1.png

 

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:

2.png

 

The same type of element appears in 2 different ways in the selection tree. Is there a way to solve this problem?

 

Thanks!

 

 

Tags (2)
6 REPLIES 6
Message 2 of 7
xiaodong_liang
in reply to: dupuisj

Hi,

 

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?

 

Message 3 of 7
dupuisj
in reply to: xiaodong_liang

Hi,

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.

Label

 

Here is some images of what happen when I try to had a tag with the code:

 

  1. This is 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.

 label2.png

 

 

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?

label3.png

 

 

This is a part of my code that is giving me some problems:

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using Autodesk.Navisworks.Api.Plugins;

using Autodesk.Navisworks.Api;

using ComApi = Autodesk.Navisworks.Api.Interop.ComApi;

using ComApiBridge = Autodesk.Navisworks.Api.ComApi;

 

 

 

namespace NavisworksLabel

{

 

    [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)

        {

            AddURL();

            return 0;

        }

 

 

        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

                ComApi.InwOpState10 state;

                state = ComApiBridge.ComApiBridge.State;

                ComApi.InwURLOverride oMyURLOoverride = (ComApi.InwURLOverride)state.ObjectFactory(ComApi.nwEObjectType.eObjectType_nwURLOverride, null, null);

 

                //Préparation du label

                ComApi.InwURL2 label = (ComApi.InwURL2)state.ObjectFactory(ComApi.nwEObjectType.eObjectType_nwURL, null, null);

 

                //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.nwEObjectType.eObjectType_nwLPos3f, null, null);

 

                oNewP.data1 = 0;

                oNewP.data2 = 0;

                oNewP.data3 = 0;

 

                //Insertion du label dans Navisworks

                label.AttachmentPoints().Add(oNewP);

 

                ComApi.InwURLColl oURLColl = oMyURLOoverride.URLs();

                oURLColl.Add(label);

 

 

                ModelItemCollection modelItemCollectionIn = new ModelItemCollection();

                modelItemCollectionIn.Clear();

                modelItemCollectionIn.Add(oItem);

 

 

 

                //convert to InwOpSelection of COM API

                ComApi.InwOpSelection comSelectionOut = ComApiBridge.ComApiBridge.ToInwOpSelection(modelItemCollectionIn);

 

                state.SetOverrideURL(comSelectionOut, oMyURLOoverride);

                state.URLsEnabled = true;

            }

            return;

        }

 

    }

}

 

Thanks.

Message 4 of 7
dupuisj
in reply to: dupuisj

There is the model I use to test my code.

Message 5 of 7
xiaodong_liang
in reply to: dupuisj

Hi,

 

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. 

 

 

Message 6 of 7
dupuisj
in reply to: xiaodong_liang

Is there any developpement to solve this problem.  I really wish I can use this function.

 

Thanks.

Message 7 of 7
xiaodong_liang
in reply to: dupuisj

Sorry I cannot guarantee anything or provide further info. The only information I can tell is the issue has been logged. 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report