Dereferencing a non-pointer error - attempting to list Spaces that elements reside in

Hello,

(See attached graph)

I have created a workflow that grabs all elements of a category, finds the Space they reside in, then assigns a unique sequential ID in the order of the room number via “List.SortByKey”. This works in my small simplified “test environment” project, but am having trouble when using this workflow on a larger “real world” project, and it is getting hung up on the list of Spaces. I am getting an error, “Dereferencing a non-pointer”. I have read other threads that say that it’s possible that when the first item listed is “null”, it can bring about this error.

One Idea: Remove “nulls” from the Space list (before it gets pushed to the “GetParameterValueByName” node), but not sure how to do this. I would also think that the number of filtered results would need to be the same for all elements getting pushed to the “List.SortByKey” ‘list’ input.

Another Idea: Somehow rearrange the Elements list (aka the output of the “All Elements of Category” node) to at least start with an element that has a valid Space, so that it may circumvent the error.

Any ideas or thoughts for a solution would be greatly appreciated.

Thank you!!

Assign ID graph|689x206

It may not be the most elegant fix, but if you put a check to see if a value is null after your familyInstances.Space node it will return a list of true or false for every item. (code block: x == null or x != null depening on if you prefer to work with true or false for the elements.

With this you can use a filter by boolmask node to get only elements that actually return a space

Of those elements either get the spaces again or get the indexvalues of the elements and then the corresponding spaces. You might also be able to do it with just a list.clean node, but you would have to check this.
Also feed the boolmask output into the codeblock and list.sort nodes.

Hope it helps

1 Like

Try using a function to pull the data through.

Remove the element input from the GetParameterValue and the name of the node will change to a lighter grey.
Wire that into a Function.Apply node as the function, and the element list as the argument.
You can then test for null and use that to filter both the spaces and the equipment list.

1 Like

Great thinking - this is actually what I ended up getting to work. Thank you for your keen input, and this confirms the approach to using “remove null” and “filter by boolmask”. See attached revised graph for the working solution.

The next step I will work on is taking all the “null” results and assigning an ID string to the ID parameter, but will not need to pull the Space number for those.

Thank you very much!

I appreciate your response and intuitive solution - I used a different approach to achieve to get a result, but will keep this method in mind. I posted an image of the finished graph in my post from a couple minutes ago. Thank you for your time and solution!

1 Like