Harness proD API Help
EPLAN.Harness.API.Occurrences.Interfaces Namespace / ILibraryOccurrence Interface / Manufacturer Property
Example
In This Topic
    Manufacturer Property (ILibraryOccurrence)
    In This Topic
    Gets or sets the manufacturer's company name and the part number of this occurrence.
    Syntax
    LibraryPartNumber Manufacturer {get; set;}
    Exceptions
    ExceptionDescription
    Api is not in an initialized state. You can get current state from EPLAN.Harness.API.HpdApi.Status property. If API is uninitialized, you can initialize it by calling EPLAN.Harness.API.HpdApi.Init method. If API is in failed state, you can not resurrect it.
    The object is in invalid state. Obtain a new one.
    The exception that is thrown when you trying to access to already deleted occurrence.
    Thrown when this property does not exist in this context.
    Example
    This example shows how to set a new manufacturer for an occurrence.
    // 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);
    
    // Obtain the occurrence.
    ILibraryOccurrence connector = designer.GetAllOccurrences().OfType<ILibraryOccurrence>().FirstOrDefault(o => o.Name == "cn_00002");
    if (connector == null)
    {
    	// Resolve this issue.
    }
    
    // Get all available manufacturers and their part numbers.
    IEnumerable<LibraryPartNumber> manufacturers = connector.LibraryPart.PartNumbers.Where(p => p.Type == ApiPartNumberType.Manufacturer);
    
    // Find the desired manufacturer.
    LibraryPartNumber desiredManufacturer = manufacturers?.FirstOrDefault(m => m.Company == "PXC");
    if (desiredManufacturer == null)
    {
    	// Resolve this issue.
    }
    
    // Set the desired manufacturer on the current occurrence.
    connector.Manufacturer = desiredManufacturer;
    
    // Save changes and close documents.
    designer.Save();
    
    designer.Close();
    project.Close();
    See Also