Python Help


#1

I am trying to retrieve parameters using python for some fabrication parts in Revit. I cannot access these parameters through the user interface or dynamo (that I know of) and that is my reasoning for using Python. Please see what is wrong with the script below. It is throwing error that is also posted.


image

I watched the course that was suggested at [https://www.lynda.com/Dynamo-Studio-tutorials/Dynamo-Revit-Python-Scripting/647661-2.html]. It was great. Thanks.


#2

you are trying to use “for” in something that is not a list, is an “FabricationPart” object…


#3

Ok. So I have changed the element’s and got rid of the collector. So now I should have a list.


image


#4

@coastguard09 Built In Parameters and other API references are case-sensitive, try changing “Fabrication_Part_Length” to uppercase so that line 20 is
output.append(i.get_Parameter(BuiltInParameter.FABRICATION_PART_LENGTH))


#5

That did the trick. Unfortunately, The results came back null. That means those parameters are empty?


#6

Empty parameters show up as blanks, not nulls. In the Instance Properties of the parts you are inputting, do you see Length under the Dimensions parameter group? Its possible the Fabrication Parts you are inputting do not report Length.

Does querying the Size property give you the output you are seeking? (replace line 20 with the following line):

output.append(i.Size)


#7

Length does not show up under the dimension parameter group which makes me think that they do not report the length.

When I replaced Line 20 they returned blank.

So is there no way to get to that length then?


#8

Could you share a screenshot showing the Type Properties of one of the elements? It would help to see what your elements are :slight_smile: if they do not report length, perhaps there is another dimension parameter that will give you the output you are looking for


#9

Hi @coastguard09

Is this length your trying to extract?


#10

That’s the one. Those dims are what I want to get at.


#11

I think you have used the “GetDimension” and “GetDimensionValue” methods. When I use the “GetDimensionValue” method it tells me an arguement is expected.

I am still looking for what I need. Just figured i’d give an update.


#12

So I know need to input a “FabricationDimensionDefinition” but do not know where I can find this information. Could anybody point me in the right direction?

image


#13

I think i am almost there. Any help?

I have so many outs just to check myself.


#14

Please attach the needed files for helping purposes, which involves the .dyn file and a small sample file would that also help. Furthermore, please provide code as text not as an image.
It is time-consuming to reinvent what you have done, so please provide whatever you can to speed up the helping process.


#15

today.dyn (2.1 KB)

@erfajo I will do this in the future. I have put the .dyn file on here.


#16

something like this

today.dyn (4.7 KB)

import clr
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

parts = IN[0]
lengths = []

for part in parts:
    lengths.append(part.GetParameterValueByName('Length'))

OUT = lengths

#17

@erfajo I am trying to access fabrication part dimensions. They don’t show up like your normal parameters on a revit element. Yes i can get some of them, but not the ones I want using your proposed method.


#18

which parameters do you want, then it is easiere to help you if that could be described.


#19

If you look at @Kulkul screenshot, that is what I am trying to achieve. I just figured it out though. I am going to mark this as solved and then when I put some finishing touches on it, I will post graph and script.


#20

I can get fabrication elements length with the code I gave you… so what is missing?
today.dyn (8.6 KB)