View Full Version : BuiltInParameters
New to the API and working in VB. Is it possible to pull in the BuiltInParameter for both project_name and project_number. What type of object do I need to construct to read and set these values? Thanks in advance.
To get the parameters you first need to get the appropriate element. The clue is at the top of the project information form. Project Information is a system family therefore you need to walk the element tree to get this family. In this case Search the symbols looking for a element with category "project Information". This will give you the parameterset.
One for the wishlist. Would be nice if these system families didn't require walking the tree. Unfortunately the PI element Id changes from project to project so you can't just grab the elementID although you could parse once and store.
Thanks! Got it working. It would be nice if there was a more direct route.
2007-01-03, 03:44 PM
Guy and others:
Like Frank, I got this working as well, so thank you.
Is it also possible to access custom information in the Project Information? We have added some project parameters in our default template (for example, one is called "Detail Order"). They show up fine under Project Information, but since it's not a Built In Parameter, I can't seem to access it. It seems as though the second option for parameter ought to allow for this as it appears in the .chm file -- parameter(definition as autodesk.revit.parameters.definition). However, this type of code doesn't work:
Do While ElementIter.MoveNext
Dim objElement As Autodesk.Revit.Element = ElementIter.Current
Dim Category As Autodesk.Revit.Category = objElement.Category
If Not (Category Is Nothing) Then
If Category.Name = "Project Information" Then
MsgBox("Project Information found")
Any ideas on accessing custom project parameters in Project Information?
Thanks in advance,
Almost right. The easiest way to process a mixture of builtin and custom parameters is to loop through all the parameters and process as you go.
To use element.parameter(...) requires the parameter definition or GUID for custom parameters.If it's not a shared parameter then you need to loop through all parameters for one element to get the definitions.... Because project information is only one element there isn't much point doing this so just use a foreach loop on the ParameterSet and a switch statement to process each parameter as required.
2007-01-08, 09:19 PM
Once again, you're the man. After taking your suggestion, it took about 2 minutes to code it and get it working. I'll keep this in mind for the rest of my API life: "When in doubt, walk the tree.".
I'll keep this in mind for the rest of my API life: "When in doubt, walk the tree."
Actually it depends... Walking the parameter tree is OK. Walking the element tree is to be avoided if possible.
Glad it helped.
2008-02-22, 10:57 PM
Ok, help. I am trying to get read some custom project parameters from rooms. Just to get the idea I'm trying to first get Revit to walk the parameters of a single object and give me a message box with their value. It's working to start, but it gives me probably 8 or 10 parameters (some blank, but with no errors) and then gives me an "object reference not set to an instance of an object" error. My code is as follows:
Dim item As Room = rmset(1)
Dim param As String = ""
Dim pset As ParameterSet = item.Parameters
For Each p As Parameter In pset
If Not p Is Nothing Then
Dim storageType As Parameters.StorageType = p.StorageType
Dim prompt As String = ""
Select Case storageType
Dim iVal As Integer = p.AsInteger()
prompt = iVal.ToString()
prompt = p.AsString()
prompt = p.AsValueString()
Dim elemId As Autodesk.Revit.ElementId = p.AsElementId()
Dim elem2 As Autodesk.Revit.Element = m_Revit.ActiveDocument.Element(elemId)
prompt = elem2.Name
prompt = p.AsString()
Catch ex As Exception
Can anyone help?
2008-02-22, 11:08 PM
Ok, well actually I took out the case statements and it seems to work now. I just made it say
I got the case statement from the SDK room schedule sample so I figured I needed it. It doesn't seem that I do, or am I missing something? I will experiment further and post back...
thanks and if anyone has any suggestions please feel free.
2008-02-23, 01:52 PM
I'd say it's almost certainly because of how you handled the ElementId case...
While a parameter may exist that has an ElementId type, that doesn't mean that it's actually set to an actual element.
Off the top of my head, I think in that case, the ElementId.Value comes back as zero (or -1, I can't recall off hand). You're turning and trying to get the Element object from that ElementId - which I suspect is NULL. Then when you try to use Elem2.Name, you're getting your error.
In short, you need to test either the ElementId.Value > 0 or the Elem2 <> Null, and handle that case differently.
2008-02-25, 02:15 PM
hmm. Ok, thank you I will look at that. I'm still new to this programming stuff, thanks for the help :)
Powered by vBulletin® Version 4.1.11 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.