looooo / freecad.gears

a gear module for freecad
GNU General Public License v3.0
237 stars 95 forks source link

Fixed issue loading old document without traverse_module in gear XML #126

Closed scottmudge closed 9 months ago

scottmudge commented 1 year ago

I had an issue with backward compatibility with loading some old documents which had gears generated by this plugin. At that time, fcgears did not add the traverse_module property to the Involute gears objects, so this property was not written out to the associated object XML.

When these old documents are loaded, these object XMLs are deserialized and loaded, and the default InvoluteGear constructor appears to be bypassed by the time generate_gear_shape() is called.

Because of this, the plugin would crash in compute_traverse_properties(), reporting FeaturePython has no attribute 'traverse_module'...

This PR fixes this by checking if the object has this attribute, and if it doesn't, it adds it within compute_traverse_properties with default values.

Any new properties being added in the future should probably have similar logic added to ensure this kind of thing doesn't occur.

mhindi2 commented 1 year ago

In addition to traverse_module, my features.py file has tests for da, df, head_fillet, root_fillet. I am not sure which of these were not in the old docs, but I am sure there were new properties in addition to traverse_module. I assume a check for those has been added too.