Beispiel #1
0
        private void buttonRename_Click(object sender, EventArgs e)
        {
            Document doc = CATIA.ActiveDocument;
            //PartDocument partDoc = (PartDocument)doc;
            //Part part = partDoc.Part;
            //HybridShapeFactory factory = (HybridShapeFactory)part.HybridShapeFactory;
            ////Reference objRef = part.CreateReferenceFromObject(_objRef);
            //for (int i = 1; i <= 100000;i++ )
            //{
            //    string sSuffix = i.ToString();
            //    string sName = textBoxSelect.Text + sSuffix;
            //    factory.ChangeFeatureName(_objRef, sName);
            //}
            //Selection select = doc.Selection;
            VisPropertySet visSet = _selection.VisProperties;

            visSet.SetRealColor(255, 255, 0, 0);
            visSet.SetRealColor(0, 255, 0, 0);
            visSet.SetRealColor(0, 0, 255, 0);

            for (int i = 1; i <= 100000; i++)
            {
                double f = 3.14 * 3.14;

                textBoxSelect.Text = i.ToString();

                //Console.Write(i.ToString());
            }
        }
        private void CheckRepeat(Selection SelectArc)
        {
            bool BoorkRepeart = false;

            if (RepeatNum > 0)
            {
                VisPropertySet VPS = SelectArc.VisProperties;
                SelectArc.Clear();
                foreach (var item in GetRepeatRef)
                {
                    if (item == null)
                    {
                        continue;
                    }
                    try
                    {
                        SelectArc.Add(item);// 标记重复点
                        BoorkRepeart = true;
                    }
                    catch (Exception e)
                    {
                        // MessageBox.Show("准备为您标记重复焊点,但是基于以下原因操作失败!"+e.Message);
                        BoorkRepeart = false;
                    }
                }
                VPS.SetRealColor(255, 0, 128, 0);
                MessageBox.Show(BoorkRepeart ? "当前选择的对象集中存在: " + RepeatNum + "个重复数据!并已为你进行颜色标记!" : "当前选择的对象集中存在: " + RepeatNum + "个重复数据!标记失败!");
                RepeatNum = 0;
                Array.Clear(GetRepeatRef, 0, GetRepeatRef.Length);
            }
        }
Beispiel #3
0
 private void CheckRepeat(Selection SelectArc)
 {
     if (RepeatNum > 0)
     {
         VisPropertySet VPS = SelectArc.VisProperties;
         SelectArc.Clear();
         foreach (var item in GetRepeatRef)
         {
             if (item == null)
             {
                 continue;
             }
             SelectArc.Add(item);
         }
         VPS.SetRealColor(255, 0, 128, 0);
         MessageBox.Show("当前选择的对象集中存在: " + RepeatNum + "个重复数据!并已为你进行颜色标记!");
         RepeatNum = 0;
         Array.Clear(GetRepeatRef, 0, GetRepeatRef.Length);
     }
 }
        //子线程中
        private void Creat3dBall_Click(object sender, EventArgs e)//Creat3dPoint_Click
        {
            progressBar.Value           = 0;
            DataGrid.AllowUserToAddRows = false;
            if (PartID == null)
            {
                MessageBox.Show("仿真环境未初始化!请先用工具栏初始化命令初始化运行环境!");
                return;
            }
            Creat3dBall.BackColor = SystemColors.ActiveCaption;
            ReadType = 2;
            int ERR = 0;

            if (DataGrid.RowCount < 1)
            {
                MessageBox.Show("数据为空,无法建立3D模型!");
                return;
            }
            HybridBodies Hybs = PartID.HybridBodies;
            HybridBody   Hyb  = null;

            //try
            //{
            //    Hyb = Hybs.Item("几何图形集.1");
            //}
            //catch (Exception)
            //{
            //    Hyb = Hybs.Item("Geometrical Set.1");
            //}
            progressBar.Maximum = DataGrid.RowCount;
            progressBar.Step    = 1;
            Hyb = Hybs.Add();
            for (int i = 0; i < DataGrid.RowCount; i++)
            {
                progressBar.PerformStep();
                HybridShapeFactory PartHyb = (HybridShapeFactory)PartID.HybridShapeFactory;
                //SPAWorkbench TheSPAWorkbench = (SPAWorkbench)CatDocument.GetWorkbench("SPAWorkbench");
                //Reference referenceObject = SelectArc.Item(i).Reference;
                //Measurable TheMeasurable = TheSPAWorkbench.GetMeasurable(referenceObject);
                //TheMeasurable.GetPoint(PointCoord); //读取选择的曲面坐标
                string TName;
                try
                {
                    TName = DataGrid.Rows[i].Cells[1].Value.ToString(); //读取选择的曲面名称
                }
                catch (Exception)
                {
                    continue;
                }
                HybridShapePointCoord NewPoint = PartHyb.AddNewPointCoord(Convert.ToDouble(DataGrid.Rows[i].Cells[2].Value.ToString()), Convert.ToDouble(DataGrid.Rows[i].Cells[3].Value.ToString()), Convert.ToDouble(DataGrid.Rows[i].Cells[4].Value.ToString()));
                Reference             ShapeRef = PartID.CreateReferenceFromObject(NewPoint);
                HybridShapeSphere     NewShape = PartHyb.AddNewSphere(ShapeRef, null, Convert.ToDouble(BallRadio.Text), -45.000000, 45.000000, 0.000000, 180.000000);
                NewShape.Limitation = 1;
                if (KeepName.Checked)
                {
                    NewPoint.set_Name(TName);
                    NewShape.set_Name(TName);
                }
                else
                {
                    NewPoint.set_Name("Rx_" + (i + 1));
                    NewShape.set_Name("Rx_" + (i + 1));
                }
                // Hyb.AppendHybridShape(NewPoint);
                Hyb.AppendHybridShape(NewShape);
                //  PartID.InWorkObject = NewPoint;
                PartID.InWorkObject = NewShape;
                try
                {
                    PartID.Update();
                }
                catch (Exception)
                {
                    ERR += 1;
                }
                Selection      SetColor = CatDocument.Selection;
                VisPropertySet VSet     = SetColor.VisProperties;
                SetColor.Add(NewShape);
                VSet.SetRealColor(128, 255, 0, 0);
                SetColor.Clear();
            }
            if (ERR > 0)
            {
                MessageBox.Show("共计:" + ERR + "个点创建新参考点失败!");
            }
            Creat3dBall.BackColor = Color.Green;
            ShowCenter();
            progressBar.Value = DataGrid.RowCount;
        }