zaozao1105
路人甲
路人甲
  • 注册日期2004-03-24
  • 发帖数15
  • QQ
  • 铜币174枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:2072回复:1

在ARCGIS加载后提示No new objects added.

楼主#
更多 发布于:2006-11-12 14:57
<P>小弟编写了个将视图内的地图导出成dxf文件的一个程序,在使用UIcontrol时可以使用,想将其制作成dll使用,但生成后在ARCGIS加载后提示No new objects added.望老鸟指教!代码如下</P>
<P>''输出DXF文件所用变量//////////////////////<BR>Implements ICommand<BR>Public g_doc As IMxDocument<BR>Public OutputFile As String<BR>Public g_sCurrent As String<BR>Const Pi As Double = 3.14159265358979</P>
<P>Dim m_pPicture As Picture<BR>Dim m_pApplication As IApplication</P>
<P>Private Sub class_initialize()<BR>Set m_pPicutre = LoadResPicture(101, vbResBitmap)<BR>End Sub</P>
<P>Private Property Get ICommand_Bitmap() As esriCore.OLE_HANDLE<BR>ICommand_Bitmap = m_pPicture<BR>End Property</P>
<P>Private Property Get ICommand_Caption() As String<BR>ICommand_Caption = "导出到DXF"<BR>End Property</P>
<P>Private Property Get ICommand_Category() As String<BR>ICommand_Category = "导出到DXF"<BR>End Property</P>
<P>Private Property Get ICommand_Checked() As Boolean</P>
<P>End Property</P>
<P>Private Property Get ICommand_Enabled() As Boolean<BR>ICommand_Enabled = True<BR>End Property</P>
<P>Private Property Get ICommand_HelpContextID() As Long</P>
<P>End Property</P>
<P>Private Property Get ICommand_HelpFile() As String</P>
<P>End Property</P>
<P>Private Property Get ICommand_Message() As String</P>
<P>End Property</P>
<P>Private Property Get ICommand_Name() As String<BR>ICommand_Name = "导出到DXF"<BR>End Property</P>
<P>Private Sub ICommand_OnCreate(ByVal hook As Object)<BR>Set m_pApplication = hook<BR>End Sub</P>
<P>Private Property Get ICommand_Tooltip() As String<BR>ICommand_Tooltip = "导出到DXF"<BR>End Property</P>
<P>Private Sub ICommand_OnClick()<BR>If MsgBox("本工具只导出可见图层在视窗范围内的图形! 注意:不能导出分子分母注记", vbOKCancel, "提示") = vbCancel Then<BR>Exit Sub<BR>End If</P>
<P>Set g_doc = ThisDocument<BR>If g_doc.FocusMap.LayerCount = 0 Then<BR>MsgBox "当前视图没有加载图形!"<BR>Exit Sub<BR>End If<BR><BR>Dim OutputFile As String<BR><BR>OutputFile = InputBox("请输入文件名", "导出DXF文件存放路径", "c:\test.dxf")<BR>If Trim(OutputFile) = "" Then<BR>''MsgBox "请输入有效的文件名"<BR>''OutputFile = InputBox("请输入文件名", "导出DXF文件存放路径", "c:\test.dxf")<BR>Exit Sub<BR>End If<BR><BR>Open_DXF OutputFile<BR>Write_Header<BR>Write_Tables<BR>Write_Blocks<BR>Write_Entities<BR>Application.StatusBar.Message(0) = "成功将窗口内的图形导出为DXF文件!"<BR>Close #1</P>
<P>Set g_doc = Nothing<BR>End Sub</P>
<P><BR>''''以下代码用于将当前视图内的图形输出到DXF文件<BR>''<BR>''''////////////////////////////////////////////////////////////////////////////////////////////////////////////////<BR>''Private Sub 导出到DXF_Click()<BR>''<BR>'' If MsgBox("本工具只导出可见图层在视窗范围内的图形! 注意:不能导出分子分母注记", vbOKCancel, "提示") = vbCancel Then<BR>'' Exit Sub<BR>'' End If<BR>''<BR>'' Set g_doc = ThisDocument<BR>'' If g_doc.FocusMap.LayerCount = 0 Then<BR>'' MsgBox "当前视图没有加载图形!"<BR>'' Exit Sub<BR>'' End If<BR>''<BR>'' Dim OutputFile As String<BR>''<BR>'' OutputFile = InputBox("请输入文件名", "导出DXF文件存放路径", "c:\test.dxf")<BR>'' If Trim(OutputFile) = "" Then<BR>'' ''MsgBox "请输入有效的文件名"<BR>'' ''OutputFile = InputBox("请输入文件名", "导出DXF文件存放路径", "c:\test.dxf")<BR>'' Exit Sub<BR>'' End If<BR>''<BR>'' Open_DXF OutputFile<BR>'' Write_Header<BR>'' Write_Tables<BR>'' Write_Blocks<BR>'' Write_Entities<BR>'' Application.StatusBar.Message(0) = "成功将窗口内的图形导出为DXF文件!"<BR>'' Close #1<BR>''<BR>'' Set g_doc = Nothing<BR>''<BR>''End Sub</P>
<P><BR>''///////////////////////////////////////////////////////////////////////////////////////////</P>
<P><BR>Public Sub Open_DXF(sFile As String)<BR>On Error GoTo errhandle:<BR><BR>Open sFile For Output As #1<BR><BR>Exit Sub<BR>errhandle:<BR>MsgBox "Open_DXF: " ; Err.Description</P>
<P>End Sub</P>
<P>Public Sub Write_Header()<BR>On Error GoTo errhandle:</P>
<P>Dim pEnv As IEnvelope<BR>Set pEnv = g_doc.ActiveView.Extent<BR><BR>Dim min_extents As IPoint<BR>Set min_extents = New Point<BR>min_extents.x = pEnv.LowerLeft.x<BR>min_extents.y = pEnv.LowerLeft.y<BR>min_extents.Z = 0<BR><BR>Dim max_extents As IPoint<BR>Set max_extents = New Point<BR>max_extents.x = pEnv.UpperRight.x<BR>max_extents.y = pEnv.UpperRight.y<BR>max_extents.Z = 0<BR><BR>Print #1, CStr(0)<BR>Print #1, "SECTION"<BR>Print #1, CStr(2)<BR>Print #1, "HEADER"<BR>Print #1, 9<BR>Print #1, "$EXTMIN"<BR>Print #1, 10<BR>Print #1, CStr(min_extents.x)<BR>Print #1, 20<BR>Print #1, CStr(min_extents.y)<BR>Print #1, 30<BR>Print #1, CStr(min_extents.Z)<BR>Print #1, 9<BR>Print #1, "$EXTMAX"<BR>Print #1, 10<BR>Print #1, CStr(max_extents.x)<BR>Print #1, 20<BR>Print #1, CStr(max_extents.y)<BR>Print #1, 30<BR>Print #1, CStr(max_extents.Z)<BR>Print #1, 0<BR>Print #1, "ENDSEC"<BR><BR>Exit Sub<BR>errhandle:<BR>MsgBox "Write_Header: " ; Err.Description</P>
<P><BR>End Sub</P>
<P>Public Sub Write_Tables()<BR>On Error GoTo errhandle:</P>
<P>Print #1, 0<BR>Print #1, "SECTION"<BR>Print #1, 2<BR>Print #1, "TABLES"<BR><BR>''Write_VPort_Information<BR>''Write_Layer_Information<BR><BR>Print #1, 0<BR>Print #1, "ENDSEC"<BR><BR>Exit Sub<BR>errhandle:<BR>MsgBox "Write_Tables: " ; Err.Description</P>
<P>End Sub</P>
<P>Public Sub Write_Blocks()<BR>On Error GoTo errhandle:</P>
<P>Print #1, 0<BR>Print #1, "SECTION"<BR>Print #1, 2<BR>Print #1, "BLOCKS"<BR>Print #1, 0<BR>Print #1, "ENDSEC"<BR><BR>Exit Sub<BR>errhandle:<BR>MsgBox "Write_Blocks: " ; Err.Description<BR><BR>End Sub</P>
<P>Public Sub Write_Entities()<BR>''On Error GoTo errhandle:</P>
<P>Dim pFeat As IFeature<BR>Print #1, 0<BR>Print #1, "SECTION"<BR>Print #1, 2<BR>Print #1, "ENTITIES"<BR><BR>Dim pMap As IMap<BR>Dim pFCursor As IFeatureCursor, pFL As IFeatureLayer<BR>Set pMap = g_doc.FocusMap<BR>Dim pShape As IGeometry<BR><BR>Dim pSpatialFilter As ISpatialFilter<BR>Dim pGeometry As IGeometry<BR>Set pGeometry = g_doc.ActiveView.Extent.Envelope<BR>Set pSpatialFilter = New SpatialFilter<BR><BR>Dim i, j As Integer<BR>Dim layer As ILayer<BR>Dim pComLayer As ICompositeLayer<BR><BR><BR>Dim pStepProgressor As IStepProgressor<BR>Set pStepProgressor = Application.StatusBar.ProgressBar<BR><BR>pStepProgressor.MinRange = 1<BR>pStepProgressor.MaxRange = pMap.LayerCount<BR>''pStepProgressor.StepValue = 1<BR>pStepProgressor.Show</P>
<P><BR>For i = 0 To pMap.LayerCount - 1<BR>Set layer = pMap.layer(i)<BR>If layer.Visible = True Then ''只导出可见图层<BR>If (TypeOf pMap.layer(i) Is IFeatureLayer) Then<BR>''If Not pMap.layer(i).Name = "Graphics" Then<BR><BR>Set pFL = pMap.layer(i)<BR>If Not pFL.FeatureClass Is Nothing Then<BR><BR>If pFL.FeatureClass.FeatureCount(Nothing) > 0 And pFL.Visible = True Then<BR><BR>g_sCurrent = pMap.layer(i).Name<BR>''Application.StatusBar.Message(0) = "正在将视窗范围内的图形导出为DXF文件(" ; Str(i) ; "/" ; Str(pMap.LayerCount) ; ")"<BR><BR>''输出当前视窗内的要素<BR>With pSpatialFilter<BR>Set .Geometry = pGeometry<BR>.GeometryField = pFL.FeatureClass.ShapeFieldName<BR>.SpatialRel = esriSpatialRelRelation<BR>.SpatialRelDescription = "T********" ''完全被包含的和相交的<BR>End With<BR>Set pFCursor = pFL.Search(pSpatialFilter, False)<BR>Set pFeat = pFCursor.NextFeature<BR>''///////////////////////////////////////////////////<BR>While Not pFeat Is Nothing<BR>If TypeOf pFeat Is IAnnotationFeature Then '' Handle anno<BR>write_anno pFeat<BR>Else '' Handle normal features<BR>Set pShape = pFeat.ShapeCopy<BR>Select Case pShape.GeometryType<BR><BR>Case esriGeometryPoint<BR>write_point pShape<BR>Case esriGeometryMultipoint<BR>write_points pShape<BR>Case esriGeometryPolyline<BR>write_polyline pShape<BR>Case esriGeometryPolygon<BR>write_poly pShape<BR>Case esriGeometryEnvelope<BR>Case esriGeometryPath<BR>Case esriGeometryAny<BR>Case esriGeometryRing<BR>Case esriGeometryLine<BR>write_polyline pShape<BR>Case esriGeometryCircularArc<BR>Case esriGeometryBezier3Curve<BR>Case esriGeometryEllipticArc<BR><BR>End Select<BR>End If<BR>Set pFeat = pFCursor.NextFeature<BR>''////////////////////////////////////////////////<BR>Wend<BR>End If<BR>End If<BR>'' End If<BR>ElseIf TypeOf pMap.layer(i) Is IGroupLayer Then<BR><BR><BR>Set pComLayer = pMap.layer(i)<BR>For j = 0 To pComLayer.Count - 1<BR>Set pFL = pComLayer.layer(j)<BR>If Not pFL.FeatureClass Is Nothing Then<BR><BR>If pFL.FeatureClass.FeatureCount(Nothing) > 0 And pFL.Visible = True Then<BR><BR>g_sCurrent = pComLayer.layer(j).Name<BR>''Application.StatusBar.Message(0) = "正在将视窗范围内的图形导出为DXF文件(" ; Str(i) ; "/" ; Str(pMap.LayerCount) ; ")"<BR><BR>''输出当前视窗内的要素<BR>With pSpatialFilter<BR>Set .Geometry = pGeometry<BR>.GeometryField = pFL.FeatureClass.ShapeFieldName<BR>''第一种空间查询方式<BR>''.SpatialRel = esriSpatialRelContains ''完全被指定的范围所包含<BR>''第二种空间查询方式<BR>.SpatialRel = esriSpatialRelRelation<BR>.SpatialRelDescription = "T********" ''完全被包含的和相交的<BR>End With<BR>Set pFCursor = pFL.Search(pSpatialFilter, False)<BR>Set pFeat = pFCursor.NextFeature<BR><BR>''///////////////////////////////////////////////////<BR>While Not pFeat Is Nothing<BR>If TypeOf pFeat Is IAnnotationFeature Then '' Handle anno<BR>write_anno pFeat<BR>Else '' Handle normal features<BR>Set pShape = pFeat.ShapeCopy<BR>Select Case pShape.GeometryType<BR><BR>Case esriGeometryPoint<BR>write_point pShape<BR>Case esriGeometryMultipoint<BR>write_points pShape<BR>Case esriGeometryPolyline<BR>write_polyline pShape<BR>Case esriGeometryPolygon<BR>write_poly pShape<BR>Case esriGeometryEnvelope<BR>Case esriGeometryPath<BR>Case esriGeometryAny<BR>Case esriGeometryRing<BR>Case esriGeometryLine<BR>write_polyline pShape<BR>Case esriGeometryCircularArc<BR>Case esriGeometryBezier3Curve<BR>Case esriGeometryEllipticArc<BR><BR>End Select<BR>End If<BR>Set pFeat = pFCursor.NextFeature<BR>''////////////////////////////////////////////////<BR>Wend<BR>End If<BR>End If<BR>Next j<BR>End If<BR><BR>End If<BR>pStepProgressor.Position = i<BR>pStepProgressor.Message = "正在生成DXF文件"<BR>''pStepProgressor.Step<BR>Next i<BR><BR>pStepProgressor.Hide<BR><BR>Print #1, 0<BR>Print #1, "ENDSEC"<BR>Print #1, 0<BR>Print #1, "EOF"<BR>Exit Sub<BR><BR>''errhandle:<BR>''MsgBox "写实体出错: " ; Err.Description</P>
<P>End Sub</P>
<P>Public Sub Write_VPort_Information()<BR>On Error GoTo errhandle:</P>
<P>Print #1, 0<BR>Print #1, "TABLE"<BR>Print #1, 2<BR>Print #1, "VPORT"<BR>Print #1, 0<BR>Print #1, "VPORT"<BR>Print #1, 2<BR>Print #1, "*ACTIVE"<BR>Print #1, 41<BR>Print #1, CStr(1#)<BR>Print #1, 0<BR>Print #1, "ENDTAB"<BR><BR>Exit Sub<BR>errhandle:<BR>MsgBox "Write_VPort_Information: " ; Err.Description</P>
<P>End Sub</P>
<P>Public Sub Write_Layer_Information()<BR>On Error GoTo errhandle:</P>
<P>'' Write the LineTypes<BR>Print #1, 0<BR>Print #1, "TABLE"<BR>Print #1, 2<BR>Print #1, "LTYPE"<BR>Print #1, 5<BR>Print #1, 1<BR>Print #1, 0<BR>Print #1, "LTYPE"<BR>Print #1, 2<BR>Print #1, "CONTINUOUS"<BR>Print #1, 70<BR>Print #1, 0<BR>Print #1, 3<BR>Print #1, "Solid line"<BR>Print #1, 72<BR>Print #1, 65<BR>Print #1, 73<BR>Print #1, 0<BR>Print #1, 0<BR>Print #1, "ENDTAB"</P>
<P><BR>Print #1, 0<BR>Print #1, "TABLE"<BR>Print #1, 2<BR>Print #1, "LAYER"<BR>Print #1, 5<BR>Print #1, 2<BR>Print #1, 0<BR>Print #1, "LAYER"<BR>Print #1, 2<BR>Print #1, 0<BR>Print #1, 70<BR>Print #1, 0<BR>Print #1, 62<BR>Print #1, 7<BR>Print #1, 6<BR>Print #1, "CONTINUOUS"<BR>Print #1, 0<BR>Print #1, "ENDTAB"<BR><BR>Exit Sub<BR>errhandle:<BR>MsgBox "Write_Layer_Information: " ; Err.Description</P>
<P>End Sub</P>
<P>Public Sub write_polyline(pShape As IGeometry)<BR>On Error GoTo errhandle:</P>
<P>Dim bFirstSeg As Boolean<BR>bFirstSeg = True<BR><BR>Dim pSegColl As ISegmentCollection<BR>Set pSegColl = pShape<BR><BR>Dim pSeg As ISegment<BR><BR>Dim i As Long<BR>For i = 0 To pSegColl.SegmentCount - 1<BR><BR>Set pSeg = pSegColl.Segment(i)<BR><BR>Select Case pSeg.GeometryType<BR><BR>Case esriGeometryLine<BR>If bFirstSeg Then<BR>'' First segment of polyline, print the header info<BR>Print #1, CStr(0)<BR>Print #1, "POLYLINE"<BR>Print #1, CStr(8)<BR>Print #1, g_sCurrent<BR>Print #1, CStr(66)<BR>Print #1, CStr(1)<BR>Print #1, CStr(62)<BR>Print #1, CStr(7)<BR>Print #1, CStr(6)<BR>Print #1, "CONTINUOUS"<BR>'' Print the "from point"<BR>Print #1, CStr(0)<BR>Print #1, "VERTEX"<BR>Print #1, CStr(8)<BR>Print #1, g_sCurrent<BR>Print #1, 10<BR>Print #1, pSeg.FromPoint.x<BR>Print #1, 20<BR>Print #1, pSeg.FromPoint.y<BR>bFirstSeg = False<BR>End If<BR><BR>'' Now print the "to point"<BR>Print #1, CStr(0)<BR>Print #1, "VERTEX"<BR>Print #1, CStr(8)<BR>Print #1, g_sCurrent<BR>Print #1, 10<BR>Print #1, pSeg.ToPoint.x<BR>Print #1, 20<BR>Print #1, pSeg.ToPoint.y<BR><BR>'' Do we need to end the entity?<BR>If i = pSegColl.SegmentCount - 1 Then<BR>Print #1, CStr(0)<BR>Print #1, "SEQEND"<BR>Print #1, 8<BR>Print #1, g_sCurrent<BR>End If</P>
<P>'' Handle curves<BR>Case esriGeometryCircularArc<BR>If Not bFirstSeg Then<BR>'' ArcMap allows a line and curve as one entity. Autocad doesn''t.<BR>'' So, in this case, this is a curve but isn''t the first segment.<BR>'' End the polyline entity first, then create a new ARC entity.<BR>Print #1, CStr(0)<BR>Print #1, "SEQEND"<BR>Print #1, 8<BR>Print #1, g_sCurrent<BR>End If<BR><BR>Dim pCA As ICircularArc<BR>Set pCA = pSeg<BR><BR>Print #1, CStr(0)<BR>Print #1, "ARC"<BR>Print #1, CStr(8)<BR>Print #1, g_sCurrent<BR>Print #1, 10<BR>Print #1, pCA.CenterPoint.x<BR>Print #1, 20<BR>Print #1, pCA.CenterPoint.y<BR>Print #1, 40<BR>Print #1, pCA.radius<BR><BR>If pCA.IsCounterClockwise Then<BR>Print #1, 50<BR>Print #1, CStr(CDbl(pCA.FromAngle * 180 / Pi))<BR>Print #1, 51<BR>Print #1, CStr(CDbl(pCA.ToAngle * 180 / Pi))<BR>Else<BR>Print #1, 50<BR>Print #1, CStr(CDbl(pCA.ToAngle * 180 / Pi))<BR>Print #1, 51<BR>Print #1, CStr(CDbl(pCA.FromAngle * 180 / Pi))<BR>End If<BR><BR>''Debug.Print " *** Arc *** "<BR>Set pCA = pSeg<BR>''Debug.Print "Center: " ; pCA.CenterPoint.X ; " , " ; pCA.CenterPoint.Y<BR>''Debug.Print "Radius: " ; pCA.radius<BR>''Debug.Print "Start Angle: " ; CDbl(pCA.FromAngle * 180 / Pi)<BR>''Debug.Print "End Angle: " ; CDbl(pCA.ToAngle * 180 / Pi)<BR>bFirstSeg = True<BR><BR>End Select<BR><BR>Next i<BR><BR><BR>Exit Sub<BR>errhandle:<BR>MsgBox "Write_Polyline: " ; Err.Description</P>
<P>End Sub</P>
<P><BR>Public Sub write_polyline_original(pShape As IGeometry)<BR>On Error GoTo errhandle:</P>
<P>Dim pPoints As IPointCollection<BR>Set pPoints = pShape<BR><BR>Dim pPoly As IPolygon<BR>Dim pRing As IRing<BR><BR>Print #1, CStr(0)<BR>Print #1, "POLYLINE"<BR>Print #1, CStr(8)<BR>Print #1, g_sCurrent<BR>Print #1, CStr(66)<BR>Print #1, CStr(1)<BR>Print #1, CStr(62)<BR>Print #1, CStr(7)<BR>Print #1, CStr(6)<BR>Print #1, "CONTINUOUS"<BR><BR>Dim i As Long<BR>For i = 0 To pPoints.PointCount - 1<BR><BR>Print #1, CStr(0)<BR>Print #1, "VERTEX"<BR>Print #1, CStr(8)<BR>Print #1, g_sCurrent<BR>Print #1, 10<BR>Print #1, pPoints.Point(i).x<BR>Print #1, 20<BR>Print #1, pPoints.Point(i).y<BR>Dim j As Long<BR><BR>Next i<BR><BR>Print #1, CStr(0)<BR>Print #1, "SEQEND"<BR>Print #1, 8<BR>Print #1, g_sCurrent<BR><BR>Exit Sub<BR>errhandle:<BR>MsgBox "Write_Polyline: " ; Err.Description</P>
<P>End Sub</P>
<P>Public Sub write_poly(pShape As IGeometry)<BR>On Error GoTo errhandle:<BR>Dim pPoly As IPolygon, lLoop As Long, lExtCount As Long, pExtRings() As IRing<BR>Dim pIntRings() As IRing, lLoop2 As Long, lIntCount As Long<BR>Set pPoly = pShape<BR>lExtCount = pPoly.ExteriorRingCount<BR>ReDim pExtRings(lExtCount - 1)<BR>For lLoop = 0 To lExtCount - 1<BR>Set pExtRings(lLoop) = New Ring<BR>Next lLoop<BR>pPoly.QueryExteriorRings pExtRings(0)<BR>For lLoop = 0 To lExtCount - 1<BR>''Write out the external ring<BR>write_polyline pExtRings(lLoop)<BR>lIntCount = pPoly.InteriorRingCount(pExtRings(lLoop))<BR>If lIntCount > 0 Then<BR>ReDim pIntRings(lIntCount - 1)<BR>For lLoop2 = 0 To lIntCount - 1<BR>Set pIntRings(lLoop2) = New Ring<BR>Next lLoop2<BR>pPoly.QueryInteriorRings pExtRings(lLoop), pIntRings(0)<BR>For lLoop2 = 0 To lIntCount - 1<BR>''Write out the internal rings<BR>Dim pPoints As IPointCollection<BR>Set pPoints = pIntRings(lLoop2)<BR>write_polyline pIntRings(lLoop2)<BR>Next lLoop2<BR>End If<BR>Next lLoop<BR><BR>Exit Sub<BR>errhandle:<BR>MsgBox "Write_Poly: " ; Err.Description</P>
<P>End Sub</P>
<P>Public Sub write_anno(pFeat As IFeature)<BR>On Error GoTo errhandle:</P>
<P>Dim pAnno As IAnnotationFeature<BR>Set pAnno = pFeat<BR><BR>Dim pShape As IGeometry<BR>Set pShape = pFeat.ShapeCopy<BR><BR>Dim pPoly As IPolygon<BR>Set pPoly = pShape<BR><BR>Dim pEnv As IEnvelope<BR>Set pEnv = pPoly.Envelope<BR><BR>Dim x1 As Double, x2 As Double, y1 As Double, y2 As Double<BR>Dim pElem As IElement<BR>Set pElem = pAnno.Annotation<BR>Dim pTextEl As ITextElement<BR>''处理地类注记中间的短线,如果短线是分开单独放置的,忽略它,不输出到DXF文件中.<BR>If TypeOf pElem Is ITextElement Then<BR>Set pTextEl = pElem<BR>Else<BR>Exit Sub<BR>End If<BR>''如果地类注记中的短线和分子分母为一个整体,怎么处理?转换为"分子/分母"方式输出?<BR>''Dim position As Integer<BR>''position = InStr(1, pTextEl.Text, Chr(13), vbTextCompare)<BR>''Dim bh As String<BR>''bh = LTrim(pTextEl.Text, position - 1)<BR>''MsgBox pTextEl.Text<BR></P>
<P>Dim pGeom As IGeometry<BR>Set pGeom = pElem.Geometry<BR><BR>''Determine the size to use for the annotation in map units<BR>Dim dSize As Double, dRatio As Double, pAnnoClass As IAnnoClass<BR>Set pAnnoClass = pFeat.Class.Extension<BR>Dim pMap As IMap, pCurrentScale As Double, pDisp As IScreenDisplay<BR>Set pMap = g_doc.FocusMap<BR>pCurrentScale = pMap.MapScale<BR>pMap.MapScale = pAnnoClass.ReferenceScale<BR>Dim pActive As IActiveView<BR>Set pActive = pMap<BR>Set pDisp = pActive.ScreenDisplay<BR>dRatio = pAnnoClass.ReferenceScale / pMap.MapScale<BR>''For some reason the size needs to be divided by 1.333 to come out correctly.<BR>''Have not figured out the reason for this.<BR>dSize = pDisp.DisplayTransformation.FromPoints(pTextEl.Symbol.Size) / 1.333<BR>pMap.MapScale = pCurrentScale<BR><BR>Dim pMP As IMultipoint<BR>Set pMP = New Multipoint<BR><BR>Dim pPoints As IPointCollection<BR>''修改后的<BR>Dim point1 As IPoint<BR>Dim point2 As IPoint<BR>Set point1 = New Point<BR>Set point2 = New Point<BR>'' point1.X = pEnv.XMin<BR>'' point1.Y = pEnv.YMin<BR>'' point2.X = pEnv.XMax<BR>'' point2.Y = pEnv.YMax<BR><BR>Set point1 = pEnv.LowerLeft<BR>Set point2 = pEnv.LowerRight<BR><BR><BR>Set pPoints = pMP<BR>pPoints.AddPoint point1<BR>pPoints.AddPoint point2</P>
<P>''////////////////////////////////////////<BR><BR>Dim dAngle As Double, deltaX As Double, deltaY As Double<BR>deltaX = pPoints.Point(1).x - pPoints.Point(0).x<BR>deltaY = pPoints.Point(1).y - pPoints.Point(0).y<BR><BR>If deltaX = 0 Then<BR>If pPoints.Point(0).y > pPoints.Point(1).y Then<BR>dAngle = 270#<BR>Else<BR>dAngle = 90#<BR>End If<BR>Else<BR>dAngle = Atn(deltaY / deltaX)<BR>dAngle = dAngle * 180 / 3.14159<BR>End If<BR>''Debug.Print deltaX ; " - " ; dAngle<BR><BR>Print #1, CStr(0)<BR>Print #1, "TEXT"<BR>Print #1, CStr(8)<BR>Print #1, g_sCurrent<BR>Print #1, CStr(1)<BR>Print #1, pTextEl.Text<BR>Print #1, 72<BR>Print #1, CStr(0)<BR>Print #1, 73<BR>Print #1, CStr(0)<BR>Print #1, 50<BR>If deltaY > 0 Then<BR>Print #1, CStr(Abs(dAngle))<BR>Else<BR>Print #1, CStr(dAngle)<BR>End If<BR>Print #1, 40<BR>Print #1, CStr(dSize) '' TOD if we''re in meters, divide by 3. Otherwise, don''t.<BR><BR>''Write out the first and last points (DXF only allows two points for defining the position)<BR>Print #1, "10"<BR>Print #1, pPoints.Point(0).x<BR>Print #1, "20"<BR>Print #1, pPoints.Point(0).y<BR>Print #1, "11"<BR>Print #1, pPoints.Point(pPoints.PointCount - 1).x<BR>Print #1, "21"<BR>Print #1, pPoints.Point(pPoints.PointCount - 1).y<BR><BR>Exit Sub<BR>errhandle:<BR>''MsgBox "写注记出错: " ; Err.Description</P>
<P>Exit Sub</P>
<P>End Sub</P>
<P>Public Sub write_point(pShape As IGeometry)<BR>On Error GoTo errhandle:</P>
<P>Dim pPoint As IPoint<BR>Set pPoint = pShape<BR><BR>Print #1, CStr(0)<BR>Print #1, "POINT"<BR>Print #1, CStr(8)<BR>Print #1, g_sCurrent<BR><BR>Print #1, 10<BR>Print #1, pPoint.x<BR>Print #1, 20<BR>Print #1, pPoint.y<BR><BR>Print #1, 39 '' Thickness<BR>Print #1, CStr(3)<BR><BR>Exit Sub<BR>errhandle:<BR>MsgBox "Write_Point: " ; Err.Description</P>
<P>End Sub</P>
<P>Public Sub write_points(pShape As IGeometry)<BR>On Error GoTo errhandle:</P>
<P>Dim pPoints As IPointCollection<BR>Set pPoints = pShape<BR><BR>Dim i As Long<BR>For i = 0 To pPoints.PointCount - 1<BR>Print #1, CStr(0)<BR>Print #1, "POINT"<BR>Print #1, CStr(8)<BR>Print #1, g_sCurrent<BR><BR>Print #1, 10<BR>Print #1, pPoints.Point(i).x<BR>Print #1, 20<BR>Print #1, pPoints.Point(i).y<BR><BR>Print #1, 39 '' Thickness<BR>Print #1, CStr(3)<BR>Next i<BR><BR>Exit Sub<BR>errhandle:<BR>MsgBox "Write_Points: " ; Err.Description</P>
<P>End Sub</P>
喜欢0 评分0
zaozao1105
路人甲
路人甲
  • 注册日期2004-03-24
  • 发帖数15
  • QQ
  • 铜币174枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2006-11-12 14:58
<P>在制作dll时应该注意些什么啊?哪个GG做过给点建议呢?</P>
举报 回复(0) 喜欢(0)     评分
游客

返回顶部