2

Is it posible to somehow extract, export or copy Project Properties from Revit file using Revit Python Shell? And if yes, how difficult it is?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Zed
  • 23
  • 2

2 Answers2

1

By Project Properties do you mean Project Information Parameters? This is a quick way to fetch a Project Information parameter in RPS:

parameterName = 'Project Name'
value = '- parameter not found -' # default setting

for parameter in document.ProjectInformation.Parameters:
    if parameter.Definition.Name == parameterName:
        if parameter.AsString():
            value = parameter.AsString()
        elif parameter.AsDouble():
            value = parameter.AsDouble()
        elif parameter.AsInteger():
            value = parameter.AsInteger()
        else:
            value = '- invalid value -'


print value

Edit: To fetch parameter values

Callum
  • 578
  • 3
  • 8
0

I can't speak to the Revit Python Shell, but in terms of the Revit API it's pretty straightforward.

From your Document object, there's a "ProjectInformation" property.

So in C# it looks like:

Parameter p =
myDoc.ProjectInformation.get_Parameter(BuiltInParameter.PROJECT_NUMBER);

Parameter o = 
myDoc.ProjectInformation.GetParameters("MyCustomParameter").FirstOrDefault();

Side note: I've recently run into a spate of models that had no ProjectInformation property (null) on their Document. That's not good. I believe it can be fixed by running an Audit on the model - but from a code perspective you should be prepared for it (not like above! :) ).

Matt
  • 1,043
  • 5
  • 8
  • wow! do you know the history of those files? would you like to try executing doc.Delete on the ProjectInfo element? it may be possible to delete it anytime you like, and thus cause pain and anguish for other poor souls... – Jeremy Tammik Dec 01 '16 at 08:23
  • Jeremy, I don't know how they got that way. A few customers sent them in to us because they were failing in some of our apps, where we didn't check for null on the ProjectInformation property. We had to put out a patch for our software. – Matt Dec 01 '16 at 12:12