Sub lengthenline() Dim lineobj As AcadLine Dim p1(0 To 2) As Double Dim p2(0 To 2) As Double p1(0) = 50: p1(1) = 50: p1(2) = 0 p2(0) = 60: p2(1) = 60: p2(2) = 0 setlineobj1 = ThisDrawing.ModelSpace.AddLine(p1, p2) lineobj1.Update Dim p3(0 To 2) As Double Dim p4(0 To 2) As Double p3(0) = 40: p3(1) = 80: p3(2) = 0 p4(0) = 100: p4(1) = 80: p4(2) = 0 Set lineobj2 = ThisDrawing.ModelSpace.AddLine(p3, p4) lineobj1.EndPoint = lineobj2 lineobj1.Update End Sub
dim lineobj1,lineobj2 as acadline的定义声明了一个Variant型变量lineobj1 一个acadline型的变量lineobj2这不是楼上的同学想要的吧?VB的变量声明要写全了dim lineobj1 as acadline,lineobj2 as acadline
Sub lengthenline() Dim lineobj1 As AcadLine,lineobj2 As AcadLine Dim p1(0 To 2) As Double Dim p2(0 To 2) As Double p1(0) = 50: p1(1) = 50: p1(2) = 0 p2(0) = 60: p2(1) = 60: p2(2) = 0 set lineobj1 = ThisDrawing.ModelSpace.AddLine(p1, p2) lineobj1.Update Dim p3(0 To 2) As Double Dim p4(0 To 2) As Double p3(0) = 40: p3(1) = 80: p3(2) = 0 p4(0) = 100: p4(1) = 80: p4(2) = 0 Set lineobj2 = ThisDrawing.ModelSpace.AddLine(p3, p4) lineobj1.EndPoint = lineobj2.startpoint lineobj1.Update End Sub 我的意思是把第一条线段延伸到和第二条相交,而这个交点是未知的,并非是线二的起始点,帮忙想想办法,我们在搞毕业设计,真是没办法