明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1074|回复: 0

[求助]插入文件问题

[复制链接]
发表于 2008-5-6 20:39:00 | 显示全部楼层 |阅读模式

我想将某个图形文件按照原坐标插入到当前图形里。如果是让CAD自己搜索插入的话就没问题,如果我将文件的路径给齐的话插入的图形坐标就不正确了是怎么回事呀?请教高手们

Sub tfcr()
Dim cn As New ADODB.Connection
Dim hct As New ADODB.Recordset
Dim sqllj As String
Dim tfm As String
Dim objUtil As AcadUtility
Dim varPnt As Variant
Dim strPrmt As String
Dim zjpoint(0 To 2) As Double
Dim x As String, y As String
Dim blockobject As AcadBlock
On Error Resume Next
  'strPrmt = "Left click to confirm, right click to cancel"
  strPrmt = "请选择图形插入位置!"
ii:  Set objUtil = ThisDrawing.Utility
  varPnt = objUtil.GetPoint(Prompt:=strPrmt)
  'No error? Then they "left clicked" (or typed a point on
  'The command line. Meh. Users are crazy.
  ClickConfirm = True
        zjpoint(0) = varPnt(0)
        zjpoint(1) = varPnt(1)
        zjpoint(2) = varPnt(2)
sqllj = "provider=sqloledb.1;password= ;persist security info=true;user id=sa;initial catalog=wzdjsj ;data source=huangbin"
cn.Open sqllj
hct.Open "select * from hct where x< " & zjpoint(1) & " order by x desc", cn, adOpenDynamic, adLockBatchOptimistic
If Not hct.EOF Then
  x = hct.Fields("x")
End If
hct.Close
hct.Open "select * from hct where y< " & zjpoint(0) & " order by y desc", cn, adOpenDynamic, adLockBatchOptimistic
If Not hct.EOF Then
  y = hct.Fields("y")
End If
hct.Close
tfm = Left(x, 3) + Left(y, 3)'此时插入的图形坐标就是正确的。

'tfm="D\航测图\"+Left(x, 3) + Left(y, 3)'此时插入的图形坐标就不正确的。
' ThisDrawing.SendCommand "-insert" & vbCr & blockname & vbCr & point.Fields("x") & "," & point.Fields("y") & vbCr & ljj.Fields("xs") & vbCr & ljj.Fields("ys") & vbCr & ljj.Fields("zs") & vbCr & ljj.Fields("jd") & vbCr
 ThisDrawing.SendCommand "-insert" & vbCr & tfm & vbCr & 0# & vbCr & 1 & vbCr & 1 & vbCr & 0 & vbCr & 0 & vbCr
End Sub

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

本版积分规则

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

GMT+8, 2024-11-26 08:32 , Processed in 0.143670 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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