PDA

View Full Version : need a new script..



Shihan Jedi
11-03-2009, 03:53 PM
just wanted to see if someone already has it made.
i want a script that will open a model, turn all the layers on, and then close it.
so the bat file i have will then run nwd files every nite with the layers turned on...

:D

A script to process autocad files that were made with Autoplant XM.
The native file type is a dwg.
the script should open, turn on every layer on the model and all xrefs
save then close.
thats it.

dave
11-03-2009, 10:37 PM
I think perhaps starting with the software being used would be a huge help:)

Shihan Jedi
11-05-2009, 07:22 AM
Ive modifed my idea but im still missing somthing...

open the dwg, run a turn on all layers
and then reload all xrefs

save and exit...

_-layer
-on
*
<return>
_-xr
-reload
*
<return)
-qsave
-exit

but im not getting the returns right...and the break from layer command to the xref command is not smooth.
any help is appreciated..

Packin31
11-05-2009, 07:54 AM
Jedi,

Try this one.

Change .txt to .scr

Zortar
11-05-2009, 07:58 AM
Jedi,
In a script, a blank line is a return. Also, make sure you use notepad as your editor since some editors will add a file carriage return at the end of the file, which gets interpreted as another <return>. Also be careful to avoid space characters on blank lines.

Attached is my attempt at your script. Rename the file to .SCR extension.

Shihan Jedi
11-05-2009, 11:44 AM
-xref
reload
*

-LAYER
on
*

-LAYER
thaw
*

.save

quit
y

Shihan Jedi
11-05-2009, 02:06 PM
OK.
currently the scr file i have does not work. but I have made a simular file in multibatch that does work, er... mostly.

problem is no one here but me has multi batch.

also, i still cant make the nwd file run with the .bat file.
navis 2010 does not like nor does it listen to the navis2009 version of
createnwd.vbs

so right now im trying to find a way to automate thru a .bat file an NWD output. If i can accomplish this, i can use task scheduler to run it every day.

Patrick_Aps
11-05-2009, 10:21 PM
I just did the test: Created a DWG with 3 boxes, each on a different layer. Layer 1 is current, Layer 2 is off and Layer 3 is frozen.
I started NavisWorks 2010
Tools -> Global Options -> File Readers -> DWG/DXF/SAT
check both "Convert Off" and "Convert Frozen"
Open the DWG with the boxes
As you can see, the initial view is as in the DWG: the frozen and off layers are invisible.
Edit -> Reset All -> Unhide all B)
everything becomes visible, without changing the DWG
Save this as NWF

Then I modified the DWG, thawed and froze some layers
opened the NWF again,
everything remainded visible.

Shihan Jedi
11-06-2009, 05:27 AM
ok, that solves half the battle. Now I need to automate the creation of the NWD file on a nightly basis using a .bat file.
Which at this time, I have not got to work yet...
but thank you Patrick_Aps, I appreciate that!!

Patrick_Aps
11-06-2009, 06:59 AM
mine works fine...

The batch file has lots of parameters for the in my case PDS project server,
cleans all the *nwc files before opening the NWF
and publishes the nwd with a YYYYMMDD_Project.nwd filename

Shihan Jedi
11-06-2009, 07:06 AM
oh my goodness...Patrick, I am now awake...
I have read and re read your email...and tested it...

we no longer need nwd files...i understand now the value of a master nwf file and appends all the models and refreshes those every time its opened.

i was blind, but now i see.

i am testing it today...

cant thank you enough...

dave
11-06-2009, 07:20 AM
That's why he's the God of SQL

Patrick_Aps
11-06-2009, 07:23 AM
Per Project you can have one NWF file that always shows the current state,
but then only one person can open the nwf file and edit it, and uses a licence

For each time you have a model discussion with the client, you need an NWD file with the status of that day, that can be opened with Navisworks Freedom.

So in our project teams it is common that the server creates NWD overnight,
the 3D CAD desingers use the NWF
but all other project members, managers and the client uses the daily_NWD files and Navisworks freedom...

Shihan Jedi
11-06-2009, 07:47 AM
Patrick, we can all 3 open the master.nwf file here at the same time.
We plan on creating specific views with direct naming conventions.
once that is done, each person can open it and move around and view.
no changing needing to be done. just used as a daily viewer.

i can see the need for nwd files only to benchmark a time on the project or to share as a walk thru with engineers.

does this sound ok?

Shihan Jedi
11-06-2009, 12:39 PM
but i am unsure as to what changes i need to make.

it seems the biggest change is the pathways.
is there some way you can show me what lines in those files I need to modify?

