Eplan Platform API
EPLAN API / User Guide / API Higher Electrotechnical services / Placing window macros
In This Topic
    Placing window macros
    In This Topic

    An EPLAN macro is a piece of schematics, which can be introduced into a project -- onto a page or as a page. EPLAN uses file macros. They can have the extension .ema - for window macros, .emp - for page macros, and .ems for symbol macros. 

    For placing macros, the EPLAN API provides the class Eplan.EplApi.HEServices.Insert. The class basically contains three overloaded methods for placing each type of macro. A window or symbol macro can either be placed on a page at absolute coordinates or with an offset relatively to its original position. 

     

    The following example shows how to place a macro on page at a given position:  

    C#
    Copy Code
    Insert oInsert = new Insert();
    oInsert.WindowMacro("$(MD_MACROS)\BECK.KL1012.ema", 0, m_oTestProject.Pages[9], new PointD(70.0, 0.0), Insert.MoveKind.Relative);
    

    Placing macros and assigning value sets

    If there are PlaceHolders objects in a macro, you can assign value sets by using result from Insert.WindoMacro function : 

     

    C#
    Copy Code
            Insert oInsert = new Insert();
            StorableObject[] oInsertedObjects = oInsert.WindowMacro(@"$(MD_MACROS)MacroWithPlaceholder.ema", 0, m_oTestProject.Pages[9], new PointD(70.0, 0.0), Insert.MoveKind.Relative);
    
            foreach (StorableObject oSOTemp in oInsertedObjects)
            {
                //we are searching for PlaceHolder 'Three-Phase' in the results
                 PlaceHolder oPlaceHoldeThreePhase = oSOTemp  as Eplan.EplApi.DataModel.Graphics.PlaceHolder;
                if((oPlaceHoldeThreePhase != null)
                    &&
                    (oPlaceHoldeThreePhase.Name == "Three-Phase")
                    )
                 {
                     oPlaceHoldeThreePhase.ApplyRecord("Motor 0,75 KW");
                 }
            }