Just follow the steps:
1 - Pick the code below and create the file nwd2nwd_publish.vbs;
2 - rename the file attached Publish_nwd.txt to Publish_nwd.bat;
3 - Put both in the same folder / directory in computer;
4 - Edit the Publish_nwd.bat in Notepad to edit the arguments, such as the full path of the nwd2nwd_publish.vbs file, and the full path of the .nwf file to publish and the destination folder;
5 - Open nwd2nwd_publish.vbs to edit aditional arguments, there's an explanation in the top of the vbscript;
6 - Open the prompt and run the script that is inside the Publish_nwd.bat file or use Task Scheduler in windows to to schedule to run this automation daily for exemple;
'Usage:
'cscript.exe nwf2nwd_advanced.vbs <f_in> <f_out> <title> <subject> <author> <publisher> <publishedfor>
'<copyright> <keywords> <comments> <password> <expirydate>
'Example of the command in .bat (batch file command, just create a test.txt in yout desktop and rename to test.bat)
'using cscript.exe in the beginning to run the vbscript, you can run by prompt or task scheduler:
'cscript.exe "P:\teste_smartplant\nwf2nwd_advanced.vbs" "P:\teste_smartplant\112-60-45-Mecanica.nwf" "P:\teste_smartplant\112-60-45-Mecanica.nwd" "Projeto XXX" "Modelo para acompanhamento de projeto" "Company_Name" "" "" "" "" ""
' input argument
dim roamer
dim attrib
dim ndx
dim arg_in
dim arg_out
dim arg_title
dim arg_password
dim arg_author
dim arg_subject
dim arg_copyright
dim arg_keywords
dim arg_comments
dim arg_publisher
dim arg_publishedfor
dim flags
dim arg_expiry
dim expiry
dim count
dim datenow
''prepare arguments
if WScript.Arguments.Count < 10 then
WScript.Echo "Missing parameters"
Else
count=WScript.Arguments.Count
arg_in=WScript.Arguments(0)
arg_out=WScript.Arguments(1)
arg_title=WScript.Arguments(2)
arg_subject=WScript.Arguments(3)
arg_author=WScript.Arguments(4)
arg_publisher=WScript.Arguments(5)
arg_publishedfor=WScript.Arguments(6)
arg_copyright=WScript.Arguments(7)
arg_keywords=WScript.Arguments(8)
'arg_comments=WScript.Arguments(9)
arg_comments="Data de publicação: " & dateadd("d", 0, Now())
arg_password=WScript.Arguments(9)
'arg_expiry=WScript.Arguments(11)
'arg_expiry = dateadd("d", 21, Now())
'expiry=CDate(arg_expiry)
End if
''create roamer via automation
set roamer=createobject("navisWorks.document")
roamer.visible = false
''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.author=arg_author
'attrib.expirydate=expiry
attrib.subject=arg_subject
attrib.copyright=arg_copyright
attrib.keywords=arg_keywords
attrib.comments=arg_comments
attrib.publisher=arg_publisher
attrib.publishedfor=arg_publishedfor
flags=attrib.flags
''show properties when open Navisworks
ndx=roamer.state.getenum("ePublishFlag_DISPLAY_ON_OPEN")
''embed recap and textures
ndx1=roamer.state.getenum("ePublishFlag_EMBED_TEXTURES")
''embed database properties such as datatools linked to excel table
'ndx2=roamer.state.getenum("ePublishFlag_EMBED_DATABASE")
''allow nwd output file be saved in other model or naviswork file
'ndx3=roamer.state.getenum("ePublishFlag_ALLOW_RESAVE")
flags=flags or ndx or ndx2 or ndx1 or ndx3
attrib.flags=flags
'write output file
roamer.publishfile arg_out,attrib
Pick