Mostly Revit... by Eric Stimmel

Detail Groups vs. Detail Components

Tuesday, July 17, 2012

I’m sure this has been done before, but here’s a simple file size comparison for using detail components vs. using detail groups. I took a simple 1x4 and made a detail group out of this using six lines and arrayed it 100 times in one direction and arrayed the array 100 times in the other direction. You can see images of it below. I then took the out-of-the-box Revit detail component of a 1x4 and inserted that into a new file starting from the same template and arrayed it the same way. I then saved the files as new files (to compress them) and checked the file sizes. I did the same thing for one instance for both the detail component and the detail group.

The results are telling - the single instance files are exactly the same size, but the file with 10,000 instances of the detail group is more than twice the size of the corresponding file using detail components. Now, I admit, 10,000 instances is a lot of instances so I did the math1 and using the detail group ended up adding about 100 bytes per line. That could add up to something not too insignificant.

one instance
10000 instances
file sizes

  1. (9,808 KB - 4,044 KB) / 10,000 instances = 0.58 KB If you round that up to 0.60 or 600 bytes per detail group and considering that each detail group contains six lines, that’s roughtly 100 bytes per line. I should really have more sample data to be making this claim… 

Upgrade a Model on Revit Server

Wednesday, June 20, 2012

This video nicely documents the two methods of upgrading a model on Revit Server.

Re-Selection

Friday, May 25, 2012

We’ve started rolling out Revit 2013 and among the new features is one called selection sets.1 There are already many different ways to aggregate objects in Revit which means it is often unclear which one to use. Regardless, I welcome the new addition - perhaps this one will work where all the others have come up short.

The topic of selection in Revit reminded me of a simple tip that, in my experience, is mostly unknown but beloved by those who do know it. The tip is that Ctrl + Left Arrow reselects the previous selection. If you have ever spent considerable effort control-selecting a large number of objects only to somehow accidentally deselected them, you can breathe a sigh of relief.

  1. Apparently selection sets have been in RST for some time - anyone know when they first appeared? 

Revit Server Model List Using the REST API

Tuesday, May 8, 2012

We’ve been looking into Revit Server for awhile at work, but never found the right project to use as a pilot until recently. There’s finally a project where our team is split between two different physical locations on the same WAN and Revit Server makes sense.

We have used GlobalScape WAFS in the past, quite successfully, when we needed access to a set of models from various locations not on the same WAN. This was before Revit Server even had that capability. That, however is a different blog post - forthcoming.

I’m sure I’ll write more about this as the project develops, but today I wanted to go over how to obtain a list of files from the Revit Server without using Revit.

I need to create local files of all the project (.rvt) files in a specified directory on the Revit Server. Autodesk provides a command line tool for making a local copy of a single file and this works well - we’ll need it - but it’s limited. First, you can only make one local file at a time. Our project has four files, but what about when there are 10 files? Or 50 files? Or 10 projects each with more that five files? We have projects like that, they just aren’t currently using Revit Server. The second limitation is that you must know the name of the model before making the local copy. Again, there are only four models and I know their names, but we’re going to do this anyway.

The command line local file creation utility does not provide an option for returning a list of models in a specific folder, so we’ll need to turn to the API. Revit Server uses the REST API. I’ll be using AutoHotKey in my example, but you can use any language. Jeremy Tammik has some helpful information with links to Autodesk’s documentation and examples. If you have the Revit SDK installed, you also have the Revit Server SDK which includes a PDF titled Revit Server REST API Reference which will be invaluable. On my machine, it can be found here:

C:\Program Files (x86)\Revit 2012 SDK\Revit Server SDK\Revit Server REST API Reference.pdf

We’ll need to make a specially formed HTTP request. This is a common task for web applications and consequently there are several libraries written in AutoHotKey that can do this - I’ve chosen to use HTTPRequest.ahk by VxE. Revit Server will respond to this request by sending back JSON formatted data. To get the filenames (or the project names in the future) we’ll need to parse the response. Again, JSON is common on the web and I easily located json.ahk by polyethene to help with this task. There are a couple of other scripts I gathered on the AutoHotKey Forums that I’ve linked to in the code. That’s about it. Once we are able to dynamically gather the file/project names, we can do something with them. My script below just shows the list of files in a message box and then writes it to a text file, but we could also call the Revit command line tool and loop through the project folder to make local/backup copies of every model without having to know the model names in advance.

So here’s the script.

;;
;; AutoHotkey_L Version:  1.x
;; Language:            English
;; Platform:            x64
;; Author:              Eric Stimmel
;;
;; Script Function:
;;	Query Revit Server and return a list of models from a specified folder.
;;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance force
#Persistent

