예제 #1
0
        private void btnBOMAddNewPart_Click(object sender, EventArgs e)
        {
            Function targetFunction = ((EplanFunctionViewModel)this.cBoxBOMFunctions.SelectedItem).Function;

            if (targetFunction == null)
            {
                return;
            }

            string selectedPartNumber  = string.Empty;
            string selectedPartVariant = string.Empty;

            new EplApplication().ShowPartSelectionDialog(ref selectedPartNumber, ref selectedPartVariant);

            if (this._logger.IsDebugEnabled)
            {
                this._logger.DebugFormat("btnBOMAddNewPart_Click(), selectedPartNumber=[{0}], selectedPartVariant=[{1}]", selectedPartNumber, selectedPartVariant);
            }

            if (string.IsNullOrEmpty(selectedPartNumber))
            {
                return;
            }

            if (string.IsNullOrEmpty(selectedPartVariant))
            {
                targetFunction.AddArticleReference(selectedPartNumber);
            }
            else
            {
                targetFunction.AddArticleReference(selectedPartNumber, selectedPartVariant, 1, true);
            }

            // Refresh Part Reference List
            RefreshPartReferenceList(this.cBoxBOMFunctions);

            // Refresh Drawing
            ApiExtHelpers.RefreshDrawing();
        }
예제 #2
0
        public static string InsertSymbol(ref Page refPage, EplSymbolProperties symbolProperties)
        {
            string msg = EplDefinition.EPL_INSERT_SYMBOL_MCR.ToString();

            try
            {
                using (LockingStep oLS = new LockingStep())
                {
                    refPage.Project.LockAllObjects();
                    SymbolLibrary symboLib       = new SymbolLibrary(refPage.Project, symbolProperties.SymbolLibraryName);
                    Symbol        symbol         = new Symbol(symboLib, symbolProperties.SymbolName);
                    SymbolVariant oSymbolVariant = new SymbolVariant();
                    oSymbolVariant.Initialize(symbol, symbolProperties.SymbolVariant);
                    Function function = new Function();
                    function.Create(refPage, oSymbolVariant);
                    //function.Properties.FUNC_SYMB_DESC = symbolProperties.SymbolDescription;
                    if (!string.IsNullOrEmpty(symbolProperties.PartName))
                    {
                        function.AddArticleReference(symbolProperties.PartName);
                    }
                    function.VisibleName                 = symbolProperties.DisplayText;
                    function.Properties.FUNC_TEXT        = symbolProperties.FunctionText;
                    function.Location                    = symbolProperties.Location;
                    function.Properties.FUNC_GRAVINGTEXT = symbolProperties.EngravingText;
                    function.Properties.FUNC_TECHNICAL_CHARACTERISTIC = symbolProperties.Characteristics;
                    if (symbolProperties.ConnectionDesignations != null)
                    {
                        for (int i = 0; i < symbolProperties.ConnectionDesignations.Length; i++)
                        {
                            function.Properties.FUNC_CONNECTIONDESIGNATION[i + 1] = symbolProperties.ConnectionDesignations[i];
                            if (symbolProperties.ConnectionPointDescription != null)
                            {
                                if (symbolProperties.ConnectionPointDescription.Length > i)
                                {
                                    function.Properties.FUNC_CONNECTIONDESCRIPTION[i + 1] = symbolProperties.ConnectionPointDescription[i];
                                }
                            }
                        }
                    }
                    function.Properties.FUNC_MOUNTINGLOCATION = symbolProperties.MountingSite;
                }
            }
            catch (Exception ex)
            {
                EplException("Insert symbol error.", ex);
                msg = EplError.EPL_ERROR.ToString();
            }

            return(msg);
        }