Patrick_Aps
11-09-2009, 02:28 AM
Place an ECHO before the 5th last line (the one with %VB_Sript%
and remove the REM of the last line

The script will then show in a dialog what script it wants to start, which NWF file it wants to open and which NWD file it wants to create.

Modify the SET lines until it makes sense.

All lines staring with REM are comments and do nothing
First I make the current folder C:\Programs\Batch\NavisWorks
Then I try to substract the year, month and date from the system, and I show the result. It should be 20091109 today.
then you have to change the PDSROOT=\\SERVERNAME\SHARE
PROJ=
SourceFolder=
and SourceFile=
with the location and filename of your NWF file.

Shihan Jedi
11-10-2009, 08:29 AM
here is what my current vbs looks like.

@ECHO OFF
TITLE Daily Creation of NavisWorks NWD
REM Based on
REM ------------------------------------------------------------------
REM NavisWorks API - AUTO_08 - Script Automation
REM Example of using the Publish API with VB script file
REM Takes an input file and creates an expiring published output file
REM ------------------------------------------------------------------
REM Usage:
REM nwf2nwd.vbs <input_filename> <output_filename> <title>
REM Example:
REM S:\Workgroups\SCS PSDF Wilsonville\PSDFData\DRAWINGS\BATCH\nwf2nwd.vbs "c:\temp\in.nwc" "c:\temp\out.nwd" "title"
ECHO.
S:
CD S:\Workgroups\SCS PSDF Wilsonville\PSDFData\DRAWINGS\BATCH
REM ------------------------------------------------------------------
REM Set the Date Variables in format yyyymmdd
REM Scheck the Regional settings of the Server
REM TIME must be HH:mm:ss
REM short DATE must be MM/dd/yyyy
set jaar=%DATE:~10,4%
set dag=%DATE:~6,2%
set maand=%DATE:~4,2%
set jaar=%DATE:~6,4%
set dag=%DATE:~3,2%
set maand=%DATE:~0,2%
ECHO %jaar%%maand%%dag%
ECHO.
REM ------------------------------------------------------------------
REM Set the File Variables
SET PDSRoot=\\alxapin03.southernco.com\shared data
SET PROJ=PSDFPC4SET SourceFolder=S:\Workgroups\SCS PSDF Wilsonville\PSDFData\DRAWINGS\MECHDRAW\_CO2_Post_C ombustion\PC4 MODEL
SET SourceFile=PC4.nwf
SET VB_Script=S:\Workgroups\SCS PSDF Wilsonville\PSDFData\DRAWINGS\BATCH\nwf2nwd.vbs
SET TargetFolder=S:\Workgroups\SCS PSDF Wilsonville\PSDFData\DRAWINGS\MECHDRAW\_CO2_Post_C ombustion\PC4 MODEL
SET TargetFileName=PC4.NWF
REM ------------------------------------------------------------------
REM Clean Up the old *.nwc and *.nwd files
REM ECHO %PDSRoot%\%PROJ%\*.nwc
REM DEL /F /S /Q %PDSRoot%\%PROJ%\*.nwc
REM ECHO %PDSRoot%\%PROJ%\%TargetFolder%\*%TargetFileName%* .nwd
REM DEL /F /S /Q %PDSRoot%\%PROJ%\%TargetFolder%\*%TargetFileName%* .nwd
REM ------------------------------------------------------------------
REM Create the new nwd file
ECHO.
ECHO "%VB_Script%"
ECHO "%PDSRoot%\%PROJ%\%SourceFolder%\%SourceFile%"
ECHO "%PDSRoot%\%PROJ%\%TargetFolder%\%jaar%%maand%%dag% _%Proj%_%TargetFileName%.nwd"
ECHO "%Proj%_%TargetFileName%*"
ECHO %VB_Script% "%PDSRoot%\%PROJ%\%SourceFolder%\%SourceFile%" "%PDSRoot%\%PROJ%\%TargetFolder%\%jaar%%maand%%dag% _%Proj%_%TargetFileName%.nwd"

:END
ECHO Reached the End
PAUSE

everything in bold im not sure about.
AND im having trouble distinguishing between what a pdsroot is.
a target file and a source file...
source is the nwf?
target is what? something that has not been created yet??
:eek:

I have the native nwf file in a diff folder than the piping models. and i have all the vbs and .bat file in a folder on the network s drive called batch.
why does the vbs want the project root? its being told to
find the pc4.nwf and turn it into a pc4.nwd.
im confused...

Shihan Jedi
11-10-2009, 08:49 AM
:\Workgroups\SCS PSDF Wilsonville\PSDFData\DRAWINGS\
MECHDRAW\_CO2_Post_Combustion\PC4 MODEL\/10/Tu 1_PSDFPC4_PC4.NWd.nwd

Shihan Jedi
11-10-2009, 08:59 AM
ok im pretty sure its the date settings on the vbs that killing the run.

here is the section on the dates...

REM ------------------------------------------------------------------
REM Set the Date Variables in format yyyymmdd
REM Scheck the Regional settings of the Server
REM TIME must be HH:mm:ss
REM short DATE must be MM/dd/yyyy
set jaar=%DATE:~10,4%
set dag=%DATE:~6,2%
set maand=%DATE:~4,2%
set jaar=%DATE:~6,4%
set dag=%DATE:~3,2%
set maand=%DATE:~0,2%
ECHO %jaar%%maand%%dag%
ECHO.
REM ------------------------------------------------------------------

i dont mind modifing it, but i have no idea what
jaar
dag
maadnd
and the 6,2% mean...

Shihan Jedi
11-10-2009, 12:19 PM
HERE IS MY CURRENT VERSION OF THE SET FILE VARIABLES
REM Set the File Variables
SET PDSRoot=\\ALWLVFP02\GROUPS
SET PROJ=\psdf\DRAWINGS\BATCH
SET SourceFolder=\\ALWLVFP02\GROUPS\PSDF\DRAWINGS\MECH DRAW\_CO2_Post_Combustion\PC4 MODEL
SET SourceFile=PC4.nwf
SET VB_Script=C:\Program Files\Autodesk\Navisworks Review 2010\api\nwcreate
SET TargetFolder=\\ALWLVFP02\GROUPS\PSDF\DRAWINGS\MECH DRAW\_CO2_Post_Combustion\PC4 MODEL
SET TargetFileName=daily_pc4

HERE IS THE OUT OF THE BOX ON THE SET FILE VARIABLES
REM Set the File Variables
SET PDSRoot=\\SERVERNAME\SHARE
SET PROJ=PROJECTFOLDERNAME
SET SourceFolder=3d\drv\Daily
SET SourceFile=Daily.nwf
SET VB_Script=C:\Programs\Batch\NavisWorks\nwf2nwd.vbs
SET TargetFolder=3d\drv\Daily
SET TargetFileName=Daily

Zortar
11-10-2009, 12:27 PM
I think Jar, Dag and Maand are Year, Day and Month in Dutch.

Patrick_Aps
11-11-2009, 03:04 AM
set jaar=%DATE:~10,4%
takes the substring of the variable DATE starting the 10th character and taking 4 charaters. The idea is that you become 2009

As for the other variabels, be sure that the
set
is at the beginning of a line

PDS root should have the server and share
but then proj does NOT need to have the driveletter
because on the last lines they are all concatenated togeter

Also the idea was NOT to have spaces in the Servername, sharename or foldernames.

the PC4 Model is causing troubles, i guess

Patrick_Aps
11-11-2009, 05:42 AM
The Idea was also to have the nwf in the Sourcefolder and the generated nwd files in a different TargetFolder, but that is not necessary.

So Try This:
I renamed the folders
MECH DRAW to MECH_DRAW and
PC4 MODEL to PC4_MODEL

SET PDSRoot=\\ALWLVFP02\GROUPS\PSDF\DRAWINGS\MECH_ DRAW\_CO2_Post_Combustion
SET PROJ=PC4
SET SourceFolder=PC4_MODEL
SET SourceFile=PC4.nwf
SET TargetFolder=PC4_MODEL
SET TargetFileName=daily
SET VB_Script=”C:\Program Files\Autodesk\Navisworks Review 2010\api\nwf2nwd.vbs”

%VB_Script% "%PDSRoot%\%SourceFolder%\%SourceFile%" "%PDSRoot%\%TargetFolder%\%jaar%%maand%%dag %_%Proj%_%TargetFileName%.nwd"

It should open
\\ALWLVFP02\GROUPS\PSDF\DRAWINGS\MECH_ DRAW\_CO2_Post_Combustion\PC4_MODEL\PC4.nwf
and create
\\ALWLVFP02\GROUPS\PSDF\DRAWINGS\MECH_ DRAW\_CO2_Post_Combustion\PC4_MODEL\20091111_PC4_d aily.nwd

Shihan Jedi
11-11-2009, 07:04 AM
So far, nothing. ive included your changes Patrick.

is there an error file or message or something i can retireve that will tell me where the problem is??

i run it and nothing. so i really dont know whats causing the non output.

Patrick_Aps
11-11-2009, 07:09 AM
locate the nwf2nwd.vbs and the batch file in
”C:\Program Files\Autodesk\Navisworks Review 2010\api\"

Start -> Run
type in CMD and ok
a dos box opens
type in
CD ”C:\Program Files\Autodesk\Navisworks Review 2010\api\"
(you can paste using the right mouse click)
then type in het name of your batch file
it should then echo some variabels