; include the supporting scripts
#include HTTPRequest.ahk
#include json.ahk
#include autoByteFormat.ahk

; create a new GUID for the HTTP header
; http://www.autohotkey.com/community/viewtopic.php?t=84037
TypeLib := ComObjCreate("Scriptlet.TypeLib")
NewGUID := TypeLib.Guid
StringReplace, NewGUID, NewGUID, {,,All
StringReplace, NewGUID, NewGUID, },,All
; MsgBox %NewGUID% ; for debugging

; create the headers
; <host> is the name of your server
URL := "http://<host>/RevitServerAdminRESTService/AdminRESTService.svc/|My Revit Server Project/contents"
In_POST__Out_Data := ""
In_Out_HEADERS := % "User-Name: " . A_UserName . "`nUser-Machine-Name: " . A_ComputerName . "`nOperation-GUID: " . NewGUID
Options := "Method: GET"

; make the request
HTTPRequest(URL, In_POST__Out_Data, In_Out_HEADERS, Options)

; MsgBox % In_POST__Out_Data ; for debugging - this should show the request that is sent

; set up our while loop
increment = 0
name = Models[%increment%].Name
model = % json(In_POST__Out_Data, name)

While model
{
	size = Models[%increment%].ModelSize
	modelsize = % json(In_POST__Out_Data, size)
	modelsize := autoByteFormat(modelsize)
	modelList = %modelList%%model%`t%modelsize%`n
	increment++
	name = Models[%increment%].Name
	model = % json(In_POST__Out_Data, name)
}

; MsgBox %In_Out_HEADERS% ; for debugging - this should show what is returned (see below for a sample)
MsgBox %modelList% 									; show the list in a message box
FileAppend, %modelList%, C:\ModelList.txt 			; write the list to a text file

ExitApp  

Here’s what the server returns. I’ve formatted it for ease of reading. You should be able to figure out what’s going on… If you uncomment the “In_POST__Out_Data” message box, you’ll get this unformatted in a message box. You can also write it to a text file for further analysis or just to see what you get.

{
	"Path":"My Revit Server Project",
	"DriveFreeSpace":204557041664,
	"DriveSpace":250056704000,
	"Folders":[],
	"LockState":0,
	"ModelLocksInProgress":null,
	"Models":[
		{
			"LockState":0,
			"ModelLocksInProgress":null,
			"ModelSize":12398749,
			"Name":"ARCH-1.rvt",
			"ProductVersion":2,
			"SupportSize":46843
		},
		{
			"LockState":0,
			"ModelLocksInProgress":null,
			"ModelSize":19581057,
			"Name":"STRUC-1.rvt",
			"ProductVersion":2,
			"SupportSize":7929
		},
		{
			"LockState":0,
			"ModelLocksInProgress":null,
			"ModelSize":7515290,
			"Name":"ARCH-2.rvt",
			"ProductVersion":2,
			"SupportSize":20218
		},
		{
			"LockState":0,
			"ModelLocksInProgress":null,
			"ModelSize":19395162,
			"Name":"STRUC-2.rvt",
			"ProductVersion":2,
			"SupportSize":5881
		}
	]
}

Changing The Workset Of An Array

Wednesday, August 24, 2011

Ever needed to change the workset of an array? A couple of days ago I did, and to my surprise, I couldn’t do it. Okay, eventually I figured it out and I’ll explain the head smackingly simple solution since I couldn’t find any blog posts describing it, but it was a really frustrating 30 minutes of Google searches and failed attempts by me and a couple of my colleagues to get there.

The trick if you’d like to call it that, is in figuring out how to select the array itself. You might think that selecting one of the items in the array would select the array because the array is kind of like a wrapper around the object, but that only selects the Array Group.

Selecting an item in an array.

You might then assume that by selecting all the items within the array you would be selecting the array itself because, well, the array is all of the things in the array. You would be wrong.

Selecting all items in an array.

At this point you might start wondering whether or not there is an array object and that perhaps the problem is something altogether different. Maybe the elements aren’t editable. Nope. Perhaps the Array category isn’t visible - no, there is no Array category. You might start Googling or asking your neighbor, then, almost by chance, as you are clicking around on everything and anything, you select the modal line above the arrayed objects and as if my royal decree, the workset parameter activates and it’s possible to change the workset of the array. So, to be clear, you have to select one of the objects in the array to make the array (manifest as a line with a number above it) visible and then select the array (the line with the number above it).

Selecting the array.