明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1605|回复: 4

程序运行后产生的问题

[复制链接]
发表于 2006-8-7 12:34:00 | 显示全部楼层 |阅读模式

最近变了一个程序,如下:

Private Sub CommandButton2_Click()
Dim pt As Variant
Dim textobject As AcadText
Dim pt1 As Variant
Dim pt2 As Variant
Dim pt3 As Variant
Dim pt4 As Variant
Dim pt5 As Variant
Dim pt6 As Variant
Dim pt7 As Variant
frmMain.Hide
pt = ThisDrawing.Utility.GetPoint(, "请输入插入点!")
pt1(0) = pt(0) + 488: pt1(1) = pt(0) - 884
pt2(0) = pt(0) + 5002: pt2(1) = pt(0) - 890
pt3(0) = pt(0) + 9148: pt3(1) = pt(0) - 752
pt4(0) = pt(0) + 9189: pt4(1) = pt(0) - 1250
pt5(0) = pt(0) + 23067: pt5(1) = pt(0) - 884
pt6(0) = pt(0) + 24475: pt6(1) = pt(0) - 984
pt7(0) = pt(0) + 9138: pt7(1) = pt(0) - 965
Set textobject = ThisDrawing.ModelSpace.AddText("sfsf", pt1, 500)
End Sub

程序运行到pt1(0) = pt(0) + 488: pt1(1) = pt(0) - 884
调试错误,提示类型不匹配!请问是什么原因?另,在输入汉字时怎么规定字体?谢谢!

发表于 2006-8-7 14:23:00 | 显示全部楼层

Dim pt As Variant
Dim textobject As AcadText
Dim pt1(2) As Double


pt = ThisDrawing.Utility.GetPoint(, "请输入插入点!")
pt1(0) = pt(0) + 488: pt1(1) = pt(0) - 884: pt1(2) = 0

Set textobject = ThisDrawing.ModelSpace.AddText("sfsf", pt1, 500)

 楼主| 发表于 2006-8-8 12:24:00 | 显示全部楼层
谢谢!顺便请问一下怎样为输入的汉字设置字体?
发表于 2006-8-9 22:06:00 | 显示全部楼层

你搜索一下吧,很多的

 楼主| 发表于 2006-8-10 19:16:00 | 显示全部楼层

找到了一个,如下:

set ts = ThisDrawing.ActiveTextStyle
tsna = ts.fontFile
    Set ts1 = ThisDrawing.ActiveTextStyle
    ts1.fontFile = "HZTXT"
ThisDrawing.ActiveTextStyle = ts1
Set textobject = ThisDrawing.ModelSpace.AddText("汉字",pt5, 500)
ThisDrawing.Regen acActiveViewport
ts.fontFile = tsna
ThisDrawing.ActiveTextStyle = ts

确实程序执行时,我采用MSGBOX看字体,气体确实由原来的ROMANS 便成了HZTXT,然后写入"汉字"两个字,之后又变成了原来的ROMANS。但是当我在查看CAD中"汉字"两个字的字体时,却是ROMANS。不知道为什么,请指教!

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

本版积分规则

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

GMT+8, 2024-11-27 00:45 , Processed in 0.163203 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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