明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2282|回复: 1

二次开发教程例子:VB进行修剪(trim)的问题

[复制链接]
发表于 2006-8-22 20:59:00 | 显示全部楼层 |阅读模式
本帖最后由 作者 于 2006-8-24 9:36:16 编辑

 vb6的程序过程:已经画了几个圆,现在画条直线,然后作该直线的偏移阵列,最后用sendcommand命令修剪圆外的直线,只留圆内的直线。

问题:见附件,无论怎么改程序,蓝色虚线的部分无法剪切掉。圆的下部的也剪切不掉。请高手指点。cad2002图

Dim Copyline As AcadLine
    Dim spoint(0 To 2) As Double, epoint(0 To 2) As Double
    Dim Rectangularline() As Object
    dim i as integer
            spoint(0) = -3 * hjw / 2: spoint(1) = R: spoint(2) = 0
            epoint(0) = -3 * hjw / 2: epoint(1) = -R: epoint(2) = 0
    Set Copyline = AcadDoc.ModelSpace.AddLine(spoint, epoint)

NumberOfRows = 1: NumberOfColumns = 0.5 * (hjks + 1) + 2: NumberOfLevels =1
DistBetweenRows = 1: DistBetweenColumns = hjw: DistBetweenLevels = 0
Rectangularline = Copyline.ArrayRectangular(NumberOfRows, NumberOfColumns,  NumberOfLevels, DistBetweenRows, DistBetweenColumns, DistBetweenLevels)

For i = LBound(Rectangularline, 1) To UBound(Rectangularline, 1)  '阵列产生对象数组 
Rectangularline(i).Layer = "主体"
Next i
     Dim det1 As String   
 Dim det2 As String'不希望与cad互动,直接自己画图,剪切。   
For i = LBound(Rectangularline, 1) To UBound(Rectangularline, 1)     
 det1 = axEnt2lspEnt(objcir2)'objcir2是个圆    
 det2 = GetDoubleEntTable(Rectangularline(i), Rectangularline(i).StartPoint)      
AcadDoc.SendCommand "_trim" & vbCr & det1 & vbCr & vbCr & det2 & vbCr & vbCr   
Next i
以下是子函数:是AutoCAD vba 二次开发教程上的。
Public Function GetDoubleEntTable(ByVal entObj As Object, ByVal Pnt As Variant) As String  
 Dim entHandle As String   
 entHandle = entObj.Handle   
 GetDoubleEntTable = "(list(handent " & Chr(34) & entHandle & Chr(34) & _
                     ")(list " & Str(Pnt(0)) & Str(Pnt(1)) & Str(Pnt(2)) & "))"
End Function

Public Function axEnt2lspEnt(ByVal entObj As Object) As String
    Dim entHandle As String
    entHandle = entObj.Handle
    axEnt2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")"
End Function

本帖子中包含更多资源

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

x
 楼主| 发表于 2006-8-23 10:22:00 | 显示全部楼层
那位大虾给看看阿。谢谢了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-26 22:29 , Processed in 0.160894 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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