Home AutoCad VB Insert Block
23 | 02 | 2012
Main Menu
Search
Paypal Donation
So we can continue and expand this site
Content View Hits : 469519
Insert Block PDF Print E-mail
User Rating: / 7
PoorBest 
Tutorials

Add a block to the modelspace. First start of by creating a block in AutoCAD and save it using WBLOCK to the C:\ drive (you can name it Block.dwg) . When completed PURGE the drawing (or open a new one) and add the following code to its VBA instance.  

Buy the hottest AutoCAD software after you play Pai Gow poker using the pai gow poker tips from CasinoBonus.org, also a great place to play roulette online .  

 

Show/Hidden php code

View source
Private Sub InsertBlock1()
 
 
 
	'****************************************
 
	'*** Code from VisibleVisual.com ********
 
	'****************************************
 
	InsertBlock "C:\Block.dwg", 0
 
	'Change the 0 to another value (in degrees) to rotate the block'
 
 
 
	End Sub
 
 
 
	Function InsertBlock(ByVal blockpath As String, ByVal rotation As Double)
 
 
 
	Dim blockobj As AcadBlockReference
 
	Dim insertionPnt As Variant
 
	Dim prompt1 As String
 
 
 
	'set rotation Angle
 
	rotateAngle = rotation
 
	rotateAngle = rotation * 3.141592 / 180#
 
 
 
	'Prompt is used to show instructions in the command bar
 
	prompt1 = vbCrLf & "Enter block insert point: "
 
 
 
	ThisDrawing.ActiveSpace = acModelSpace
 
 
 
	insertionPnt = ThisDrawing.Utility.GetPoint(, prompt1)
 
 
 
	Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, blockpath, 1#, 1#, 1#, rotateAngle)
 
 
 
	'Change Modelspace into Paperspace to insert the block into Paperspace
 
 
 
	End Function

 

The code will get the block, ask you for its insert point and then places it into the modelspace.


 

{googleAds}
<script type="text/javascript"><!--
google_ad_client = "pub-0319650333001257";
/* 728x90, gemaakt 5-11-09 */
google_ad_slot = "9864489589";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
{/googleAds

It could be useful to explode a block upon insertion. To do so add the following line after 'Set blockrefobj......'

Show/Hidden php code

View source
 
 
	BlockRefobj.Explode

Attachments:
FileDescriptionFile sizeDownloads
Download this file (Block.zip)Block.zipInsert Block15 Kb683
 

Add comment


Security code
Refresh

Advertising

LOGON
Sponsored Links