|
Tutorials
|
|
The Function below shows how to search modelspace for blocks and them Zoom them in to the center of the screen.
Show/Hidden vbnet code Function ZmBlock1(ByVal Blockname As String)
'****************************************
'*** Code from VisibleVisual.com ********
'****************************************
On Error Resume Next
'Search All blocks in Modelspace and Zoom when found
Dim minPt As Variant
Dim maxPt As Variant
Dim varPt As Variant
Dim objBlkRef As AcadBlockReference
Dim StrYesNo As String
For Each objBlkRef In ThisDrawing.ModelSpace
'Set Blockname to search
If objBlkRef.Name = Blockname Then
'If found then Zoom object
objBlkRef.GetBoundingBox minPt, maxPt
ZoomWindow minPt, maxPt
'Ask Users Input to search for more
ThisDrawing.Utility.InitializeUserInput 0, "Y N"
StrYesNo = ThisDrawing.Utility.GetKeyword(vbCr & "Do you wish to search modelspace for the next block?[Y/N]:")
If StrYesNo <> "Y" Then Exit Function
End If
ThisDrawing.Utility.Prompt "Done. No more blocks found..."
Next
End Function
|