为什么会出错呢?请教
<IMG alt=发贴心情 src="skins/default/topicface/face10.gif" border=0> <B>为什么会出错呢?请教!</B><BR>有以下一段代码 用来创建一个面域 :'定义点
Dim pt1(0 To 2) As Double<BR> Dim pt3(0 To 2) As Double<BR> Dim hpt1(0 To 2) As Double<BR> Dim hpt3(0 To 2) As Double
<BR> Dim upt1 As Variant<BR> Dim upt3 As Variant<BR> Dim uhpt1 As Variant<BR> Dim uhpt3 As Variant<BR> '获得点的坐标<BR> <BR> 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<BR> 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<BR> 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<BR> 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)<BR> upt4 = ThisDrawing.Utility.TranslateCoordinates(pt4, acUCS, acWorld, False)<BR> upt1 = ThisDrawing.Utility.TranslateCoordinates(pt1, acUCS, acWorld, False)<BR> upt3 = ThisDrawing.Utility.TranslateCoordinates(pt3, acUCS, acWorld, False)<BR> uhpt1 = ThisDrawing.Utility.TranslateCoordinates(hpt1, acUCS, acWorld, False)<BR> uhpt3 = ThisDrawing.Utility.TranslateCoordinates(hpt3, acUCS, acWorld, False)<BR> <BR> <BR> '定义一组直线
Dim curs(0 To 3) As AcadLine<BR> <BR> Set curs(0) = ThisDrawing.ModelSpace.AddLine(upt1, uhpt1)<BR> curs(0).Layer = "0"<BR> Set curs(1) = ThisDrawing.ModelSpace.AddLine(uhpt1, uhpt3)<BR> curs(1).Layer = "0"<BR> Set curs(2) = ThisDrawing.ModelSpace.AddLine(uhpt3, upt3)<BR> curs(2).Layer = "0"<BR> Set curs(3) = ThisDrawing.ModelSpace.AddLine(upt3, upt1)<BR> curs(3).Layer = "0"
以下代码为:<BR> 根据以上衔接直线段创建一个面域 <BR> Dim regionobj1 As Variant <BR> Set regionobj1 = ThisDrawing.ModelSpace.AddRegion(curs)<BR> regionobj1(0).Layer = "0"
可运行期间出现"运行时错误"的提示: 说是类型不[匹配,调试出现
-> Set regionobj1 = ThisDrawing.ModelSpace.AddRegion(curs) 不用Set,因为regionobj1不是对象,而是对象变体数组。 谢谢指点!
检查好多遍都没发现这个问题
页:
[1]