예제 #1
0
        /// <summary>
        /// 通过modelPoint查找model,修改model顶点,塞回数据源
        /// </summary>
        /// <param name="fdbPath"></param>
        void editModleNodeCoord(string fdbPath)
        {
            IConnectionInfo ci = new ConnectionInfo();

            ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
            ci.Database       = fdbPath;

            //获取数据源
            IDataSource ds = new DataSourceFactory().OpenDataSource(ci);

            string[]         dataSetNames = ds.GetFeatureDatasetNames();
            IFeatureDataSet  fds          = ds.OpenFeatureDataset("fdsName");
            IResourceManager resourceM    = (IResourceManager)fds;

            //获取所有featureClass
            string[] fcNames = fds.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
            for (int fci = 0; fci < fcNames.Length; fci++)
            {
                IFeatureClass        fc         = fds.OpenFeatureClass(fcNames[fci]);
                IFieldInfoCollection fieldInfos = fc.GetFields();
                for (int fieldi = 0; fieldi < fieldInfos.Count; fieldi++)
                {
                    IFieldInfo finfo = fieldInfos.Get(fieldi);
                    if (finfo.FieldType == gviFieldType.gviFieldGeometry)
                    {
                        //获取fc的几何属性及其索引,索引用于更新模型
                        aaa(fc, fieldi, resourceM);
                        break;
                    }
                }
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            try
            {
                ConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                ci.Database       = "../XXX.FDB";
                IDataSource      dataSouce  = new DataSourceFactory().OpenDataSource(ci);
                string[]         names      = (string[])dataSouce.GetFeatureDatasetNames();
                IFeatureDataSet  fds        = dataSouce.OpenFeatureDataset(names[0]);
                IResourceManager resManager = fds as IResourceManager;

                //没有锁时这句会报错
                IEnumResName myEnumNames = resManager.GetModelNames();
                while (myEnumNames.MoveNext())
                {
                    string modelName = myEnumNames.Current;
                    IModel myModel   = resManager.GetModel(modelName);
                    if (myModel != null)
                    {
                        for (int i = 0; i < myModel.GroupCount; i++)
                        {
                            IDrawGroup myGroup = myModel.GetGroup(i);
                            for (int j = 0; j < myGroup.PrimitiveCount; j++)
                            {
                                IDrawPrimitive myPv = myGroup.GetPrimitive(j);
                                IDrawMaterial  myDM = myPv.Material;
                                if (myDM != null)
                                {
                                    myDM.EnableLight = false;
                                }
                                myPv.Material = myDM;
                                myGroup.SetPrimitive(j, myPv);
                            }
                            myModel.SetGroup(i, myGroup);
                        }
                        resManager.UpdateModel(modelName, myModel);
                    }
                }

                //手动释放COM对象
                Marshal.ReleaseComObject(fds);
                MessageBox.Show("完成!");
            }
            catch { MessageBox.Show("必须插入加密锁!必须安装CityMaker Builder 7.1"); }
        }