According to the relevant information, it is not illegal to donate the patent to the country even if the family does not agree. Patent donation is a very noble act that can promote scientific and technological progress and social development. However, the family does not agree to donate the patent to the state, which would not be illegal. Patent rights belong to the patent applicant or patentee and will only become effective if they voluntarily donate the patent to the state. If your family members disagree, you can respect their opinions, retain ownership of the patent, and continue to enjoy the benefits of the patent. Of course, if you have other ideas or need to consult relevant legal issues, you can consult a professional legal advisor or lawyer.