|
发表于 2002-7-24 14:38:00
|
显示全部楼层
是自动选择,以下是我实现的代码:
Public Mydrawing As AcadApplication
Private Sub Command1_Click()
Dim i As Integer
Dim n As Integer
Dim Path_file() As String
Dim Text_temp As String
Dim ssetObj As AcadSelectionSet
Dim m As Integer
Dim Mode As Integer
Dim corner1(0 To 2) As Double
Dim corner2(0 To 2) As Double
Dim entObj As AcadEntity
Dim lineobj As AcadLine
Set Mydrawing = autocad.Application
Ismydrawopen = True
If Mydrawing.ActiveDocument.SelectionSets.Count 0 Then
For m = 0 To Mydrawing.ActiveDocument.SelectionSets.Count - 1
Set ssetObj = Mydrawing.ActiveDocument.SelectionSets.Item(m)
ssetObj.Delete
Next m
End If
Set ssetObj = Mydrawing.ActiveDocument.SelectionSets.Add("lineselect")
Mode = acSelectionSetCrossing
corner1(0) = 105: corner1(1) = 286: corner1(2) = 0
corner2(0) = 96: corner2(1) = 290: corner2(2) = 0
ssetObj.Select Mode, corner1, corner2
a = ssetObj.Count
corner1(0) = 100: corner1(1) = 286: corner1(2) = 0
corner2(0) = 109: corner2(1) = 286: corner2(2) = 0
Set entObj = ssetObj.Item(0)
entObj.Move corner1, corner2
Set ssetObj = Mydrawing.ActiveDocument.SelectionSets.Add("lineselect1")
Mode = acSelectionSetCrossing
corner1(0) = 45: corner1(1) = 285: corner1(2) = 0
corner2(0) = 47: corner2(1) = 282: corner2(2) = 0
ssetObj.Select Mode, corner1, corner2
corner1(0) = 25: corner1(1) = 284.34: corner1(2) = 0
corner2(0) = 108.55: corner2(1) = 284.34: corner2(2) = 0
Set lineobj = Mydrawing.ActiveDocument.PaperSpace.AddLine(corner1, corner2)
lineobj.Linetype = ssetObj.Item(0).Linetype
lineobj.Color = ssetObj.Item(0).Color
lineobj.Layer = ssetObj.Item(0).Layer
ssetObj.Item(0).Delete
entObj.Update
Mydrawing.ActiveDocument.Save
以上代码是在VB下的,CAD的VBA中只要将mydrawing.activedocument改成thisdrawing就行执行。但现在有两个问题,
1)我将代码在VBA中运行可以通过并且正确执行了。但是在VB下就选不到那些线。(线的位置在图纸上是固定的。)
2)我不知道lineobj.Linetype = ssetObj.Item(0).Linetype
lineobj.Color = ssetObj.Item(0).Color
lineobj.Layer = ssetObj.Item(0).Layer
这些代码是不是就能使后加的线与原先的线性质一样,至少打印出来后看不区别?
(原先想把原来的线延长的,可是不会写代码,参考书上也没找到相关内容)
还望各位帮助,指教。谢谢! |
|