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
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
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); } }
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