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: 

Unhide All

4 REPLIES 4
Reply
Message 1 of 5
jorge.garza
1465 Views, 4 Replies

Unhide All

I am new to using this API for Navisworks and fairly new to writing code. I have taken the sample code for building a NWD file but need assistance on a particular function. I need to determine what code is required in order to "Unhide All" before the automationApplication.SaveFile takes place. I can't seem to find the answer while browsing thought the Object Browser. Thanks

4 REPLIES 4
Message 2 of 5

Hi,

the automation of .NET api can only handle some operations with document (save, merge, publish etc). The advanced abilities require the plugin. So you need to write a plugin which unhide all, and the automation execute the plugi by ApplicationAutomation.ExecuteAddInPlugin.
Message 3 of 5
deanlyon
in reply to: jorge.garza

There are several ways to do what you are asking.  Here is one way with VBScript on Simulate 2012.  You could probably do something similar in the language you are using.

 

Sub UnhideAllLayers (roamer,filePath)

'Unhide all
ofind = roamer.state.getenum("eObjectType_nwOpFind")
set find = roamer.state.objectFactory(ofind)

ofind_spec = roamer.state.getenum("eObjectType_nwOpFindSpec")
set find_spec = roamer.state.objectFactory(ofind_spec)

ofind_condition = roamer.state.getenum("eObjectType_nwOpFindCondition")
set find_condition = roamer.state.objectFactory(ofind_condition)

find_condition.SetAttributeNames "LcOaNode"
find_condition.SetPropertyNames "LcOaNodeHidden"
find_condition.Condition = 6
find_condition.Value = True

ofindException = roamer.state.getenum("eObjectType_nwOpFind")
set findException = roamer.state.objectFactory(ofindException)

ofindException_spec = roamer.state.getenum("eObjectType_nwOpFindSpec")
set findException_spec = roamer.state.objectFactory(ofindException_spec)

ofindException_condition = roamer.state.getenum("eObjectType_nwOpFindCondition")
set findException_condition = roamer.state.objectFactory(ofindException_condition)

findException_condition.SetAttributeNames ""
findException_condition.SetPropertyNames roamer.state.StdName(0, False)
findException_condition.Condition = 7
findException_condition.ValueCaseSensitive = false
findException_condition.Value = "S-LABELS-SECTIONNAME"

find_spec.Selection = Nothing
find_spec.Conditions.Add find_condition
find_spec.Conditions.Add findException_condition

find.FindSpec = find_spec
roamer.state.SelectionHidden(find.FindAll) = False

End Sub

Message 4 of 5
jabowabo
in reply to: jorge.garza

Here is an example using C#:

private void UnhideAll()
{
	Document doc = Autodesk.Navisworks.Api.Application.ActiveDocument;
	DocumentModels models = doc.Models;
	doc.CurrentSelection.Clear();

	foreach (Model model in models)
	{
		ModelItem rootItem = model.RootItem;
		ModelItemEnumerableCollection modelItems = rootItem.DescendantsAndSelf;
		doc.Models.SetHidden(modelItems, false);
	}
}

 

Message 5 of 5

Hi Jorge,

 

I just want clarify what the other peers contributed, in case you may be confused with what I replied.

 

as mentioned, .NET Automation has the basic abilities of document only. For advanced abilities such as model, you will need to write a seperate plugin and the automation program calls the plugin. what jabowabo contridued in meesage 4 is an example if you write the code of plugin.

 

While COM Automation can manipulate the document and also the model. A plugin is not required. So what deanlyon contributed in message 3 is a kind of code to unhide object in COM. It assumes you have created an Automation of COM. There are some automation samples in SDK

\api\COM\examples\Auto

 

 

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report