Complex sentence: In the Middle Ages it was transformed into a fortress by the Frangipane family and so survived intact up until 1830, when the attic and top were torn down because they were erroneously believed not to belong to the original structure.
Split into simpler sentences: In the Middle Ages, the Frangipane family transformed the building into a fortress and so it survived intact up until 1830. Then the attic and top were torn down because they were erroneously believed not to belong to the original structure.