Пример #1
0
        public NxOperation(NXOpen.CAM.Operation operation, NxOperationGroup nxOperationGroup)
        {
            if (operation == null)
            {
                throw new Exception("Получение операций. Объект не является типом операция.");
            }

            Operation = operation;

            //String n = Operation.Name;
            System.Type t = Operation.GetType();

            UF_TYPE_OPERATION_NAME = t.Name;// if SurfaceContour

            _operationGroup = nxOperationGroup;

            ufs = NxSession.Ufs;
            if (ufs == null)
            {
                throw new Exception("Не удалось получить сессию пользовательских функций NX.");
            }

            GetParams();
            // GetCutterTool(); <--перенёс в метод GetParams()
            GetCutterInsertTypeStr();
            GetChanellNumber();
        }
Пример #2
0
        private void GetOperationAttributes(List <TaggedObject> taggedObjects)
        {
            var group      = new NxOperationGroup(taggedObjects, "<null>");
            var operations = group.NxOperations.GroupBy(op => op.CUTTER_TAG).Select(gr => gr.First()).ToList();

            var type   = typeof(UFConstants);
            var fields = type.GetFields()
                         .Select(f => new { Name = f.Name, Value = f.GetValue(null), FieldType = f.FieldType }).ToList();

//            var list = new List<string>();
            var lw = Session.ListingWindow;

            lw.Open();
            foreach (var operation in operations)
            {
                lw.WriteFullline(new string('=', 80));
                lw.WriteFullline(operation.UF_PARAM_TL_DESCRIPTION);

                var operationFields = operation.RequiredParams
                                      .Where(p => fields.Where(f => f.Value is int).Any(f => (int)f.Value == p))
                                      .Select(p => fields.Where(f => f.Value is int).FirstOrDefault(f => (int)f.Value == p))
                                      .Where(f => f != null).ToList();

                foreach (var operationField in operationFields)
                {
                    var val = "";
                    try
                    {
                        val = operation.GetStrParams((int)operationField.Value);
                    }
                    catch (Exception)
                    {
                        try
                        {
                            val = operation.GetDblParams((int)operationField.Value).ToString();
                        }
                        catch (Exception)
                        {
                            try
                            {
                                val = operation.GetIntParams((int)operationField.Value).ToString();
                            }
                            catch (Exception)
                            {
                                // ignored
                            }
                        }
                    }
                    if (string.IsNullOrEmpty(val))
                    {
                        continue;
                    }

                    //var s = string.Format("Parameter: {0} \t\t\t| Index: {1} \t\t\t| Value: {2}", operationField.Name, operationField.Value, val);
                    var s = string.Format("Parameter: {0, -50} | Index: {1, -10} | Value: {2}", operationField.Name, operationField.Value, val);
                    lw.WriteFullline(s);
                }
            }

            //list.ForEach(s => Session.ListingWindow.WriteLine(s));
        }