阅读:1993回复:5
我写的用vc 读CAD文件函数,可显示汉字
<P>CString CGeoDrawView::AddCadLayer(const CString ; path )
{ //首先加入面图层,再加入线图层,再加入点图层,最后加入文本图层 CString CADType[5]; CADType[0] = "[CAD]"; CADType[1] = "[CADArea]"; CADType[2] = "[CADLine]"; CADType[3] = "[CADPoint]"; CADType[4] = "[CADText]"; for (int i = 2; i<5; i++) { // Establish connection to data CMoDataConnection conn; if (!conn.CreateDispatch(TEXT("MapObjects2.DataConnection"))) throw "unable to create MapObjects2.DataConnection"; //设置数据库为包含CAD文件的文件夹 conn.SetDatabase(CADType + GetFileDirectory(path)); if (!conn.Connect()) { throw "unable to connect to database"; }</P> <P> CMoLayers layers(m_map.GetLayers()); //层集对象</P> <P> CMoMapLayer layer; //矢量层对象</P> <P> if (!layer.CreateDispatch(TEXT("MapObjects2.MapLayer"))) { throw "unable to create MapObjects2.MapLayer"; } //设置MapLayer的GeoDataset属性 CMoGeoDataset geoDataset(conn.FindGeoDataset(GetFileName(path))); layer.SetGeoDataset(geoDataset);</P> <P> //标注文字 if( i == 4 ) { CMoLabelRenderer LabelRend; LabelRend.CreateDispatch("MapObjects2.LabelRenderer"); LabelRend.SetDrawBackground(false);//即显示标注内容也显示图层中的要素 LabelRend.SetHeightField("HeightText"); //字体高度 LabelRend.SetField("Text"); //字体内容 layer.SetRenderer( LabelRend); } layers.Add(layer); } return CString(); } </P> |
|
1楼#
发布于:2004-12-18 23:47
<P>是真的话那就不错了……</P>
|
|
|
2楼#
发布于:2004-12-19 09:21
绝对可用,大家可试一下,提出宝贵意见。
|
|
3楼#
发布于:2005-03-16 13:02
好呀 非常感谢!
|
|
4楼#
发布于:2005-03-16 15:29
<img src="images/post/smile/dvbbs/em04.gif" /><img src="images/post/smile/dvbbs/em04.gif" /><img src="images/post/smile/dvbbs/em04.gif" />
|
|
5楼#
发布于:2005-03-19 15:01
偶用了,非常不错!
|
|