ArchiTech: SuperCharge your worksharing setup for new projects in Revit

Tags: , , , ,

Date: February 25, 2016

tech-tues-richard-binning

Public domain image Credit: By CZmarlin — Christopher Ziemnowicz https://commons.wikimedia.org/w/index.php?curid=5114914

As part of new project rollouts, it is always a best practice to setup the worksharing according to project workflow and project type.  If you have developed some internal standards with regard to worksharing and setting up worksets within Revit then you will find this macro handy.  If you’re familiar with the Macro editor inside Revit, grab a copy of the macros listed below and supercharge your workset setup.  If you’re unfamiliar with the SharpDevelop macro editor inside Revit, then you’ll want to do a little learning.

I recommend doing a google search for “Revit macro Tutorial”.  You’ll find links at AUGI.com and ArchSmarter among others.   At last years Autodesk University, I had the pleasure of assisting Michael Kilkelly as a lab assistant in his Macro class.  While his class is mainly focused on document level macros in Visual Basic, you can easily use the sharp develop macro editor to convert this c# dot net code into visual basic if that is your preferred language.

tech-tuesday-richard-binning-bim

public void CreateDefaultWorksets()
{
Document doc = this.ActiveUIDocument.Document;
// An unsorted string array.
string[] Workshares =
{
“CEILINGS”,
“DWG PLAN LINKS”,
“DWG LINKS – ALL OTHERS”,
“MEP MODEL”,
“MECHANICAL MODEL”,
“ELECTRICAL MODEL”,
“PLUMBING MODEL”,
“MERCHANDISING MODEL”,
“FIXTURES”,
“INTERIORS MODEL”,
“RENDERING ENTOURAGE”,
“SHELL & CORE”,
“STRUCTURAL MODEL”,
“XX-SACRIFICIAL & HIDDEN”
};
// Use LINQ query syntax to sort the array alphabetically.
var sorted = from share in Workshares
orderby share
select share;
// Loop with the foreach keyword.
foreach (string value in sorted)
{
CreateWorkset(doc,value);
}
}

The above routine could be duplicated to create additional macros dedicated to creating worksets for different project types by changing the workset names in each version. Or it could be further extended by adding a dialog box and selector option to read a simple list from a text file to make it really flexible for multiple project delivery types.  I’ll leave that to you to complete.

public Workset CreateWorkset(Document document, string worksharename)
{
Workset newWorkset = null;
// Worksets can only be created in a document with worksharing enabled
if (document.IsWorkshared)
{
string worksetName = worksharename;
// Workset name must not be in use by another workset
if (WorksetTable.IsWorksetNameUnique(document, worksetName))
{
using (Transaction worksetTransaction = new Transaction(document, “Set preview view id”))
{
worksetTransaction.Start();
newWorkset = Workset.Create(document, worksetName);
worksetTransaction.Commit();
}
}
}
return newWorkset;
}

Note:  There are many people in our industry willing to share their knowledge and code.  The above “CreateWorkset” subroutine was only slightly modified from the original code found here:  http://adndevblog.typepad.com/aec/2015/10/aec-hackathon-and-creating-workset-with-revit-2016-api.html.  This code also works with Revit 2015.

# # #

By: Richard Binning, Director of BIM Technology; Check out his blog: Beside the Cursor; http://www.integr-8.com/