A single-crystal to single-crystal transition from a 7-fold interpenetrated coordination polymer to a non-interpenetrated one by photochemical [2 + 2] polymerization and their sensing properties.