明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1348|回复: 0

[求助]写MTEXT时自动捕捉插入点和手写输入插入点难道不同?

[复制链接]
发表于 2007-10-25 21:45:00 | 显示全部楼层 |阅读模式

Sub cadtoxls()

  Dim ExcelApp As Excel.Application
    On Error Resume Next

     Set ExcelApp = GetObject(, "Excel.Application")

        If Err <> 0 Then

        Set ExcelApp = CreateObject("Excel.Applicationn")

        End If


     Set xlsheet = ExcelApp.ActiveWorkbook.Sheets("数据输入") 'excel通讯
 
 
 Dim Ent As AcadEntity, TextEnt As AcadMText
 
 
 ' Dim TextToExcel As AcadMText
 
Dim pp As Variant

 
  Dim p(0 To 2) As Double '定义坐标变量

Dim p2(0 To 2) As Double

Dim p3(0 To 2) As Double

Dim p4(0 To 2) As Double


p(0) = 310.77: p(1) = 42: p(2) = 0 '坐标赋值

p2(0) = 353.56: p2(1) = 42: p2(2) = 0

p3(0) = 336.33: p3(1) = 10.44: p3(2) = 0

p4(0) = 367.08: p4(1) = 17.98: p4(2) = 0
 

  For Each Ent In ThisDrawing.PaperSpace '循环实体
    Select Case Ent.ObjectName '获取实体名
     
      Case "AcDbMText" '选择文本实体
     

        Set TextEnt = Ent
       
       
        pp = TextEnt.InsertionPoint
       
       
       
      If pp(0) = p(0) And pp(1) = p(1) Then
   

         dz1 = TextEnt.TextString
        
        
        
         ElseIf pp(0) = p2(0) And pp(1) = p2(1) Then

        
         bb = TextEnt.TextString
        
            For aa = 1 To Len(bb)
        
            If IsNumeric(Mid(bb, aa, 1)) Then Exit For

               Next aa


             ElseIf pp(0) = p3(0) And pp(1) = p3(1) Then
   

           xz1 = TextEnt.TextString


    End If
   

    End Select
 
   
  Next Ent

 mz1 = CStr(Left(bb, aa - 1))

 hm1 = CStr(Right(bb, Len(bb) - aa + 1))
 
 
 
  dzxz1 = dz1 & xz1


xlsheet.Cells(1, 2) = mz1
xlsheet.Cells(5, 2) = dzxz1
xlsheet.Cells(15, 2) = hm1


 End Sub

请问为什么我在  P  点写MTEXT时,用自动捕捉插入点时,dz1显示不出来

而用手写输入插入点310.77,42,0  dz1却可以识别呢?

 

 

 

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 12:41 , Processed in 0.142026 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表