Harness proD API Help
EPLAN.Harness.API.Projects.Documents Namespace / Designer Class / CreatePattern Method
Occurrence from which you want to create a pattern.
Pattern settings.
Use prefix generated from occurrence name?
Use starting index generated from occurrence name?
Example
In This Topic
    CreatePattern Method
    In This Topic
    Create pattern of parts.
    Syntax

    Parameters

    occurrence
    Occurrence from which you want to create a pattern.
    settings
    Pattern settings.
    usePrefixFromOccName
    Use prefix generated from occurrence name?
    useStartingIndexFromOccName
    Use starting index generated from occurrence name?

    Return Value

    Created pattern.
    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.
    This file is not opened.
    You can not perform this action on a document opened as read only.
    Example
    This example shows how to create pattern from a terminal (the object must implements IPatternable interface) with desired settings.
    // Open a designer.
    Designer designer = ...
    designer.Open(false, false);
    
    // Find the terminal
    IOccTerminal terminal = designer.GetAllOccurrences().OfType<IOccTerminal>().FirstOrDefault(t => t.Name.Value == "myFavouriteTerminal");
    
    // All except OddRowOffset will have default values.
    PatternSettings settings = new PatternSettings()
    {
    	OddRowOffset = new LengthProperty(15, Unit.Millimeter)
    };
    
    // Distance between terminals is automatically counted.
    // Prefix and starting index for terminals are generated from name of the terminal.
    IOccPattern pattern = designer.CreatePattern(terminal, settings);
    This example shows how to create pattern from a terminal with desired prefix and starting index.
    // Open a designer.
    Designer designer = ...
    designer.Open(false, false);
    
    // Find the terminal
    IOccTerminal terminal = designer.GetAllOccurrences().OfType<IOccTerminal>().FirstOrDefault(t => t.Name.Value == "myFavouriteTerminal");
    
    // All except of filled will have default values.
    PatternSettings settings = new PatternSettings()
    {
    	Prefix = new TextProperty("Prefix"),
    	StartingIndex = new UnsignedIntegerProperty(45),
    	Separator = new TextProperty("=>")
    };
    
    // Do not generate prefix and starting index from occurrence name.
    IOccPattern pattern = designer.CreatePattern(terminal, settings, false, false);
    This example shows how to create pattern from a terminal with desired distances between terminals.
    // Open a designer.
    Designer designer = ...
    designer.Open(false, false);
    
    // Find the terminal
    IOccTerminal terminal = designer.GetAllOccurrences().OfType<IOccTerminal>().FirstOrDefault(t => t.Name.Value == "myFavouriteTerminal");
    
    // Only distance for Z-axis will be automatically counted.
    PatternSettings settings = new PatternSettings()
    {
    	DistanceX = new LengthProperty(50, Unit.Millimeter),
    	DistanceY = new LengthProperty(30, Unit.Millimeter)
    };
    
    // Do not generate prefix and starting index from occurrence name.
    IOccPattern pattern = designer.CreatePattern(terminal, settings);
    See Also