明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1718|回复: 9

[求助]谁帮我看看,为什么offset这一步运行下不去了

[复制链接]
发表于 2003-12-19 09:54:00 | 显示全部楼层 |阅读模式
'运行到offset这一步就直接跳出entrimf子过程返回enttrim
  1. Sub entTrim()
  2.   On Error Resume Next
  3.   Dim ent As AcadEntity
  4.   Dim pnt1 As Variant
  5.   
  6.   ThisDrawing.Utility.GetEntity ent, pnt1, "选择多义线:"
  7.   If Err Then Exit Sub
  8.   entTrimF ent
  9. End Sub

  10. Sub entTrimF(plineObj As AcadEntity)
  11.     Dim offplineObj As AcadEntity
  12.     Dim Coors As Variant
  13.     Dim coorString, cmdString As String
  14.     Dim i As Integer
  15.    
  16.     offplineObj = plineObj.Offset(-0.1) '运行到这一步就直接跳出entrimf子过程返回enttrim
  17.    
  18.     offplineObj.Update
  19.     Coors = offplineObj.Coordinates
  20.     offplineObj.Delete
  21.    
  22.     coorString = ""
  23.     For i = UBound(Coors) To UBound(Coors) Step 3
  24.       coorString = coorString & Coors(i) & "," & Coors(i + 1) & "," & Coors(i + 2) & "," & vbCr
  25.     Next i
  26.     'coorString = Left(coorString, Len(coorString) - 1)
  27.     cmdString = "trim" & vbCr & "(handent """ & plineObj.Handle & """)" & vbCr & _
  28.                 "f" & vbCr & coorString
  29.     ThisDrawing.SendCommand cmdString
  30.    

  31. End Sub
发表于 2003-12-19 09:58:00 | 显示全部楼层
set offplineObj = plineObj.Offset(-0.1)
 楼主| 发表于 2003-12-19 10:22:00 | 显示全部楼层
试过了,还是不行,我把dim offplineobj as acadentity 改为dim offplineobj就行了
发表于 2003-12-19 10:34:00 | 显示全部楼层
offset 返回的是对象的数组

Signature

RetVal = object.Offset(Distance)

RetVal

Variant (array of objects)
An array of the newly created objects resulting from the offset.


所以只能赋给变体了~~~
 楼主| 发表于 2003-12-19 10:42:00 | 显示全部楼层
offset后,原来的对象删除了,我把程序改成这样,可是很奇怪的offplineobj.delete这句又不起作用。
  1. Sub entTrim()
  2.   On Error Resume Next
  3.   Dim ent As AcadEntity
  4.   Dim pnt1 As Variant
  5.   
  6.   ThisDrawing.Utility.GetEntity ent, pnt1, "选择多义线:"
  7.   If Err Then Exit Sub
  8.   entTrimF ent
  9. End Sub

  10. Sub entTrimF(plineObj As AcadEntity)
  11.     Dim offplineObj As Variant
  12.     Dim Coors As Variant
  13.     Dim coorString, cmdString As String
  14.     Dim i As Integer
  15.    
  16.     Set offplineObj = plineObj.Copy
  17.     offplineObj.Offset 0.1
  18.     offplineObj.Update
  19.     Coors = offplineObj.Coordinates
  20.     offplineObj.Delete
  21. end sub  
  22.    
发表于 2003-12-19 10:46:00 | 显示全部楼层
offplineObj 已经成为了一组对象了所以的改成这样offplineObj(0)
 楼主| 发表于 2003-12-19 11:04:00 | 显示全部楼层
再请教一下,offset后原来的多义线还存在吗?下面的代码我在一个文件时运行时原来的多义线存在,但在另一个文件运行时原来的多义线不存在。是不是和某个系统变量有关?
  1. Sub entTrimF(plineObj As AcadEntity)
  2.     Dim offplineObj As Variant
  3.     Dim Coors As Variant
  4.     Dim coorString, cmdString As String
  5.     Dim i As Integer
  6.    
  7.     offplineObj = plineObj.Offset(0.25)
  8.     offplineObj(0).Update
  9.    
 楼主| 发表于 2003-12-19 11:11:00 | 显示全部楼层

帮忙在我的这个文件里运行一下以下代码,运行后原来的多义线位置会自动改变。
在运行代码前用zoom e
运行后在用一下zoom e

  1. Sub entTrim()
  2.   On Error Resume Next
  3.   Dim ent As AcadEntity
  4.   Dim pnt1 As Variant
  5.   
  6.   ThisDrawing.Utility.GetEntity ent, pnt1, "选择多义线:"
  7.   If Err Then Exit Sub
  8.   entTrimF ent
  9. End Sub
  10. Sub entTrimF(plineObj As AcadEntity)
  11.     Dim offplineObj As Variant
  12.     Dim Coors As Variant
  13.     Dim coorString, cmdString As String
  14.     Dim i As Integer
  15.    
  16.     offplineObj = plineObj.Offset(0.25)
  17.     offplineObj(0).Update
  18. end sub

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2003-12-19 11:59:00 | 显示全部楼层
这是个BUG,你查看以前的贴子,解决过这类问题。
 楼主| 发表于 2003-12-19 14:15:00 | 显示全部楼层
谢谢明总,查到那个帖子了。先把要偏移的物体先复制一份,用复制的偏移,然后删除。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-28 10:52 , Processed in 0.190221 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表