特急!请大家都帮忙看看
我先通过vba在autocad中划出一些点(是通过ThisDrawing.ModelSpace.AddPoint语句实现),然后将这些点用直线连接成图形通过(ThisDrawing.ModelSpace.AddLine(PT1, PT2))实现的,我现在的问题是如果要是改变其中的任意的一个点的坐标想让和它所连接的直线也随之变化,我不知道如何实现。但是在lisp中好象是用反应器,那么在vba中是如何实现呢。请各位老师教教。最好给写些程序代码。 本帖最后由 作者 于 2004-11-9 14:03:27 编辑 <br /><br /> 点的变量就设PT1,PT2等啊!Sub test()<BR>' 定义点1的位置<BR>Dim pointobject As AcadPoint<BR>Dim point1(0 To 2) As Double<BR>point1(0) = 0: point1(1) = 0: point1(2) = 0<BR>' 创建点1<BR>Set pointobject = ThisDrawing.ModelSpace.AddPoint(point1)' 定义点2的位置<BR>Dim pointobject1 As AcadPoint<BR>Dim point2(0 To 2) As Double<BR>point2(0) = 0: point2(1) = 100: point2(2) = 0<BR>' 创建点2<BR>Set pointobject1 = ThisDrawing.ModelSpace.AddPoint(point2)
' 定义直线<BR>Dim line As AcadLine<BR>' 创建直线<BR>Set line = ThisDrawing.ModelSpace.AddLine(point1, point2)
' 移动后的点<BR>' 定义点3的位置<BR>Dim pointobject2 As AcadPoint<BR>Dim point3(0 To 2) As Double<BR>point3(0) = 0: point3(1) = 200: point3(2) = 0<BR>' 创建点3<BR>Set pointobject2 = ThisDrawing.ModelSpace.AddPoint(point3)
' 定义点4的位置<BR>Dim pointobject3 As AcadPoint<BR>Dim point4(0 To 2) As Double<BR>point4(0) = 0: point4(1) = 300: point4(2) = 0<BR>' 创建点4<BR>Set pointobject3 = ThisDrawing.ModelSpace.AddPoint(point4)
pointobject.Move point1, point3 '改变(移动)点的坐标<BR>pointobject1.Move point2, point4 '改变(移动)点的坐标
line.StartPoint = point3 ' 点的坐标被改变(移动)后线的起始点也跟着改变(移动)<BR>line.EndPoint = point4 ' 点的坐标被改变(移动)后线的起始点也跟着改变(移动)
' 缩放试图<BR>ZoomAll
End Sub
请问你要的是这种结果吗? 不是你认为的,这样的我已经实现,我是想如果改变任意的点的坐标,那么和它所连接的直线就会自动的也随之改变。可能要利用反反应器吧 <BR>Dim point1(0 To 2) As Double<BR>point1(0) = 0: point1(1) = 0: point1(2) = 0<BR><BR>Dim point2(0 To 2) As Double<BR>point2(0) = 0: point2(1) = 100: point2(2) = 0
<BR>Dim line As AcadLine<BR>Set line = ThisDrawing.ModelSpace.AddLine(point1, point2)
point1(0) = 100: point1(1) = 100: point1(2) = 0
line.StartPoint = point1<BR>
line.Update
把改变了的点附给直线的端点就可以达到该目的。 各位大哥,这些我知道,但是我考虑的是如果操作者直接在autocad环境下利用鼠标直接选取某个点,然后改变它的坐标那么直线还你能自动的跟随着点来改变吗? 夹点不是有该功能吗? 老师什么是夹点,可以教教我吗?能给段程序看看吗? 用事件做,给点附扩展数据,把直线的Handle放在里面 在图上选中点及直线,用鼠标点中它们的共同特征位置,移到想要的地方 雪山飞狐老师,可以说的再清楚些吗?最好给些代码让我好好学习学习。谢谢了!!
页:
[1]
2