Hi,
I think this is mostly a Design Script issue… i am still new at it.
i am trying to assign the Level of a pipe fitting based on its location with respect to the levels in the Document.
So i will compare its Z location with respect to the Levels Elevation.
As you can see below, i am getting “Empty List”. I have tried many things, based on the Forums, but i guess i am still missing something fundamental or this should not be an issue.
Can someone help me out see what i am missing?
thanks
def elActualLevel(el_lst:var[],lvls_lst:var[]){
el_cnt = DSCore.List.Count(el_lst);
lvl_cnt = DSCore.List.Count(lvls_lst);
return=[Imperative]{
el_lvl_lst=[];
for(ec in 0..el_cnt){
// Get point.Z of each element
g = Element.GetLocation(el_lst[ec]);
pt = Points.DeconstructPoint(g);
pZ = DesignScript.Dictionary.ValueAtKey(pt,"Z");
for(lc in 0..lvl_cnt)
{
if(pZ > lvls_lst[lc]) {
//DSCore.List.AddItemToEnd(lvls_lst[i],el_lvl_lst);
el_lvl_lst[ec]=lvls_lst[lc];
}
}
}
return el_lvl_lst;
}};
Is the Points.DeconstrucPoint
a custom node?
Regardless, I think you won’t be able to extract the point Z of each fitting through a for-loop. If I’m not mistaken this is not a static method.
Maybe you can get the location and each Z coordinate out of the Imperative mode and then proceed with your idea.
Hi EdsonMatt,
It looked like the culprit was GetLocation. I could not put it in the imperative block. it complained about non static function. So i kept it above the imperative block.
The reason i did not see this is that warning message the first time around, before i submitted my question, is that i was building the code as a def function, and calling it as you see in image below. It was only when i switched to writing the code as in-line codeblock, and not a function call, did i start seeing these warnings… i am not sure if there is a switch for hiding these warnings. it would have saved me a lot of time if i did see them early on.
So here it is now, it gets the location of a Pipe Fitting based on its Location on the Z axis, regardless of what the Revit assignment for it is, in the properties window.
Thanks for your response,
// Get the Level of a Fitting Based on its Z location with respect to Level Elev in Doc.
def fittActualLevel(fitt_el_lst:var[], lvls_lst:var[]){
// Get Z of Center of Fitting
fitt_el_geo_lst = Element.GetLocation(fitt_el_lst);
fitt_el_pt_lst = Points.DeconstructPoint(fitt_el_geo_lst);
fitt_el_pZ_lst = DesignScript.Dictionary.ValueAtKey(fitt_el_pt_lst, "Z");
lvls_elv_lst = Revit.Level.Elevation(lvls_lst);
lvls_nm_lst = Revit.Level.Name(lvls_lst);
// Sort the List by Elevation (by keys)
lvls_sort_lst = DSCore.List.SortByKey(lvls_lst, lvls_elv_lst);
// Seperate the two Dictionary output ("sorted list" and "sorted keys")
lvls_elv_sort_lst = DesignScript.Dictionary.ValueAtKey(lvls_sort_lst, "sorted keys");
lvls_nm_sort_lst = Revit.Level.Name(DesignScript.Dictionary.ValueAtKey(lvls_sort_lst, "sorted list"));
// get the counts of the elements and the Level sorted lists
el_cnt = DSCore.List.Count(fitt_el_pZ_lst);
lvl_cnt = DSCore.List.Count(lvls_elv_sort_lst);
return=[Imperative]{
//[Imperative]{
//------- Begin Custom Function here -----------
el_lvl_lst=[];
for(ec in 0..el_cnt-1)
{
// i had to assign a Default value,
//since the else overrides the if statement Below
el_lvl_lst[ec]="missing";
for(lc in 0..lvl_cnt-1){
//if(el_lst[ec] >= lvls_elv_sort_lst[lc])
if(fitt_el_pZ_lst[ec] >= lvls_elv_sort_lst[lc])
{
el_lvl_lst[ec] = lvls_nm_sort_lst[lc];
}
// else
// {
// el_lvl_lst[ec]="Missing";
// }
}
}
//------- End Custom Function here -----------
return el_lvl_lst;
}
};
1 Like