#PowerShell, #PowerWiseScripting, #ProjectWise, PWPS_DAB

How To: Update TitleBlocks with PowerShell

There have been many requests asking for the ability to update titleblocks within MicroStation using PowerShell. The good news is that this can be accomplished. It simply requires you run the Enable-PWTitleBlockUpdate cmdlet which was added to the PWPS_DAB module in version 1.7.6.0.

Get-Help Enable-PWTitleBlockUpdate -Full

The Enable-PWTitleBlockUpdate cmdlet sets a few values within the registry to allow PowerShell to update the titleblocks.

Enable-PWTitleBlockUpdate -Verbose

verbose

The following shows the changes made to each of the registry keys which enables the titleblock update for both 32bit and 64bit versions of the PWPS_DAB module.

Regedit1Regedit2

Configure ProjectWise Datasource

In order for titleblocks to be updated, at least one of the highlighted Update file conditions needs to be toggled on within the ProjectWise Administrator client. 

titleblock

Get Document Object to Update

The following populates the PWDoc variable with the ProjectWise document object. This is the design file containing the titleblock to be updated.

The document and settings used in these examples are delivered with the sample data provided with the ProjectWise installers.

# ProjectWise Folder Containing design file to update.
$PWFolder = 'BSI400 - W01 - Intersection of I-9 and SR 32\04_Design\D_Design-Files'
# Design file name.
$PWDocName = 'BSI400-RW-SH-NA-0002'
# Populate PWDoc with returned ProjectWise Document object.

$Splat = @{
FolderPath = $PWFolder
DocumentName = $PWDocName
JustThisFolder = $true
}
$PWDoc = Get-PWDocumentsBySearch @Splat

 

Titleblock within the Design File Prior to Updating

There are two empty lines below the 1 – 9… line in the highlighted section. In the following examples we will use PowerShell to update these two lines.

titleblock_before

Document Attributes Prior to Updating TitleBlock

In the first example, we will be adding the two highlighted lines to the titleblock within the design file.

attributes_checkout

Update TitleBlock Using CheckOut

In the following we will use PowerShell to checkout and checkin the ProjectWise document. The titleblock will be updated because the Update File Condition: Document is “Checked Out” is toggled on.

# Checks out the document and immediately checks it back in.
CheckOut-PWDocuments -InputDocument $PWDoc -Verbose |
CheckIn-PWDocumentsOrFree

Titleblock after running Checkout-PWDocuments

Opening the MicroStation Design File from within ProjectWise Explorer using View.

You can see that the two new lines have been added to the titleblock.

titleblock_aftercheckout

Update TitleBlock Using CopyOut

In the next example we will use PowerShell to copy out the ProjectWise document. The titleblock will be updated because the Update File Condition: Document is “Copied Out” is toggled on.

Updated the last line for titleblock update.

attributes_copyout

# Copy out document to the local working directory.
CheckOut-PWDocuments -InputDocument $PWDoc -CopyOut -Verbose

Titleblock after running Checkout-PWDocuments with CopyOut

Opening the MicroStation Design File from within ProjectWise Explorer using View.

Again, you will see that the last line in the titleblock now reflects the change made within the document attributes.

titleblock_aftercopyout

Update TitleBlock Using Export

Finally, in the last example we will use PowerShell to export the ProjectWise document to a folder on the local drive. The titleblock will be updated because the Update File Condition: Document is “Exported” is toggled on.

Updated the last line for titleblock update.

attributes_export

# Export document to the specified folder on the local drive.
CheckOut-PWDocuments -InputDocument $PWDoc -Export -ExportFolder 'd:\temp\export' -Verbose

Titleblock after running Checkout-PWDocuments

Opening the MicroStation Design File from within ProjectWise Explorer using View.

Again, you will see that the last line in the titleblock now reflects the change made within the document attributes.

titleblock_afterexport

 

Experiment with it and have fun.

Hopefully, you find this useful. Please let me know if you have any questions or comments.

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 )

Google photo

You are commenting using your Google 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.