Home AutoCad VB Search and Zoom object
08 | 02 | 2012
Main Menu
Search
Paypal Donation
So we can continue and expand this site
Content View Hits : 455709
Search and Zoom object PDF Print E-mail
User Rating: / 1
PoorBest 
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

View source
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
 
Show/Hidden vbnet code
View source
 
 
	Sub test()
 
 
 
	'Add blockname to Search
 
	ZmBlock1 "Blockname"
 
 
 
	End Sub

 
  
 

Add comment


Security code
Refresh

Advertising

LOGON
Sponsored Links