cadplayer 发表于 2015-5-12 02:48:24

获取PipeNetwork对象

你好
我从pipenetwork请求数据几乎没有问题,尤其是对于没有构造函数的Network类。但是我应该如何获得它们的对象。

      public void PipeProp()
      {
            CivilDocument doc = CivilApplication.ActiveDocument;
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
         
            // Ask the user to select a Pipeline
            PromptEntityOptions opt = new PromptEntityOptions("\nSelect a pipe");
            opt.SetRejectMessage("\nObject must be a pipeline.");
            opt.AddAllowedClass(typeof(Pipe), false);
            PromptEntityResult res = ed.GetEntity(opt);
            if (res.Status != PromptStatus.OK) return;
            Database db = Application.DocumentManager.MdiActiveDocument.Database;
            using (Transaction ts = db.TransactionManager.StartTransaction())
            {
                // Get PartDataRecord for first pipe in the network
                Network oNetwork = new Network();
                ObjectId pipeId = oNetwork.GetPipeIds();
                Pipe oPipe = ts.GetObject(pipeId, OpenMode.ForRead) as Pipe;
                PartDataField[] oDataFields = oPipe.PartData.GetAllDataFields();
                ed.WriteMessage("Additional info for pipe: {0}\n", oPipe.Name);
                foreach (PartDataField oPartDataField in oDataFields)
                {
                  ed.WriteMessage("Name: {0}, Description: {1}, DataType: {2}, Value: {3}\n",
                  oPartDataField.Name,
                  oPartDataField.Description,
                  oPartDataField.DataType,
                  oPartDataField.Value);
                }
            }
      }
**** Hidden Message *****

cadplayer 发表于 2015-5-12 07:15:35

我解决了这个问题代码1]
页: [1]
查看完整版本: 获取PipeNetwork对象