能不能帮我看看那里错了!!!!!!!!!!!
Dim acadapp As AcadApplication<BR>Dim d1() As Double<BR>Dim d2() As Double<BR>Dim d0() As Double<BR>Dim data() As String<BR>Dim shuju() As Double<BR>Dim b As Variant<BR>Dim splineobj As Acad3DPolyline<BR>Dim orig(2) As Double<BR>Dim za(2) As Double<BR>Dim xa(2) As Double<BR>Dim ya(2) As Double
<BR>Private Sub Command1_Click()<BR>
ReDim data(0)<BR>i = 0<BR>Open "E:\12月\菜单12.9\barrel.dat" For Input As #1<BR>Do While Not EOF(1)<BR>Line Input #1, data(i)<BR>i = i + 1<BR>ReDim Preserve data(i)<BR>Loop<BR>Close #1<BR>ReDim d1(i - 1, 3)<BR>ReDim d2(i - 1, 3)<BR>ReDim d0(i - 1, 3)<BR>For j = 0 To i - 1<BR>b = Split(data(j), " ")<BR>d1(j, 0) = Val(b(2))<BR>d1(j, 1) = Val(b(3))<BR>d1(j, 2) = Val(b(4))<BR>d2(j, 0) = Val(b(5))<BR>d2(j, 1) = Val(b(6))<BR>d2(j, 2) = Val(b(7))<BR>d0(j, 0) = (d1(j, 0) + d2(j, 0)) / 2<BR>d0(j, 1) = (d1(j, 1) + d2(j, 1)) / 2<BR>d0(j, 2) = (d1(j, 2) + d2(j, 2)) / 2
Next<BR>ReDim shuju(3 * i - 1)<BR>For j = 0 To i - 1<BR>shuju(3 * j) = d0(j, 0)<BR>shuju(3 * j + 1) = d0(j, 1)<BR>shuju(3 * j + 2) = d0(j, 2)<BR>Next
orig(0) = shuju(0)<BR>orig(1) = shuju(1)<BR>orig(2) = shuju(2)<BR>za(0) = shuju(3)<BR>za(1) = shuju(4)<BR>za(2) = shuju(5)<BR>Dim points(0 To 7) As Double<BR> points(0) = 7.5: points(1) = -15<BR>points(2) = 7.5: points(3) = 15<BR> points(4) = -7.5: points(5) = 15<BR> points(6) = -7.5: points(7) = -15<BR>Dim curves(0 To 0) As AcadLWPolyline<BR>Set curves(0) = acadapp.ActiveDocument.ModelSpace.AddLightWeightPolyline(points)<BR>curves(0).Closed = True
<BR>Set splineobj = acadapp.ActiveDocument.ModelSpace.Add3DPoly(shuju)
Call axis(orig(), za(), xa(), ya())<BR>Dim ucsobj As AcadUCS<BR>Set ucsobj = acadapp.ActiveDocument.UserCoordinateSystems.Add(orig, xa, ya, "ucs1")
acadapp.ActiveDocument.ActiveUCS = ucsobj
<BR>transmatrix = ucsobj.GetUCSMatrix()
Dim transmartrix As Variant<BR>curves(0).TransformBy (transmatrix)<BR>Dim regionobj(0 To 0) As Variant<BR>regionobj(0) = acadapp.ActiveDocument.ModelSpace.AddRegion(curves)
Dim solidobj As Acad3DSolid<BR>Set solidobj = acadapp.ActiveDocument.ModelSpace.AddExtrudedSolidAlongPath(regionobj(0), splineobj)
End Sub
Private Sub Form_Load()<BR>On Error Resume Next<BR>Set acadapp = GetObject(, "autocad.application")<BR>If Err Then<BR> Err.Clear<BR> Set acadapp = CreateObject("autocad.application")<BR> If Err Then<BR> MsgBox ("不能运行autocad 2000,请检查是否安装了autocad 2000")<BR> Exit Sub<BR> End If<BR> End If<BR> acadapp.Visible = True<BR>End Sub 拉深时出错,提示要求对象 AddRegion方法得到的是对象数组,而不是单纯的对象,就算对象数组中只有一个对象也是这样。<BR>所以要取得对象数组regionobj中的对象,可以使用regionobj(0)取得。<BR>所以你的<BR>Dim regionobj(0 To 0) As Variant<BR>这句直接改成<BR>Dim regionobj As Variant<BR> 谢了!
页:
[1]