这是随附的代码
- Public Sub insblk(blkname As String, strLayer As String, Optional strVisibilityState As String)
- Dim blkr As AcadBlockReference
- Dim inspt As Variant
- Dim strCurrentLayer As AcadLayer, newLayer As AcadLayer
- Dim dybprop As Variant, i As Integer
- inspt = ThisDrawing.Utility.GetPoint(, "Enter a point: ")
- Set strCurrentLayer = ThisDrawing.ActiveLayer
- Set newLayer = ThisDrawing.Layers.Add(strLayer)
- ThisDrawing.ActiveLayer = newLayer
- Set blkr = ThisDrawing.ModelSpace.InsertBlock(inspt, blkname, 1, 1, 1, 0)
- If blkr.IsDynamicBlock Then
- dybprop = blkr.GetDynamicBlockProperties
- For i = LBound(dybprop) To UBound(dybprop)
- If dybprop(i).PropertyName = "Visibility" Then
- dybprop(i).Value = strVisibilityState
- End If
- Next i
- End If
- ThisDrawing.ActiveLayer = strCurrentLayer
- End Sub
|