- 积分
- 73549
- 明经币
- 个
- 注册时间
- 2001-6-7
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2006-4-12 11:43:00
|
显示全部楼层
理解你的意思,你还需要对原来已经插入的图块进行处理。- Public Sub tt1() '以下是变为各种螺丝调用程式
- Dim R As Double
- On Error Resume Next
- Dim Sr As String
- Dim Zm As String
- Dim Shuz As Integer
- Dim Yj As Double
- Sr = InputBox("请输入人要变的东东", "变变", "")
- Zm = Left(Sr, 1)
- Shuz = Mid(Sr, 2)
- Select Case Zm
- Case "m"
- Select Case Shuz
- Case 5
- Yj = 4.3
- Case 6
- Yj = 5.2
- Case 8
- Yj = 6.8
- Case 10
- Yj = 8.6
- Case 12
- Yj = 10.5
- Case 14
- Yj = 12.5
- End Select
- Call Gy1(Shuz, Yj)
- Case "u" '以下是正面沉头的调用公式
- 'Call u(shuz)
- Case Else
- 'Call gy(Val(sr)) '这是变为圆的调用程式
- End Select
- End Sub
-
- Public Sub Gy1(Ls As Integer, Yj As Double)
- On Error Resume Next
- Dim SSetObj1 As AcadSelectionSet '以下是画螺丝的共用程式
- Dim I1 As Integer
- Dim SelObj1 As AcadObject
- Dim blockObj As AcadBlock
- Dim InsertPoint(0 To 2) As Double
- Dim i As Integer
- Dim BlockRefObj As AcadBlockReference
- Dim Pt1 As Variant
- Dim typeArray, dataArray
-
- Const PI = 3.141592654
-
- BuildFilter typeArray, dataArray, -4, "<or", 0, "circle,arc", -4, "<and", 0, "insert", 2, "luosi*", -4, "and>", -4, "or>"
- Set SSetObj1 = PickFirstSSet("please select object:", typeArray, dataArray)
-
- InsertPoint(0) = InsertPoint(1) = InsertPoint(2) = 0
-
- Set blockObj = ThisDrawing.Blocks("luosi" & Ls)
- If Err Then
- Err.Clear
- Set blockObj = ThisDrawing.Blocks.Add(InsertPoint, "luosi" & Ls)
- blockObj.AddArc InsertPoint, Ls / 2, PI, PI / 2
- blockObj.AddCircle InsertPoint, Yj / 2
- End If
-
- For I1 = 0 To SSetObj1.Count - 1
- Set SelObj1 = SSetObj1.Item(I1)
- Select Case SelObj1.ObjectName
- Case "AcDbCircle", "AcDbCrc"
- Pt1 = SelObj1.Center
- Set BlockRefObj = ThisDrawing.ModelSpace.InsertBlock(Pt1, "luosi" & Ls, 1#, 1#, 1#, 0)
- Case "AcDbBlockReference"
- Pt1 = SelObj1.InsertionPoint
- Set BlockRefObj = ThisDrawing.ModelSpace.InsertBlock(Pt1, "luosi" & Ls, 1#, 1#, 1#, 0)
- End Select
- SelObj1.Delete
-
- Next
- End Sub
-
- Public Sub BuildFilter(typeArray, dataArray, ParamArray gCodes())
- Dim fType() As Integer, fData()
- Dim index As Long, i As Long
-
- index = LBound(gCodes) - 1
-
- For i = LBound(gCodes) To UBound(gCodes) Step 2
- index = index + 1
- ReDim Preserve fType(0 To index)
- ReDim Preserve fData(0 To index)
- fType(index) = CInt(gCodes(i))
- fData(index) = gCodes(i + 1)
- Next
- typeArray = fType: dataArray = fData
- End Sub
-
- Function PickFirstSSet(Optional txtTip As String = "", Optional typeArray = -1, Optional dataArray = -1) As AcadSelectionSet
- On Error Resume Next
- ThisDrawing.SelectionSets("PICKFIRST").Delete
- Set PickFirstSSet = ThisDrawing.PickfirstSelectionSet
- If PickFirstSSet.Count = 0 Then
- If txtTip <> "" Then ThisDrawing.Utility.Prompt txtTip
- If IsArray(typeArray) Then
- PickFirstSSet.SelectOnScreen typeArray, dataArray
- Else
- PickFirstSSet.SelectOnScreen
- End If
- Else
- If IsArray(typeArray) Then PickFirstSSet.Select acSelectionSetPrevious, , , typeArray, dataArray
- End If
- End Function
|
|