I have a few python components following the MyComponent class setup. However sometimes they fail on their first run, and enabling/disabling the component does not fix it. However, opening the script editor and hitting the test/run buttons fix it. Any clues?
Error was the error is object not set to an instance
But i canât get line number and i canât debug, because as soon as i run it with the test button in the editor, the error disappears. Clue of missing line numbers if the error is in overwrite methods, or in classes not part of the MyComponent class.
Your comment on init got me to look new places in my componet.
I have a RhinoRoom class in here which had a init that required a dictionary in the constructor.
I might have fixed it by changed the below. I changed:
class RhinoRoom:
Geometry = None
Name = "RhinoRoom"
Values = {}
Points = []
def __init__(self, dict):
self.Values = dict
if dict.ContainsKey("Name") and dict["Name"] != None:
self.Name = dict["Name"]
to
class RhinoRoom:
Geometry = None
Name = "RhinoRoom"
Values = {}
Points = []
def __init__(self, dict = None):
if dict is not None:
self.Values = dict
if dict.ContainsKey("Name") and dict["Name"] != None:
self.Name = dict["Name"]
else:
self.Values = {}
Not sure if this will fix (the error message is not very specific unfortunately), try changing your variable name from âdictâ to something else. dict is a reserved keyword.
Also I would move the static variable Values into the init.