See the top rated post in this thread. Click here

Page 4 of 22 FirstFirst 1234567814 ... LastLast
Results 31 to 40 of 217

Thread: Transparent Local file creation

  1. #31
    NavisWorks Moderator david.kingham's Avatar
    Join Date
    2004-07
    Location
    Fort Collins, CO
    Posts
    1,329
    Login to Give a bone
    1

    Default Re: Transparent Local file creation

    Thanks alot David, I've wasted a many hours learning AHK because of you lol
    I figured out how to get the specify worksets option, everything is automated except for the user specifying what worksets to open.
    I've modified yours quite a bit to suit our needs but you can pick out the parts you need, I changed it so the local file goes into a subfolder and added an Archive folder.
    I haven't done a lot of testing on this so let me know if anything doesn't work for you.

    Code:
    ;---###Scripted by David Baldacchino 08/10/2007, with lots of help from the Discussion Forum at AutoHotKey.com. Thanks guys!!
    ;---###Modified by David Kingham 09/16/2007
    
    i = 0
    Loop, *central.rvt, 0, 0  ; Don't include folders (0) or Recurse into subfolders (0)
    
    
    ;---#### The script is designed to be placed in the location of the central file. First we're going to loop through
    ;---#### all files in the folder to check if there is only one central file. If there are more files that match the
    ;---#### searched pattern, the script will issue a dialog, open the folder and terminate execution.
    
    
    {  
       i := i+1
       CENTRALFILE = %A_LoopFileName%
    }
    
    if i > 1
    {
       ; This will execute if more than one central exists
       MsgBox, 16, Problem encountered!!, %i% Central Files were found! Please make sure there is only one Central File in the folder.
       Goto, LABEL1
    }
    Else if i = 0
    {
       ; This will execute if no central is found
       MsgBox, 16, Problem encountered!!, No Central File was found!
       Goto, LABEL1
    }
    
    Goto, LABEL2
    
    LABEL1: ;---------------------------Activate or open the central file folder
    
    IfWinExist %A_WorkingDir%
    {
      WinActivate
      ExitApp
    }
    Else
    {
      Run %A_WorkingDir%
      ExitApp
    }
    
    LABEL2: ;---------------------------Check discipline
    
    DSCPLN := SubStr(CENTRALFILE,-14,1)    ; Pick the 14th character to determine the discipline
    
    If DSCPLN = A
    {
       DISCIPLINE = Architecture
       Goto, LABEL3
    }
    
    If DSCPLN = S
    {
       DISCIPLINE = Structure
       Goto, LABEL3
    }
    
    If DSCPLN = M
    {
       DISCIPLINE = MEP
       Goto, LABEL3
    }
    
    If DSCPLN = E
    {
       DISCIPLINE = MEP
       Goto, LABEL3
    }
    
    If DSCPLN = P
    {
       DISCIPLINE = MEP
       Goto, LABEL3
    }
    else
    {
       MsgBox, 16, Undefined Discipline!!, The discipline designator ("%DSCPLN%") in the filename is incorrect.`n Please rename the file correctly and try again.
       Goto, LABEL1
    }
    
    LABEL3: ;---------------------------Create Local File
    
    
    ;---#### Create local file folder in case it doesn't exist. Delete the backup copy of the local file. Rename the existing local file so it becomes the new backup.
    ;---#### Then copy the central file to this folder and rename it to reflect the user's username, thus becoming the new local file. 
    
    StringTrimRight, PARTFILE, CENTRALFILE, 11
    
    DESTINATION = C:\Revit Local Files\%PARTFILE%
    
    FileCreateDir, C:\Revit Local Files\Archive
    
    LOCALFILE = %PARTFILE%%username%.rvt                                          ; and replace with "username.rvt"
    
    FileRecycle, C:\Revit Local Files\Archive\%PARTFILE%                                              ; If "_BAK" file exists, delete it and keep in recycle bin
    
    FileMoveDir, %DESTINATION%, C:\Revit Local Files\Archive\%PARTFILE%, 2                       ; Rename the local (if exists) by appending "_BAK" to the filename
    
    FileCreateDir, %DESTINATION%
    
    FileCopy, %CENTRALFILE%, %DESTINATION%, 0                                     ; Do not overwrite existing files    (0). Copy central to destination...
    
    FileMove, %DESTINATION%\%CENTRALFILE%, %DESTINATION%\%LOCALFILE%                ; and rename copied central to appropriate local filename.
    
    ;---#### Now start the correct flavor of Revit, but first check if it is installed and if it is already running, to prevent a new session from opening.
    ;---#### Remove the user's username from Revit.ini so Revit uses the Username System Variable. Then open the new local file.
    
    
    AppPath = %A_ProgramFiles%\Revit %Discipline% 2008\Program\
    IfNotExist, %AppPath%
    {
       MsgBox, 20, Application not installed!!, The local file "%LOCALFILE%" has been created and would typically be opened with Revit %Discipline% 2008.`nThis application is not installed on your computer. Do you want to use another discipline's Revit application?
       IfMsgBox No, ExitApp
       IfMsgBox Yes
       {
          DISCIPLINE = Architecture
          AppPath = %A_ProgramFiles%\Revit %Discipline% 2008\Program\
          IfNotExist, %AppPath%
          {
             DISCIPLINE = Structure
          }
          AppPath = %A_ProgramFiles%\Revit %Discipline% 2008\Program\
          IfNotExist, %AppPath%
          {
             DISCIPLINE = MEP
          }
          AppPath = %A_ProgramFiles%\Revit %Discipline% 2008\Program\
          IfNotExist, %AppPath%
          {
             MsgBox, 16, Application not found!!, No version of Revit is installed on this computer. Please contact IT for assistance.
             ExitApp
          }
       }
    }
    
    IniWrite, %DESTINATION%, %AppPath%\Revit.ini, Directories, ProjectPath ;
    
    {
    ; Open Revit Discipline 2008 and open the file
    Run %AppPath%Revit.exe
    WinWait, Revit Architecture 2008 - [Project1 - Drafting View: Start], 
    IfWinNotActive, Revit Architecture 2008 - [Project1 - Drafting View: Start], , WinActivate, Revit Architecture 2008 - [Project1 - Drafting View: Start], 
    WinWaitActive, Revit Architecture 2008 - [Project1 - Drafting View: Start],  
    Send, {ALTDOWN}fo{ALTUP}
    WinWait, Open, 
    IfWinNotActive, Open, , WinActivate, Open, 
    WinWaitActive, Open, 
    Send, %LOCALFILE% {TAB}{ALTDOWN}w{ALTUP}{DOWN}{ALTDOWN}o{ALTUP}{ALTDOWN}o{ALTUP}
     
    }
    #Persistent
    SetTimer, MsgBoxCheck, 1000
    
    MsgBoxCheck:
    If WinExist("Revit", "This Central File has been copied or moved from", "ahk_class #32770")
    {
       WinClose
       ExitApp
    }
    Return

  2. #32
    Count (Formula) dbaldacchino's Avatar
    Join Date
    2005-07
    Location
    Missouri City, Texas (Houston area)
    Posts
    3,250
    Login to Give a bone
    0

    Default Re: Transparent Local file creation

    haha, sorry for forcing you to learn AHK

    I'm developing something similar but in a different way. I want to make it work without needing Revit to be the active window, which is the only way to make the senkeys method work. basically I'm making AHK write a text file (journal) and run it, which would open Revit and bring up the dialog. I'm stuck on being able to run a journal if Revit is already open, which isn't too bad as I can open a new session (or use your method on the running session by sending keystrokes). I still haven't given up on that though, but we'll see. The idea is to then create a menu that will come up and the user will either just open the local file or open the local and launch the worksets dialog or detach from central.

    Thanks for posting! I'll do the same once I get back to the second version of this project. The current version (with no menu and just opening the local) has been working great for us.

  3. #33
    Moderator JamesVan's Avatar
    Join Date
    2016-01
    Location
    New York, NY
    Posts
    625
    Login to Give a bone
    0

    Default Re: Transparent Local file creation

    Quote Originally Posted by david.kingham View Post
    Very nice David, I created the same thing just in a less fancy fashion through batch files, about the only difference is mine does not open the local file so you can specify what worksets to open initially
    David (Kingham, that is),

    I like your simple BAT file solution. I'm trying to figure out how to get it to partially rename the local files - yes, multiple files per project. Right now, my modified rename line is as follows:

    Code:
    for %%f in ("%UserProfile%\My Documents\%PROJECT_NUMBER%\*.rvt") do rename "%UserProfile%\My Documents\%PROJECT_NUMBER%\*CENTRAL.rvt" "*LOCAL.rvt"
    This leaves me with files that are "Project-BldgA-CENTRAL.rvt-LOCAL.rvt". Do you know of a way to accomplish this using the BAT file? Looks like Dave B has it figured out with AutoHotKey, so I'll check that out in the meantime.

  4. #34
    NavisWorks Moderator david.kingham's Avatar
    Join Date
    2004-07
    Location
    Fort Collins, CO
    Posts
    1,329
    Login to Give a bone
    0

    Default Re: Transparent Local file creation

    You're on the right track James, I did a little bit of testing and I think the only thing you need to do is add the dash in before central and local, should look like this
    Code:
    for %%f in ("%UserProfile%\My Documents\%PROJECT_NUMBER%\*.rvt") do rename "%UserProfile%\My Documents\%PROJECT_NUMBER%\*-CENTRAL.rvt" "*-LOCAL.rvt"

  5. #35
    NavisWorks Moderator david.kingham's Avatar
    Join Date
    2004-07
    Location
    Fort Collins, CO
    Posts
    1,329
    Login to Give a bone
    0

    Default Re: Transparent Local file creation

    I think you'll appreciate this David, I created a GUI that allows you to choose from specify worksets, open all, detach from central or just open revit. It pulls revit into focus no matter what the user is doing. I added a ton of stuff, you'll have to look at the code as most of it is commented, I'm pretty happy with it
    Attached Files Attached Files

  6. #36
    Count (Formula) dbaldacchino's Avatar
    Join Date
    2005-07
    Location
    Missouri City, Texas (Houston area)
    Posts
    3,250
    Login to Give a bone
    0

    Default Re: Transparent Local file creation

    Nice work David! You took it a lot farther than where I left it I'll have to go through it and re-path some stuff and see what it does. Looks like using the SEND command is probably the best way to go since we can't run journals while Revit is already running. Thanks for sharing all your hard work!

  7. #37
    NavisWorks Moderator david.kingham's Avatar
    Join Date
    2004-07
    Location
    Fort Collins, CO
    Posts
    1,329
    Login to Give a bone
    0

    Default Re: Transparent Local file creation

    Thank you for sharing your work, I never would have got to this point without your original script. If you think of anything to add to it let me know, I'm getting fairly proficient (I'm sure the code is very ugly to the real experts, but it works that's all that matters lol)

  8. #38
    Member
    Join Date
    2007-05
    Posts
    9
    Login to Give a bone
    0

    Default Re: Transparent Local file creation

    Quote Originally Posted by david.kingham View Post
    Very nice David, I created the same thing just in a less fancy fashion through batch files, about the only difference is mine does not open the local file so you can specify what worksets to open initially

    David, I used your script file and tinkered with it so it has our file structure locations. Problem is it will create the archive file for me but it does not overwrite the previous file there. if it could delete the previous archive and then resave the new one it would fix this. same for the local file. Steve Stafford suggested that we maybe save a new local file everyday so i would like this to be as transparent and easy for our staff to run it as possible. I havent looked at the AHK much and it looks way harder to personalize than these .bat files you created. Can you help me with some code perhaps and maybe even suggest a better way maybe to be able to leave the script file in one central location and be able to shortcut it into the projects that we to set up? any info is appreciated.

    Jaysyn

  9. #39
    NavisWorks Moderator david.kingham's Avatar
    Join Date
    2004-07
    Location
    Fort Collins, CO
    Posts
    1,329
    Login to Give a bone
    0

    Default Re: Transparent Local file creation

    Ahh you found a bug I never even realized it wasn't overwriting the archive, change this and it should work

    Code:
    :ArchiveLocal
        RD  "C:\Revit Local Files\Archive\%PRJ%" /S /Q
        mkdir "C:\Revit Local Files\Archive\%PRJ%
        rename "C:\Revit Local Files\%PRJ%\*.rvt" "*-%username%-ARCHIVE.rvt"
        xcopy /c /v /q /y /i /r /h /s "C:\Revit Local Files\%PRJ%" "C:\Revit Local Files\Archive\%PRJ%"
        RD  "C:\Revit Local Files\%PRJ%" /S /Q
        goto :CopyCentral

  10. #40
    Member
    Join Date
    2007-05
    Posts
    9
    Login to Give a bone
    0

    Cool Re: Transparent Local file creation

    Quote Originally Posted by david.kingham View Post
    Ahh you found a bug I never even realized it wasn't overwriting the archive, change this and it should work

    Code:
    :ArchiveLocal
        RD  "C:\Revit Local Files\Archive\%PRJ%" /S /Q
        mkdir "C:\Revit Local Files\Archive\%PRJ%
        rename "C:\Revit Local Files\%PRJ%\*.rvt" "*-%username%-ARCHIVE.rvt"
        xcopy /c /v /q /y /i /r /h /s "C:\Revit Local Files\%PRJ%" "C:\Revit Local Files\Archive\%PRJ%"
        RD  "C:\Revit Local Files\%PRJ%" /S /Q
        goto :CopyCentral

    Do I just add this somewhere specific or am i rewriting over a portion? thanks for the fast reply!

    here is my code:
    @echo off
    REM ------------------- Script Functions -------------------
    REM Replaces Keyboardshortcuts and Revit.ini
    REM Rename Batch file to desired project name
    REM Script checks for existing local files
    REM Archives if they exist
    REM Copies CENTRAL files to LOCAL folder
    REM Renames CENTRAL files with USERNAME

    for %%1 in (%0) do (set PRJ=%%~n1)
    for %%1 in (%0) do (set CEN=%%~dp1)
    REM title Neenan Revit Projects - %PRJ%
    echo.
    echo Checking for existing local files for %PRJ%
    echo.

    if exist "C:\Revit Projects\%PRJ%\*.rvt" (
    goto ArchiveLocal
    ) else (
    echo.
    echo Creating LOCAL folder for %PRJ%
    echo.
    mkdir "C:\Revit Projects\%PRJ%\
    goto :CopyCentral
    )

    :ArchiveLocal

    if not exist "C:\Revit Projects\Archive\%PRJ%\*.rvt" (
    mkdir "C:\Revit Projects\Archive\%PRJ%
    echo.
    echo %PRJ% folder created in Revit Projects
    echo.
    )

    echo.
    echo Renaming existing LOCAL files to LOCAL-ARCHIVE
    echo.

    rename "C:\Revit Projects\%PRJ%\*.rvt" "*-LOCAL-ARCHIVE.rvt"

    echo.
    echo Moving existing %PRJ% LOCAL files to %PRJ% ARCHIVE
    echo.

    xcopy /y /i /s "C:\Revit Projects\%PRJ%" "C:\Revit Projects\Archive\%PRJ%"
    RD "C:\Revit Projects\%PRJ%" /S /Q

    :CopyCentral

    echo.
    echo Copying %PRJ% CENTRAL files to LOCAL folder
    echo.

    xcopy "%CEN%*.rvt" "C:\Revit Projects\%PRJ%\" /y

    echo.
    echo Adding "-%username%" to %PRJ% LOCAL files
    echo.

    rename "C:\Revit Projects\%PRJ%\*.rvt" "%PRJ%-LOCAL.rvt"

    echo.


    call "U:\Revit standards\EW RAC2008.bat"
    cls
    @echo off
    echo Done!
    echo Local File created in C:\Revit Projects\%PRJ%
    type "U:\Revit standards\echo.txt"
    pause

    exit
    Last edited by jasonq; 2007-11-20 at 03:06 PM. Reason: add code

Page 4 of 22 FirstFirst 1234567814 ... LastLast

Similar Threads

  1. Transparent Local File Creation - GUI (v5) *UPDATED*
    By dbaldacchino in forum Revit - Worksharing/Worksets/Revit Server
    Replies: 38
    Last Post: 2017-01-09, 02:50 AM
  2. Detached Revit Local File - (Anyway to reattach or copy worksets over to central file)
    By Reviting in forum Revit - Worksharing/Worksets/Revit Server
    Replies: 2
    Last Post: 2014-05-23, 05:17 PM
  3. Creation of local file and synchronization error
    By wongkuanwei570223 in forum BIM Management - General
    Replies: 3
    Last Post: 2014-03-10, 09:44 PM
  4. 2014: Revit reporting Central File is not available, no one else is in file, can't save, won't create local file
    By patricks in forum Revit - Worksharing/Worksets/Revit Server
    Replies: 3
    Last Post: 2013-10-03, 10:31 PM
  5. Local Files: program to delete local file and create a new local file
    By mailshanegross in forum Revit - Worksharing/Worksets/Revit Server
    Replies: 4
    Last Post: 2009-06-03, 02:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •