明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2360|回复: 0

为什么会出错呢?请教!

[复制链接]
发表于 2005-5-24 19:17 | 显示全部楼层 |阅读模式
有以下一段代码 用来创建一个面域 : '定义点 Dim pt1(0 To 2) As Double
Dim pt3(0 To 2) As Double
Dim hpt1(0 To 2) As Double
Dim hpt3(0 To 2) As Double
Dim upt1 As Variant
Dim upt3 As Variant
Dim uhpt1 As Variant
Dim uhpt3 As Variant
'获得点的坐标

pt1(0) = 0 - 1 / 2 * 100 * Val(Form1.MCbox1.Text) - 100 * Val(Form1.LPbox1.Text) - 100 * Val(Form1.LTbox1.Text): pt1(1) = 0: pt1(2) = 0
hpt1(0) = 0 - 1 / 2 * 100 * Val(Form1.MCbox1.Text) - 100 * Val(Form1.LPbox1.Text) - 100 * Val(Form1.LTbox1.Text): hpt1(1) = r + t + r: hpt1(2) = 0
pt3(0) = 1 / 2 * 100 * Val(Form1.MCbox1.Text) + 100 * Val(Form1.RPbox1.Text) + 100 * Val(Form1.RTbox1.Text): pt3(1) = 0: pt3(2) = 0
hpt3(0) = 1 / 2 * 100 * Val(Form1.MCbox1.Text) + 100 * Val(Form1.RPbox1.Text) + 100 * Val(Form1.RTbox1.Text): hpt3(1) = r + t + r: hpt3(2) = 0 '将点pt1,pt3,hpt1,hpt3的坐标转换为世界坐标 upt2 = ThisDrawing.Utility.TranslateCoordinates(pt2, acUCS, acWorld, False)
upt4 = ThisDrawing.Utility.TranslateCoordinates(pt4, acUCS, acWorld, False)
upt1 = ThisDrawing.Utility.TranslateCoordinates(pt1, acUCS, acWorld, False)
upt3 = ThisDrawing.Utility.TranslateCoordinates(pt3, acUCS, acWorld, False)
uhpt1 = ThisDrawing.Utility.TranslateCoordinates(hpt1, acUCS, acWorld, False)
uhpt3 = ThisDrawing.Utility.TranslateCoordinates(hpt3, acUCS, acWorld, False)


'定义一组直线 Dim curs(0 To 3) As AcadLine

Set curs(0) = ThisDrawing.ModelSpace.AddLine(upt1, uhpt1)
curs(0).Layer = "0"
Set curs(1) = ThisDrawing.ModelSpace.AddLine(uhpt1, uhpt3)
curs(1).Layer = "0"
Set curs(2) = ThisDrawing.ModelSpace.AddLine(uhpt3, upt3)
curs(2).Layer = "0"
Set curs(3) = ThisDrawing.ModelSpace.AddLine(upt3, upt1)
curs(3).Layer = "0" 以下代码为:
根据以上衔接直线段创建一个面域
Dim regionobj1 As Variant
Set regionobj1 = ThisDrawing.ModelSpace.AddRegion(curs)
regionobj1(0).Layer = "0" 可运行期间出现"运行时错误"的提示: 说是类型不[匹配,调试出现 -> Set regionobj1 = ThisDrawing.ModelSpace.AddRegion(curs)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-4-28 16:28 , Processed in 0.326915 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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