Navisworks API

Reply
Active Member
dupuisj
Posts: 6
Registered: ‎08-21-2012
Message 1 of 7 (529 Views)

Position of labels in Navisworks

529 Views, 6 Replies
08-21-2012 01:05 PM

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!

 

 

ADN Support Specialist
xiaodong.liang
Posts: 1,233
Registered: ‎06-12-2011
Message 2 of 7 (508 Views)

Re: Position of labels in Navisworks

08-30-2012 02:43 AM 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?

 



Xiaodong Liang
Developer Technical Services
Autodesk Developer Network

Active Member
dupuisj
Posts: 6
Registered: ‎08-21-2012
Message 3 of 7 (493 Views)

Re: Position of labels in Navisworks

09-05-2012 12:13 PM 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.

Active Member
dupuisj
Posts: 6
Registered: ‎08-21-2012
Message 4 of 7 (492 Views)

Re: Position of labels in Navisworks

09-05-2012 12:34 PM in reply to: dupuisj

There is the model I use to test my code.

ADN Support Specialist
xiaodong.liang
Posts: 1,233
Registered: ‎06-12-2011
Message 5 of 7 (481 Views)

Re: Position of labels in Navisworks

09-06-2012 03:07 AM 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. 

 

 



Xiaodong Liang
Developer Technical Services
Autodesk Developer Network

Active Member
dupuisj
Posts: 6
Registered: ‎08-21-2012
Message 6 of 7 (459 Views)

Re: Position of labels in Navisworks

09-13-2012 10:42 AM in reply to: xiaodong.liang

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

 

Thanks.

ADN Support Specialist
xiaodong.liang
Posts: 1,233
Registered: ‎06-12-2011
Message 7 of 7 (447 Views)

Re: Position of labels in Navisworks

09-18-2012 03:01 AM 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. 



Xiaodong Liang
Developer Technical Services
Autodesk Developer Network

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community