One of the SDK samples in Navisworks called AutoSimpleScriptExample shows how to use the Navisworks API with the VB script file. If there is a requirement to change the background color from black to another color, say, red during this automation process, how can we achieve this?
All available attributes for publishing are listed in InwOaPublishAttribute. There is no attribute to control the background color. However, you can use state.BackgroundColor before publishing. Performing the following changes (highlighted in grey) to the VB script file included in the AutoSimpleScriptExample, helps change the background color to Red.
' Navisworks API - AutoSimpleScriptExample - Script Automation
' Example of using the Navisworks API with VB script file
'------------------------------------------------------------
'TODO: The filename needs setting to a suitable .nwd file.
'create new document
set navis_doc=CreateObject("Navisworks.Document")
'make sure it's visible
navis_doc.visible=true
'open document
navis_doc.OpenFile("C:\Program Files\Autodesk\Navisworks Manage 2013\API\COM\examples\gatehouse.nwd")
'set current view to first saved view
navis_doc.state.currentview=navis_doc.state.savedviews(1).anonview
dim ndx
ndx = navis_doc.state.getenum("eObjectType_nwLVec3f")
set color =navis_doc.state.objectFactory(ndx)
color.data1 = 1
color.data2 = 0
color.data3 = 0
navis_doc.state.BackgroundColor = color
'make sure app stays open with no refs
navis_doc.stayopen
Using the SDK sample as it is: