suggestion for show objects api method

suggestion for show objects api method

ulski1
Collaborator Collaborator
3,899 Views
25 Replies
Message 1 of 26

suggestion for show objects api method

ulski1
Collaborator
Collaborator

 

hi,

this is mainly a cry out to the Navisworks dev team.

it would be really useful if the Navisworks dev team could add a method to the API which takes a collection of model items and make them visible without affeting already hidden objects not in the collection(parent or grand parent objects are sometimes hidden causing all grandkids to be invisible and we do not want sibling objects to become visible if the grand parent is made visible so a lot of testing is needed and I can not find a way to ask an object "are you truly visible" ). My unqualified guess if that it should not be "crazy expensive" to add a "show method" because some super fast code is already available as "Show" on the context (right click menu) on selection sets and search sets in the "manage sets" dialog. I'm aware of the c# sample code which mimics the "show" code by looping and testing what objects are hidden but I think for the size of models we have it will be impossible to get the same outstanding performance the "native" show code have.

 

br

Ulrik

 

 

2016-09-13_14-25-19.png

 

0 Likes
Accepted solutions (2)
3,900 Views
25 Replies
Replies (25)
Message 21 of 26

xiaodong_liang
Autodesk Support
Autodesk Support
Accepted solution
Hi Ulski,

Finally I got the comments from our engineer team:

This functionality (SetHidden) is built into Navisworks, but it isn't exposed like what UI does. But it does look like it is exposed in the Interop API:

Interop.LcOpSelectionSetsElement.MakeVisible(NW.Application.MainDocument.State, MySelectionSet);

I gave a test at my side and found it can work well, the same to UI.

Could you check if it could help you?

Message 22 of 26

ulski1
Collaborator
Collaborator

Is this some undocumented way of interacting with Navisworks? I don't recall reading about this in the documentation. If this method will replicate the show command it is really good news

0 Likes
Message 23 of 26

ulski1
Collaborator
Collaborator
Accepted solution

Hurra, it seems to work.

 

I added this in "CodeRun"

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using NW = Autodesk.Navisworks.Api;

using Autodesk.Navisworks.Api;

namespace CScript
{
public class CScript
{
static public void Main()
{
/*Code goes here!!*/
Document oDoc = Autodesk.Navisworks.Api.Application.ActiveDocument;
Autodesk.Navisworks.Api.DocumentParts.DocumentSelectionSets oCurSets = oDoc.SelectionSets;
SelectionSet oMySet1 = new SelectionSet(oDoc.CurrentSelection.SelectedItems);
Autodesk.Navisworks.Api.Interop.LcOpSelectionSetsElement.MakeVisible(NW.Application.MainDocument.State, oMySet1);
}
}
}

show_selected.png

Message 24 of 26

xiaodong_liang
Autodesk Support
Autodesk Support
it is a hidden API that is not officially exposed. So you have to use it at your own risk. The best is the official API (SetHidden) can behavior like UI. I will log it.
0 Likes
Message 25 of 26

ulski1
Collaborator
Collaborator

makevisible is not the same as sethidden. set hidden is just a toggle - makevisible will do the looping to investigate which objects to hide and not hide

0 Likes
Message 26 of 26

alexisDVJML
Collaborator
Collaborator

Excellent thread, I was not even aware of this user feature.
I can imagine using it, even without referring to a SelectionSet of the document SelectionSets.
Just creating a temporary SelectionSet with the objects we want to show should work.

 

This opens a range of opportunities...

Really worth spending some times looking at old threads 😉

 

Main Scientist, Full Stack Developer & When Time Permits Director of IDIGO ► On your marks, Set, Go
0 Likes