Harness proD API Help
EPLAN.Harness.API.Occurrences.Workdesk Namespace / OccWdConstraintSimple Class / Toggle Method
Example
In This Topic
    Toggle Method (OccWdConstraintSimple)
    In This Topic
    Toggle (exchange) master and slave occurrences of a constraint.
    Syntax
    public void Toggle()
    Example
    The example shows how to toggle master and slave occurrences of a constraint.
    // Initialize API
    HpdApi api = HpdApi.GetInstance();
    api.Init();
    
    // Open a project and a workdesk.
    Project project = api.OpenProject(@"d:\Harness proD 2.9\Projects\Demo\Demo.hxproj");
    					
    Variant variant = project.GetVariants()[0];
    Designer designer = variant.GetWorkdesks().FirstOrDefault(w => w.Name == "Workdesk_1");
    designer.Open(false, false);
    
    // Select a constraint and togle its master and slave.
    IOccConstraintSimple constraint = workdesk.GetAllOccurrences<IOccConstraintSimple>().FirstOrDefault(c => c.Name == "cp_00026 :: cn_00001");
    constraint.Toggle();
    
    // Save changes and close documents.
    designer.Save();
    designer.Close();
    project.Close();
    See Also