wangyancai 发表于 2005-6-8 23:49:00

[VBA]

<FONT color=#000000>Sub lengthenline()<BR>Dim lineobj As AcadLine<BR>Dim p1(0 To 2) As Double<BR>Dim p2(0 To 2) As Double<BR>p1(0) = 50: p1(1) = 50: p1(2) = 0<BR>p2(0) = 60: p2(1) = 60: p2(2) = 0<BR>setlineobj1 = ThisDrawing.ModelSpace.AddLine(p1, p2)<BR>lineobj1.Update<BR>Dim p3(0 To 2) As Double<BR>Dim p4(0 To 2) As Double<BR>p3(0) = 40: p3(1) = 80: p3(2) = 0<BR>p4(0) = 100: p4(1) = 80: p4(2) = 0<BR>Set lineobj2 = ThisDrawing.ModelSpace.AddLine(p3, p4)<BR>lineobj1.EndPoint = lineobj2<BR>lineobj1.Update<BR>End Sub</FONT>


<FONT color=#000000></FONT>

xxsheng 发表于 2005-6-9 08:50:00

第一、变量定义问题dim lineobj1,lineobj2 as acadline


第二、setlineobj1 = ThisDrawing.ModelSpace.AddLine(p1, p2)<BR>set和lineobj1中间加空格----------


第三,lineobj1.EndPoint = lineobj2???这句什么意思?线一的末端点等于线一???lineobj1.EndPoint = lineobj2.startpoint

今晚打老虎 发表于 2005-6-9 09:42:00

dim lineobj1,lineobj2 as acadline的定义声明了一个Variant型变量lineobj1       一个acadline型的变量lineobj2这不是楼上的同学想要的吧?VB的变量声明要写全了dim lineobj1 as acadline,lineobj2 as acadline

wangyancai 发表于 2005-6-9 19:37:00

[VBA]

Sub lengthenline()<BR>Dim lineobj1 As AcadLine,lineobj2 As AcadLine<BR>Dim p1(0 To 2) As Double<BR>Dim p2(0 To 2) As Double<BR>p1(0) = 50: p1(1) = 50: p1(2) = 0<BR>p2(0) = 60: p2(1) = 60: p2(2) = 0<BR>set lineobj1 = ThisDrawing.ModelSpace.AddLine(p1, p2)<BR>lineobj1.Update<BR>Dim p3(0 To 2) As Double<BR>Dim p4(0 To 2) As Double<BR>p3(0) = 40: p3(1) = 80: p3(2) = 0<BR>p4(0) = 100: p4(1) = 80: p4(2) = 0<BR>Set lineobj2 = ThisDrawing.ModelSpace.AddLine(p3, p4)<BR>lineobj1.EndPoint = lineobj2.startpoint<BR>lineobj1.Update<BR>End Sub<BR>我的意思是把第一条线段延伸到和第二条相交,而这个交点是未知的,并非是线二的起始点,帮忙想想办法,我们在搞毕业设计,真是没办法

雪山飞狐_lzh 发表于 2005-6-9 20:27:00

用IntersectWith函数求交点
页: [1]
查看完整版本: [VBA]