明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2203|回复: 11

[求助]VB与R14的问题

  [复制链接]
发表于 2004-12-22 19:20:00 | 显示全部楼层 |阅读模式
vb中怎么引用AutoCAD R14的类库啊?


在AUTOCAD 2005环境中开发出来的应用程序在R14中运行不了啊


我该怎么配制,转移环境啊?


再此请教啊!:)
发表于 2004-12-22 20:56:00 | 显示全部楼层
后期绑定,不引用类型库,所有对象声明为Object
 楼主| 发表于 2004-12-23 10:47:00 | 显示全部楼层
后期怎么绑定啊?还是不大明白。


就把所有对象声明为Object就可以了吗?
 楼主| 发表于 2004-12-23 15:28:00 | 显示全部楼层
我还是想请教一下,用vb在R 14的环境下开发CAD和在2005的环境在一样吗?


现在在2005下开发的怎么转到R14下依然能用?急啊~~~


谢谢了!:)
发表于 2004-12-23 15:39:00 | 显示全部楼层
R14是单文档,2005是多文档,新建文件时会有不同,其他的应该差不多,


一定要不引用类型库,在GetObject或CreateObject时把版本号附上


比如2005是AutoCad.Application.16


R14是AutoCad.Application.14?(忘了,先试试吧)
 楼主| 发表于 2004-12-23 16:20:00 | 显示全部楼层
谢谢斑竹。 连接R 14没有问题。连上了。但是打不开文件啊? 在2005中我是这样写的: Dim acadapp As Object '建立Application对象
Dim acaddocs As Object '建立Document对象
On Error Resume Next Set acadapp = GetObject(, "autocad.application.14") '若AutoCad已启动 , 则直接得到
If Err Then
Err.Clear
Set acadapp = CreateObject("autocad.application.14") '若AutoCad未启动,则运行它
If Err Then
MsgBox Err.Description
Exit Function
End If
End If
MsgBox "Now running " + acadapp.Name + " version " + acadapp.Version
Set acaddocs = acadapp.Documents '设acaddocs为当前图形文件
Dim dwgname As String
dwgname = "C:\temp\temp.dwg" If Dir(dwgname) <> "" Then
acaddocs.Open (dwgname) '打开一个CAD文件
MsgBox "有文件"
acadapp.Visible = True
Dim temp() As String
Dim signer As String
Dim time As String

Dim insPoint(0 To 2) As Double '定义插入点
Dim textHeight As Double '定义文本高度
Dim textStr As String '定义文本字符
Dim textObj As Object '定义文本对象

insPoint(0) = -18990
insPoint(1) = 3424
insPoint(2) = 0
textHeight = height
textStr = "明经通道"

Dim ts As Object '设置字体
Set ts = acaddocs(0).TextStyles.Add("option")
ts.SetFont "宋体", True, False, 0, 1
acaddocs(0).ActiveTextStyle = ts

'创建文本对象
Set textObj = acaddocs(0).ModelSpace.AddText(textStr, insPoint, textHeight)
textObj.Update
textObj.StyleName = "option"

acaddocs(0).SaveAs ("C:\temp\temp.dwg")
Else
MsgBox "没有此文件,请建文件,路径为:C:\temp\temp.dwg"
Exit Function
End If cad可见后,什么都没有啊,里面不是temp.dwg文件啊? 我该怎么处理啊?
发表于 2004-12-23 16:22:00 | 显示全部楼层
试试


acadapp.ActiveDocument.open
 楼主| 发表于 2004-12-23 17:59:00 | 显示全部楼层
现在可以打开文件了,但是还是有一个问题啊,我修改后的代码如下: Dim acadapp As Object '建立Application对象
Dim acaddoc As Object '建立Document对象
On Error Resume Next Set acadapp = GetObject(, "autocad.application.14") '若AutoCad已启动 , 则直接得到
If Err Then
Err.Clear
Set acadapp = CreateObject("autocad.application.14") '若AutoCad未启动,则运行它
If Err Then
MsgBox Err.Description
Exit Function
End If
End If
MsgBox "Now running " + acadapp.Name + " version " + acadapp.Version
Set acaddoc = acadapp.ActiveDocument '设acaddocs为当前图形文件
Dim dwgname As String
dwgname = "C:\temp\temp.dwg" If Dir(dwgname) <> "" Then
acaddoc.Open (dwgname) '打开一个CAD文件
MsgBox "有文件"
acadapp.Visible = True

Dim temp() As String
Dim signer As String
Dim time As String

Dim insPoint(0 To 2) As Double '定义插入点
Dim textHeight As Double '定义文本高度
Dim textStr As String '定义文本字符
Dim textObj As Object '定义文本对象

insPoint(0) = -18990
insPoint(1) = 3424
insPoint(2) = 0
textHeight = height
textStr = "明经通道"

Dim ts As Object '设置字体
Set ts = acaddoc.TextStyles.Add("option")
ts.SetFont "宋体", True, False, 0, 1
acaddoc.ActiveTextStyle = ts

'创建文本对象
Set textObj = acaddoc.ModelSpace.AddText(textStr, insPoint, textHeight)
textObj.Update
textObj.StyleName = "option"

acaddoc.SaveAs ("C:\temp\temp.dwg")
'acadapp.Visible = True '使AutoCad可见
Else
MsgBox "没有此文件,请建文件,路径为:C:\temp.dwg"
Exit Function
End If 执行到打开文件后出现下面的情况: 出现一个对话框:Font not found: hztxt 我做的程序是在服务器上的,是不允许人工手动来选择对话框的。 我很疑惑,用vb在2005的环境下,打开文件可以后台执行这样一个过程,R14怎么不行啊? 我怎么解决啊?
发表于 2004-12-23 19:18:00 | 显示全部楼层
hztxt.shx在Font目录下么?
 楼主| 发表于 2004-12-23 20:51:00 | 显示全部楼层
HZFS
hztxt
gbcbig 都是字体库吗? 打开文件时,都说找不到。 我是刚开始接触开发CAD的程序,不是很懂。 我能在哪里找到啊?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-2-23 04:17 , Processed in 0.159098 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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