|
为什么会出错呢?请教!
有以下一段代码 用来创建一个面域 : '定义点
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) |
|