Override transparency from VBScript

By Adam Nagy

If you have an nwf document with a saved selection set and you want to override the transparency for the objects that belong to that, and finally save the document to nwd format, then you can use the following code which is based on the AUTO_08.vbs sample.

option explicit
 
dim roamer
dim attrib
dim ndx
dim arg_in
dim arg_out
dim arg_title
dim arg_password 
dim flags
dim arg_expiry
dim expiry
dim count
 
dim selsets
dim current
dim i
 
count=WScript.Arguments.Count
 
arg_in=WScript.Arguments(0)
arg_out=WScript.Arguments(1)
arg_title=WScript.Arguments(2)
arg_password=WScript.Arguments(3)
arg_expiry=WScript.Arguments(4)
 
expiry=CDate(arg_expiry)
 
'create roamer via automation
set roamer=createobject("navisWorks.document")  
 
'open input file
roamer.openfile arg_in
 
'create publishing attribute
ndx=roamer.state.getenum("eObjectType_nwOaPublishAttribute")
set attrib=roamer.state.objectFactory(ndx)
 
'set publishing properties
attrib.title=arg_title
attrib.password=arg_password
attrib.expirydate=expiry
 
flags=attrib.flags
ndx=roamer.state.getenum("ePublishFlag_DISPLAY_ON_OPEN")
flags=flags or ndx
attrib.flags=flags
 
' get selection sets
set selsets = roamer.state.SelectionSets()
count = selsets.Count
for i = 1 to count
  set current = selsets.Item(i)
  ' check the name  
  if current.name = "MySelSet" then
    'override transparency
    roamer.state.overridetransparency current.selection, .5
  end if
next
 
'write output file
roamer.publishfile arg_out,attrib

Comments

One response to “Override transparency from VBScript”

  1. Hello,
    Is there any way to perform a search and apply overridetransparency on said search ? Something like Set s = roamer.state.objectFactory(Search) ?
    I can’t find any resource on VBS syntax for Navisworks. There’s only 2 examples left in the api folder, the rest is C# and I don’t know how to use it. The documentation doesn’t make it overly clear either. All I need to make is a simple VBS file to automate transparency replacements.
    I would be very grateful if you could help.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading