AttributeError: 'NoneType' object has no attribute 'AsValueString

Trying to create a simple script but getting this error. Don’t understand why because i can clearly see the value in it.

“AttributeError: ‘NoneType’ object has no attribute 'AsValueString”

please check this out. Try ruling out Null values in the code.

My guess: The Comments parameter doesn’t have units, so AsValueString doesn’t apply.

Try AsString instead.

Hi Jacob,

Tried both actually. Can see the value in Revit lookup. Don’t know why it’s not giving me the value.

Do all elements have a value and location?

If i remove the method i get this…

You can see the value is there in the comment section.

Hello @lovebhardwaj01
you can use the WhereElementIsNotElementType() method in your FilteredElementCollector to get only instances.

ALL_MODEL_INSTANCE_COMMENTS is an instance parameter

1 Like

Attribute errors in Python are generally raised when you try to access or call an attribute that a particular object type doesn’t possess. It’s simply because there is no attribute with the name you called, for that Object. This means that you got the error when the “module” does not contain the method you are calling. But it is evident that the method is there, which leads to believe that may be the method was added by you in the source code after you had already imported the file (module). Or, some times packages get deprecated and they rename some functions. If that is true, then you may want to exit and reimport the module once again to be able to access the new method .

You can do it in another way to reimport the module with changes without having to exit the interpreter is to do the following:


If you are using python 3.2 or 3.3 you should:

import imp

If running Python 3.4 and up, do import importlib, then do:

import importlib

The importlib.reload() method reload a previously imported module. The argument must be a module object, so it must have been successfully imported before .