View Full Version : element.parameter overload-V8.1
I've just discovered the parameter overload method which I assume allows me to access a parameter of an element directly using in my case the definition.
I'm trying to access a parameter of a generic annotation using the following code:
ID = element.Parameter.Definition("ID") where ID is the parameter name
and I get the following error:
AttributeError: 'FamilyInstance' object has no attribute 'Parameter'
Does this method not work with family instances? Or am I missing something?
TIA,
Guy
Danny Polkinhorn
2005-09-26, 08:22 PM
Guy,
I took a quick glance at the Object Browser and there isn't a Parameter property for FamilyInstance objects. Nor have I seen an example of using the Parameter function to directly access a specific parameter. You might have to use a ParameterSetIterator to iterate the parameters. I'd like to see the answer to your question too as it seems that it would be much easier (and faster) to access specific parameters with this method.
Cheers Danny,
Firstly, I still don't quite get the difference between Autodesk.Revit.Elements... and Autodesk.Revit.Element.... ?
From the API.chm for 8.1(sorry no page numbers so I can't provide a reference) the element class says I should have a parameter property that can be overloaded and a relevant parameter referenced by definition,GUID,builtin enum.
Elements.FamilyInstance.Parameter should be possible but only accessing builtin parameters I think. For user created parameters I think you have to access these through the parameterSet.
The conclusion I've come to is, I should at least be able to access builtin parameters using my code but even this doesn't seem to be working.... Will keep trying.
Guy
Danny Polkinhorn
2005-09-26, 11:59 PM
Guy,
Yes, this can be quite confusing, especially for guys like you and me who don't program for a living. :? :-)
Elements is an ElementSet, a collection of individual Element objects. You're correct, Element objects do have a method called Parameter. While a FamilyInstance is derived from Element and you can find them in an ElementSet, they have had the Parameter method removed.
Take a Room for example. Rooms are derived from an Element object. So in addition to sharing all the properties and methods of Elements, they have additional properties and methods, like their boundary, that not all other elements have.
They can also Override a method in a base class replacing it with a new method, or removing support for it in the derived class. It looks like this is what they've done in your case, removing a specific method from a base class. Everything derived from an Instance class doesn't have a Parameter method (or any other method of an Element for that matter). Note the differences in the attached images between Instance and Element.
I hope that doesn't confuse you more...
Danny,
Thanks for taking the time to explain this, it's much clearer now. I've fudged it to get it working but I'll keep trying and see if there is a better way. I really need to stop having fun with python and the API and publish the binding for everyone to play with;-)
The BRM or Building Risk Matrix is a lovely piece of legislation the government has introduced after NZ's 'leaky building crisis'. In this example the command generates the numerical score based on a number of parameters in a generic annotation(ReD.BRM). Each parameter value can be either low, medium, high or very high (text parameter).
brmKlass = BRM
numAnnot = 0
for elem in elementSet:
try:
cat = elem.Category.Name
if cat == "Generic Annotations":
if elem.Name == "ReD.BRM":
numAnnot +=1
#this is a dictionary of parameters for accessing afterwards
paramDict={}
if elem.Parameters.Size != 0:
for param in elem.Parameters:
paramDict[param.Definition.Name] = param
ID = paramDict["ID"].AsInteger()
vw = paramDict["View"].AsString()
wz = paramDict["Wind Zone"].AsString()
ns = paramDict["Number of Storeys"].AsString()
ind = paramDict["Roof-Wall Intersection design"].AsString()
ew = paramDict["Eave Width"].AsString()
ec = paramDict["Envelope Complexity"].AsString()
dd = paramDict["Deck Design"].AsString()
rs = paramDict["Risk Score"]
rs.Set(brmKlass.calcRisk(wz, ns, ind, ew, ec, dd))
except:
raise
winForms.MessageBox.Show("Finished processing \n %d Annotations processed" %numAnnot)
Guy
Guy
Ummm, let's see... You know, it's impossible to remove a method from a class. You either inherit, or you don't.
So, what's happening is that the Parameter property can take either a GUID, a built-in enum, or a Definition object (that really encompasses the other two). There is no method to look up a parameter by a string. That's why your code does not work.
Log a support request that the family parameters be properly represented in the API.
Danny Polkinhorn
2005-09-27, 09:59 PM
Ummm, let's see... You know, it's impossible to remove a method from a class. You either inherit, or you don't.That's why you make money doing this and I don't! :wink: Inheritance is still a new thing for me. Thanks for clearing it up.
So, what's happening is that the Parameter property can take either a GUID, a built-in enum, or a Definition object (that really encompasses the other two).
Cheers Fedor,
Lots to learn...;-) The error I was getting was 'FamilyInstance' object has no attribute 'Parameter'.
So as far as the element is concerned there is no parameter method? Not that I was trying to access it using the Name as the identifier? Looking at help it should work so it must be some problem with the way python is binding to the API ;-( The first problem I've had like this... Will try it in C# and see if that works.
Guy
I think it's inadequate error reporting - it was supposed to tell you there's no Parameter[String].
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.