First, this is an extremely useful little utility that is most helpful in visualizing the critical metrics of the JSBSim model. Thank you for creating it.
When importing a JSBSim xml file, if the file does not contain any "external_reactions" tags, it will generate an "AttributeError: 'NoneType' object has no attribute 'final'"
. The dump is included in the attached screenshot. Based on my limited understanding here... I think the issue is the following code lines:
def parse_external_reactions(self):
external_reactions = self.root.find("external_reactions")
for force in external_reactions.findall("force"):
force_name = force.get("name")
force_frame = force.get("frame")
locations = self.get_locations(force)
for _, location in locations.items():
self.plot(f"{force_name} ({force_frame})", location["xyz"], "External Reactions")
In the above code, if the call to self.root.find("external_reactions")
returns None
because the tag is missing, then the call to external_reactions.findall("force")
will fail. Given that the other tags are parsed in the same way, this error will probably also happen for any of the following function calls:
self.parse_metrics()
self.parse_mass_balance()
self.parse_ground_reactions()
self.parse_external_reactions()
self.parse_propulsion()
A solution would be to add a return if find
returns none
in each of the above function calls. This exception is fatal, so any missing tags will result in the rest of the file not being processed. So in this case, if the file does not contain at least an empty external_reactions
block, it will fail to parse the next tag, propulsion
.
https://drive.google.com/file/d/1f4KanBXFz_GyYkdqHqphG1gp2dD_UHfq/view?usp=share_link
A workaround for this is to simply add an empty tag block for the missing tag like the following:
<external_reactions>
</external_reactions>