コード例 #1
0
        public void GetData()
        {
            MyEntity = TechnologicalProcess.GetEntity("请选择实体!");
            if (MyEntity != null)
            {
                ResultBuffer tvList = new ResultBuffer()
                {
                    new TypedValue((int)DxfCode.Text, "写个1进去!"),
                    new TypedValue((int)DxfCode.Text, "写个2进去!"),
                    new TypedValue((int)DxfCode.Text, "写个3进去!"),
                };
                ExtendedDataHelper.ModObjXrecord(MyEntity.ObjectId, "Test", tvList);                     //写扩展属性

                ResultBuffer resultBuffer = ExtendedDataHelper.GetObjXrecord(MyEntity.ObjectId, "Test"); //读扩展属性
                if (resultBuffer != null)
                {
                    var array = resultBuffer.AsArray();
                    if (array != null)
                    {
                        foreach (var content in array)
                        {
                            System.Windows.Forms.MessageBox.Show(content.Value.ToString());
                        }
                    }
                }

                bool isSuccess = ExtendedDataHelper.DelObjXrecord(MyEntity.ObjectId, "Test");//删除扩展属性
                if (isSuccess)
                {
                    System.Windows.Forms.MessageBox.Show("删除成功!");
                }
            }
        }
コード例 #2
0
 public string GetEmployeesExtendedData(string extendedDataInfo)
 {
     return(ExtendedDataHelper.GetExtendedData(CurrentDataSource.Employees, extendedDataInfo));
 }
コード例 #3
0
        internal static void GetPolyline(string num, string factor, string individualName, string stage, int index, ref System.Windows.Forms.DataGridView dataGridView1)
        {
            string   polylineId = "";
            Document doc        = Application.DocumentManager.MdiActiveDocument;
            Editor   ed         = doc.Editor;
            Database db         = doc.Database;

            DocumentLock m_DocumentLock = Application.DocumentManager.MdiActiveDocument.LockDocument();

            try
            {
                //PromptSelectionResult acSSPrompt = ed.GetSelection();
                Entity acSSObj = null;
                while (true)
                {
                    using (Transaction tr = db.TransactionManager.StartTransaction())
                    {
                        //让CAD获取焦点
                        SetFocus(Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Window.Handle);
                        acSSObj = TechnologicalProcess.GetEntity("请选择多段线!");
                        bool changeData = false;
                        if (acSSObj != null && acSSObj is Polyline)
                        {
                            //如果扩展字典中已包含指定的扩展记录对象
                            ResultBuffer resultBuffer = ExtendedDataHelper.GetObjXrecord(acSSObj.ObjectId, "polylineNumber");//读扩展属性
                            if (resultBuffer != null)
                            {
                                if (System.Windows.Forms.DialogResult.Yes == System.Windows.Forms.MessageBox.Show("多段线已定义个体,是否覆盖信息!", "消息", System.Windows.Forms.MessageBoxButtons.YesNo))
                                {
                                    changeData = true;
                                }
                            }
                            else
                            {
                                changeData = true;
                            }
                            if (changeData) //若没有包含扩展记录,则创建一个
                            {
                                ResultBuffer valueBuffer = new ResultBuffer();
                                valueBuffer.Add(new TypedValue((int)DxfCode.Text, num));
                                valueBuffer.Add(new TypedValue((int)DxfCode.Text, factor));
                                valueBuffer.Add(new TypedValue((int)DxfCode.Text, individualName));
                                valueBuffer.Add(new TypedValue((int)DxfCode.Text, stage));

                                ExtendedDataHelper.ModObjXrecord(acSSObj.ObjectId, "polylineNumber", valueBuffer); //写扩展属性

                                polylineId = acSSObj.ObjectId.Handle.Value.ToString();                             // +",";
                                //System.Windows.Forms.MessageBox.Show("添加成功");
                            }
                        }
                        else if (acSSObj == null)
                        {
                            tr.Commit();
                            break;
                        }

                        //去除已添加的id
                        if (changeData && dataGridView1.Rows.Count > 0)
                        {
                            //string[] vals = value.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                            System.Windows.Forms.DataGridViewRow deleteRow = null;
                            foreach (System.Windows.Forms.DataGridViewRow item in dataGridView1.Rows)
                            {
                                string gridData = ((string)item.Cells[0].Value);
                                if (gridData != null)
                                {
                                    //foreach (var val in vals)
                                    //{
                                    if (gridData.Contains(polylineId))
                                    {
                                        if (gridData.IndexOf(polylineId + ",") >= 0)
                                        {
                                            gridData = gridData.Replace(polylineId + ",", "");
                                        }
                                        else
                                        {
                                            gridData = gridData.Replace(polylineId, "");
                                        }
                                        int factorcount = 0;
                                        int.TryParse((string)item.Cells["entitycount"].Value, out factorcount);
                                        item.Cells["entitycount"].Value = (factorcount - 1).ToString();

                                        System.Windows.Forms.Application.DoEvents();

                                        if (factorcount == 1 && index != item.Index)
                                        {
                                            deleteRow = item;
                                        }
                                    }
                                    //}
                                    item.Cells[0].Value = gridData;
                                }
                            }

                            dataGridView1.Rows[index].Cells[0].Value += polylineId + ",";

                            //更新数量
                            int count = 0;
                            int.TryParse((string)dataGridView1.Rows[index].Cells["entitycount"].Value, out count);
                            dataGridView1.Rows[index].Cells["entitycount"].Value = (count + 1).ToString();
                            System.Windows.Forms.Application.DoEvents();
                            if (deleteRow != null)
                            {
                                dataGridView1.Rows.Remove(deleteRow);
                            }
                        }

                        tr.Commit();
                    }
                }
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.ToString());
            }
            finally
            {
                m_DocumentLock.Dispose();
            }
        }
コード例 #4
0
 public string GetProductsExtendedData(string extendedDataInfo)
 {
     return(ExtendedDataHelper.GetExtendedData(CurrentDataSource.Products, extendedDataInfo));
 }