instead of setting the level *property*, you could try to set the level *parameter*.
Depending on the type and category of the element you want to modify, you could set the BuiltInParameter.FAMILY_LEVEL_PARAM (for FamilyInstances), for example.
Use RevitLookup to get the level parameters for other kinds of elements.
Level params usually are set with an ElementId:
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register