|
问题提出:
VBA没有处理fillet的功能,我用SendCommand调用fillet命令进行了组合,VBA中实现了在倒圆角功能.
关键语句 Dim Command As String
Command = "fillet" + Chr(10) + "R" + Chr(10) + "300" + Chr(10) + Chr(10)
obj_Doc.SendCommand Command
实际运行运行语句如下:
Dim cn As ADODB.Connection
Dim rst As ADODB.Recordset
''
Set cn = New ADODB.Connection
cn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& App.Path & "\directory.mdb;"
Set rst = New ADODB.Recordset
rst.Open "pipeline", cn, adOpenKeyset, adLockPessimistic
rst.MoveFirst
Dim Command As String
Command = "fillet" + Chr(10) + "R" + Chr(10) + "300" + Chr(10) + Chr(10) '设置倒圆角的半径
obj_Doc.SendCommand Command
Dim point1(0 To 2) As Double, point2(0 To 2) As Double, point3() As Double
Dim ii As Integer
ii = 0
Do Until rst.EOF
point1(0) = rst!PointX: point1(1) = rst!PointY: point1(2) = rst!PointZ
rst.MoveNext
If rst.EOF Then
Exit Do
Else
point2(0) = rst!PointX: point2(1) = rst!PointY: point2(2) = rst!PointZ
Set Ent = obj_ModelSpace.addline(point1, point2)
rst.Fields(1).Value = Trim(Ent.Handle) '获取直线的handle数据
End If
Loop
通过数据库,调用两相邻直线段的handle数据,实现倒圆角的功能.
Command = "fillet" + Chr(10) + "(handent " & Chr(34) & Str_Handle(ii) & Chr(34) & ")" & Chr(10) + "(handent " & Chr(34) & Str_Handle(ii + 1) & Chr(34) & ")" & Chr(10)
obj_Doc.SendCommand Command
存在问题:
SendCommand 是将VBA数据整合为Auto CAD的组合命令,现在倒角的功能已经实现,但不能获取生成后的圆弧的ID号,不能对其进行扩展运行,建立三维管道模型.
要找到这个弧的handle我用的方法是for each ent in thisdrawing, 但不能与建立直线相关联.
|
|