public IEnumerable<IOccCableUnit> CreateCableUnits( ApiCableUnitGeneratorSettings settings )
Parameters
- settings
- Defines which cables to use and how to create the cable units.
Return Value
Created cable units.
public IEnumerable<IOccCableUnit> CreateCableUnits( ApiCableUnitGeneratorSettings settings )
Exception | Description |
---|---|
EPLAN.Harness.API.Exceptions.ArgumentNullException | Argument is null. |
EPLAN.Harness.API.Exceptions.HpdApiNotInitializedException | Api is not in an initialized state. You can get current state from EPLAN.Harness.API.Studio.Status property. If API is uninitialized, you can initialize it by calling EPLAN.Harness.API.Studio.Init method. If API is in failed state, you can not resurrect it. |
Studio api = Studio.GetInstance(); api.Init(@"C:\Program Files\EPLAN\EPLAN Harness proD 2022"); // Open project and variant and document. Project project = api.OpenProject(@"C:\Users\user\Documents\Harness proD 2022\Projects\My project.hxproj"); Variant variant = project.GetVariants()[0]; Designer designer = variant.GetWorkspaces().FirstOrDefault(wsp => wsp.Name == "Workspace 1"); designer.Open(false, false); // Select a desired occurrence. List<Cable>cables = designer.GetAllOccurrences().OfType<ICable>().ToList(); ApiCableUnitGeneratorSettings settings = new ApiCableUnitGeneratorSettings(true, true, true, true, true, true, true, cables); designer.CreateCableUnits(settings); // Save changes and close documents. designer.Save(); designer.Close();