#PowerShell, #PowerWiseScripting, #ProjectWise, PWPS_DAB

How To: Change the Environment on a Project with Documents

Be sure to check out my Scripting4Crypto initiative. It’s a fun way to get into using cryptocurrencies all while getting your PowerShell needs met.

I’ve come across a few instances where users are having difficulty changing the ProjectWise Environment associated with a folder. The cause of the issue was that some or all of the documents contained within the folder had attribute sheet(s) associated with them. An attribute sheet is created either at the time a document is created or when any document attribute values are filled in. So, to resolve this issue, we have added a new cmdlet, Remove-PWDocumentSheet to the PWPS_DAB module.

The following is one approach to changing the environment on a folder.

Steps to change the environment associated with a ProjectWise folder.

  • First, determine if the folder exists.
  • Second, check to see if it contains documents.
  • Third, if it does, remove all of the attribute sheets associated with the documents.
  • Finally, set the new environment for the folder.
# Verify the folder exists.
$Project = Get-PWFolders -FolderPath 'Test\New' -JustOne -Verbose

# Get the current environment name.
$Project.Environment

The following is the output:
VERBOSE: Looking for folder ‘Test\New’
VERBOSE: Folder ‘Test\New’ was found with ID 2745

# Next determine if the folder contains any documents.
$PWDocuments = Get-PWDocumentsBySearch -FolderPath $Project.FullPath -Verbose

The following is the output:
VERBOSE: Found 6 documents

# Next, remove the associated attribute sheets.
$PWDocuments = Remove-PWDocumentSheet -InputDocument $PWDocuments -Verbose

The following is the output:
VERBOSE: Preparing to remove attribute sheets from 6 documents.
VERBOSE: A111-View-1.dwg has 1 sheets associated with it.
VERBOSE: Preparing to remove attribute sheets.
VERBOSE: Successfully removed attribute sheets.
VERBOSE: A111-View-2.dwg has 2 sheets associated with it.
VERBOSE: Preparing to remove attribute sheets.
VERBOSE: Successfully removed attribute sheets.

# Finally, set the new environment for the folder.
Set-PWFolderEnvironment -InputFolder $Project -NewEnvironment "Complex" -Verbose

# Verify the environment was updated.
$Project.Environment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.