Exemplo n.º 1
0
    void SetEactElec(Snap.NX.Body body, Snap.NX.Face baseFace = null, Snap.NX.Face topFace = null, Snap.NX.Point basePoint = null)
    {
        selectBaseFace.SelectedObjects = new Snap.NX.NXObject[] { };
        selectTopFace.SelectedObjects  = new Snap.NX.NXObject[] { };
        selectBaseFacePointEx.Position = new Snap.Position();
        var pos = new Snap.Position();

        ElecManage.Electrode.GetEactElectrode(body, ref topFace, ref baseFace, ref basePoint, ref pos);
        if (baseFace != null)
        {
            selectBaseFace.SelectedObjects = new Snap.NX.NXObject[] { baseFace };
        }
        if (topFace != null)
        {
            selectTopFace.SelectedObjects = new Snap.NX.NXObject[] { topFace };
        }
        selectBaseFacePointEx.Position = pos;
        if (baseFace != null && topFace != null)
        {
            //更新尺寸
            var info = GetElecInfo(body);
            if (info != null)
            {
                strElecSize.Value        = info.ElecSize;
                strElecCuttingSize.Value = info.ElecCuttingSize(_configData, EactConfig.MatchJiaju.GetMatchJiajuValue(_configData, cbbChuckType.SelectedIndex));
            }
            else if (groupSElec.Show) //异形电极
            {
                var tempInfo = new ElecManage.ElectrodeInfo(body);
                var tempOri  = new Snap.Orientation(-baseFace.GetFaceDirection());
                strElecSize.Value        = tempInfo.GetElecSize(tempOri);
                strElecCuttingSize.Value = tempInfo.ElecCuttingSize(_configData, EactConfig.MatchJiaju.GetMatchJiajuValue(_configData, cbbChuckType.SelectedIndex), tempOri);
            }
            else
            {
                strElecSize.Value        = string.Empty;
                strElecCuttingSize.Value = string.Empty;
            }
        }
    }
