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

Leave a Reply