首先,我觉得你地这条语句就有问题,Line是对象,赋值应该用Set。另外,我觉得一个很好的方法就是使用ObjectID来取得对象: dim ObjLine as acadLine,ObjId as Long dim ObjLineOffset as acadLine objId=objLine.ObjectID ..................... '执行平移动操作 ..................... set ObjLineOffset=thisdrawing.ObjectIdToObject(objId)
可能是line1的类型定义错了,参照帮助文件中,dim line1 as Variant ,不知道1楼是不是一样的。例如:
Sub test() Dim lineobj As AcadLine Dim line1obj As Variant
ThisDrawing.Utility.GetEntity lineobj, point, "select a line:" line1obj = lineobj.Offset(100#) line1obj(0).Layer = "hatch"
End Sub