谢谢了,通过你帮助,我写了如下过程,
Private Sub CommandButton1_Click()
On Error Resume Next Dim BlkRef As AcadBlockReference Dim BlkName As String ' 创建空白选择集 Dim SS As AcadSelectionSet Set SS = CreatSSet Form_SuoFang.Hide ' 设置过滤条件,将所有同名的块过滤出来 Dim FilterType As Variant Dim FilterData As Variant Dim FType(1) As Integer Dim FData(1) As Variant FType(0) = 0 FData(0) = "insert" '图元名 FType(1) = 66 FData(1) = 0 '不带属性 FilterType = FType FilterData = FData SS.SelectOnScreen FilterType, FilterData Dim i As Integer Dim j As Integer Dim Blk As AcadBlock If SS.Count = 0 Then MsgBox "该区域内该块总数为零,请重新选择区域", vbExclamation, "错误" Exit Sub End If ' 遍历选择集中的块 For i = 0 To SS.Count - 1 Set BlkRef = SS(i) BlkName = BlkRef.Name If CheckBox2.Value = True Then SQLSTR = "select * from 放大倍率表 where 块名='" & BlkName & "'" Set ADORSTemp = Nothing ADORSTemp.Open SQLSTR, ADOConnection, adOpenKeyset, adLockOptimistic If ADORSTemp.RecordCount > 0 Then BLX = ADORSTemp.Fields("倍率X").Value BLY = ADORSTemp.Fields("倍率Y").Value BLZ = ADORSTemp.Fields("倍率Z").Value Else BLX = 1 BLY = 1 BLZ = 1 End If Else If BlkName = ComboBox1.Text Then BLX = TextBox1.Text BLY = TextBox2.Text BLZ = TextBox3.Text Else BLX = 1 BLY = 1 BLZ = 1 End If End If BlkRef.XScaleFactor = BLX BlkRef.YScaleFactor = BLY BlkRef.ZScaleFactor = BLZ
Next MsgBox "放大成功!!!", vbExclamation, "提示" End Sub |