Exemplo n.º 2
0
    public override void Update(NXOpen.BlockStyler.UIBlock block)
    {
        if (block == selectCuprum.NXOpenBlock)
        {
            var cuprums = Enumerable.Select(selectCuprum.SelectedObjects, u => Snap.NX.Body.Wrap(u.NXOpenTag)).ToList();
            var unNameC = cuprums.Where(u => string.IsNullOrEmpty(u.Name)).ToList();
            var nameC   = cuprums.Where(u => !string.IsNullOrEmpty(u.Name)).ToList();

            groupSElec.Show = false;
            var groupSElecShow = false;
            if (nameC.Count == 1)
            {
                var body = nameC.First();
                var info = GetElecInfo(body);
                groupSElecShow = info == null || info.IsSpecialShapeElec == "1";
                if (info == null)
                {
                    info = new ElecManage.EactElectrodeInfo(body);
                }

                if (_configData.Edition == 1)
                {
                    if ((info.KL_SIZE_HEIGHT == 0 || info.KL_SIZE_LEN == 0 || info.KL_SIZE_WIDTH == 0))
                    {
                        theUI.NXMessageBox.Show("提示", NXOpen.NXMessageBox.DialogType.Error, "该电极未设置开料尺寸!");
                        selectCuprum.SelectedObjects = new Snap.NX.NXObject[] { };
                        return;
                    }

                    if (string.IsNullOrEmpty(info.ELEC_CLAMP_GENERAL_TYPE))
                    {
                        theUI.NXMessageBox.Show("提示", NXOpen.NXMessageBox.DialogType.Error, "该电极未设置夹具!");
                        selectCuprum.SelectedObjects = new Snap.NX.NXObject[] { };
                        return;
                    }
                }

                SetDefaultValue(info);
                Action <bool> action = (b) =>
                {
                    groupSElec.Show = b;
                    if (b)
                    {
                        theUI.NXMessageBox.Show("提示", NXOpen.NXMessageBox.DialogType.Information, "异形电极,请设置相关参数!");
                        SetEactElec(body);
                    }
                };

                if (SpecialshapedElec)
                {
                    action(groupSElecShow);
                }
            }
            else if (SpecialshapedElec && unNameC.Count > 0)
            {
                theUI.NXMessageBox.Show("提示", NXOpen.NXMessageBox.DialogType.Information, "电极名称不能为空");
                selectCuprum.SelectedObjects = cuprums.Where(u => !string.IsNullOrEmpty(u.Name)).ToArray();
            }
            else if (SpecialshapedElec && nameC.Count > 1)
            {
                var lstMsg    = new List <string>();
                var tempNameC = nameC.Where(u => !_elecNameLst.Contains(u.Name));
                foreach (var item in tempNameC.GroupBy(u => u.Name))
                {
                    var body = item.First();
                    var info = GetElecInfo(body);
                    if (info == null)
                    {
                        lstMsg.Add(string.Format("{0}:{1}", body.Name, "异形电极"));
                        selectCuprum.SelectedObjects = cuprums.Where(u => u.Name != body.Name).ToArray();
                    }
                }
                if (lstMsg.Count > 0)
                {
                    Snap.InfoWindow.Clear();
                    lstMsg.ForEach(u => { Snap.InfoWindow.WriteLine(u); });
                }
            }

            if (_isAllowMultiple)
            {
                if (nameC.Count > 1)
                {
                    strElecName.Show = false;
                }
                else
                {
                    strElecName.Show = true;
                }

                if (cuprums.Count != 1)
                {
                    selectCuprum.AllowMultiple = true;

                    if (unNameC.Count > 0)
                    {
                        theUI.NXMessageBox.Show("提示", NXOpen.NXMessageBox.DialogType.Information, "电极名称不能为空");
                        selectCuprum.SelectedObjects = cuprums.Where(u => !string.IsNullOrEmpty(u.Name)).ToArray();
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(cuprums.First().Name))
                    {
                        selectCuprum.AllowMultiple = false;
                    }
                    else if (groupSElecShow)
                    {
                        selectCuprum.AllowMultiple = false;
                    }
                    else
                    {
                        selectCuprum.AllowMultiple = true;
                    }
                }
            }

            strElecSize.Show        = strElecName.Show;
            strElecCuttingSize.Show = strElecName.Show;
        }
        else if (block == cbbChuckType.NXOpenBlock ||
                 block == selectBaseFace.NXOpenBlock
                 //|| block == selectBaseFacePointEx.NXOpenBlock
                 || block == selectTopFace.NXOpenBlock
                 )
        {
            var cuprums = Enumerable.Select(selectCuprum.SelectedObjects, u => Snap.NX.Body.Wrap(u.NXOpenTag)).ToList();
            if (cuprums.Count == 1)
            {
                var info = GetElecInfo(cuprums.First());
                if (info != null)
                {
                    strElecSize.Value        = info.ElecSize;
                    strElecCuttingSize.Value = info.ElecCuttingSize(_configData, EactConfig.MatchJiaju.GetMatchJiajuValue(_configData, cbbChuckType.SelectedIndex));
                }
                else if (groupSElec.Show) //异形电极
                {
                    var tempInfo    = new ElecManage.ElectrodeInfo(cuprums.First());
                    var tempFaceDir = -Snap.Orientation.Identity.AxisZ;
                    var baseFace    = selectBaseFace.SelectedObjects.FirstOrDefault() as Snap.NX.Face;
                    if (baseFace != null)
                    {
                        tempFaceDir = -baseFace.GetFaceDirection();
                    }
                    var tempOri = new Snap.Orientation(tempFaceDir);
                    strElecSize.Value        = tempInfo.GetElecSize(tempOri);
                    strElecCuttingSize.Value = tempInfo.ElecCuttingSize(_configData, EactConfig.MatchJiaju.GetMatchJiajuValue(_configData, cbbChuckType.SelectedIndex), tempOri);
                }
                else
                {
                    strElecSize.Value        = string.Empty;
                    strElecCuttingSize.Value = string.Empty;
                }
            }
        }
        else if (block == selectBaseFace.NXOpenBlock ||
                 block == selectBaseFacePointEx.NXOpenBlock ||
                 block == selectTopFace.NXOpenBlock
                 )
        {
            //var cuprums = Enumerable.Select(selectCuprum.SelectedObjects, u => Snap.NX.Body.Wrap(u.NXOpenTag)).ToList();
            //if (cuprums.Count == 1)
            //{
            //    var basePoint = Enumerable.Select(selectBaseFacePoint.SelectedObjects, u => Snap.NX.Point.Wrap(u.NXOpenTag)).FirstOrDefault();
            //    var baseFace = Enumerable.Select(selectBaseFace.SelectedObjects, u => Snap.NX.Face.Wrap(u.NXOpenTag)).FirstOrDefault();
            //    var topFace = Enumerable.Select(selectTopFace.SelectedObjects, u => Snap.NX.Face.Wrap(u.NXOpenTag)).FirstOrDefault();
            //    SetEactElec(cuprums.FirstOrDefault(),baseFace,topFace, basePoint);
            //}
        }
    }