// Init API
HpdApi api = HpdApi.GetInstance();
// Open project and variant and document.
Project project = api.OpenProject(@"d:\MyProject.hxproj");
Variant variant = project.GetVariants()[0];
Designer designer = variant.GetWorkdesks().FirstOrDefault(w => w.Name == "Workdesk_2");
designer.Open(false, false);
// Select a desired occurrence.
IOccurrence occ = designer.GetAllOccurrences().FirstOrDefault(o => o.Name == "fuse_00001");
// Create 2 new user defined properties.
UserDefinedProperty udp1 = new UserDefinedProperty("Fuse response", new TextProperty("Fast"));
UserDefinedProperty udp2 = new UserDefinedProperty("Voltage", new VoltageProperty(250d, Unit.Volt));
// Add them to the occurrence.
occ.UserDefinedProperties.Add(udp1);
occ.UserDefinedProperties.Add(udp2);
// Save changes and close documents.
designer.Save();
designer.Close();
project.Close();