public static string InsertDevice(this Page page, string lib, string symbol, string part, string DT, PointD location,
                                          string functionT, string characteristic, string engravingT, string mountingT,
                                          string[] connections = null, string[] connectionDes = null)
        {
            var deviceP = new EplDeviceProperties
            {
                SymbolLibraryName = lib,
                SymbolName        = symbol,
                SymbolVariant     = 0,
                PartName          = part,
                Characteristics   = characteristic,
                FunctionText      = functionT,
                EngravingText     = engravingT,
                MountingSite      = mountingT,
                DisplayText       = DT,
                Location          = location,
            };

            if (connections != null)
            {
                deviceP.ConnectionDesignations = connections;
            }

            if (connectionDes != null)
            {
                deviceP.ConnectionPointDescription = connectionDes;
            }

            return(EplExtension.InsertDevice(ref page, deviceP));
        }
        public static string InsertDevice(ref Page refPage, EplDeviceProperties deviceProperties)
        {
            string msg = EplDefinition.EPL_INSERT_DEVICE.ToString();

            try
            {
                using (LockingStep oLS = new LockingStep())
                {
                    refPage.Project.LockAllObjects();
                    BoxedDevice   oBoxedDevice = new BoxedDevice();
                    string        slib         = string.IsNullOrEmpty(deviceProperties.SymbolLibraryName) ? "GB_symbol" : deviceProperties.SymbolLibraryName;
                    SymbolLibrary sLibrary     = new SymbolLibrary(refPage.Project, slib);
                    Symbol        s            = new Symbol(sLibrary, deviceProperties.SymbolName);
                    SymbolVariant sv           = new SymbolVariant();
                    sv.Initialize(s, 0);
                    oBoxedDevice.Create(refPage);
                    oBoxedDevice.SymbolVariant = sv;
                    //oBoxedDevice.Properties.FUNC_DES = deviceProperties.SymbolDescription;
                    if (!string.IsNullOrEmpty(deviceProperties.PartName))
                    {
                        oBoxedDevice.AddArticleReference(deviceProperties.PartName);
                    }
                    oBoxedDevice.VisibleName                 = deviceProperties.DisplayText;
                    oBoxedDevice.Properties.FUNC_TEXT        = deviceProperties.FunctionText;
                    oBoxedDevice.Location                    = deviceProperties.Location;
                    oBoxedDevice.Properties.FUNC_GRAVINGTEXT = deviceProperties.EngravingText;
                    oBoxedDevice.Properties.FUNC_TECHNICAL_CHARACTERISTIC = deviceProperties.Characteristics;
                    if (deviceProperties.ConnectionDesignations != null)
                    {
                        for (int i = 0; i < deviceProperties.ConnectionDesignations.Length; i++)
                        {
                            oBoxedDevice.Properties.FUNC_CONNECTIONDESIGNATION[i + 1] = deviceProperties.ConnectionDesignations[i];
                            if (deviceProperties.ConnectionPointDescription != null)
                            {
                                if (deviceProperties.ConnectionPointDescription.Length > i)
                                {
                                    oBoxedDevice.Properties.FUNC_CONNECTIONDESCRIPTION[i + 1] = deviceProperties.ConnectionPointDescription[i];
                                }
                            }
                        }
                    }
                    oBoxedDevice.Properties.FUNC_MOUNTINGLOCATION = deviceProperties.MountingSite;
                }
            }
            catch (Exception ex)
            {
                EplException("Insert device error.", ex);
                msg = EplError.EPL_ERROR.ToString();
            }
            return(msg);
        }