ZScaleFactor Example

Using Programming Languages other than VBA

Sub Example_ZScaleFactor()
	' This example creates a block containing a circle.
	' It then inserts the block and changes the ZScaleFactor.

	' Create the block
	Dim blockObj As AcadBlock
	Dim insertionPnt(0 To 2) As Double
	insertionPnt(0) = 0#: insertionPnt(1) = 0#: insertionPnt(2) = 0#
	Set blockObj = ThisDrawing.Blocks.Add(insertionPnt, "CircleBlock")

	' Add a circle to the block
	Dim circleObj As AcadCircle
	Dim center(0 To 2) As Double
	Dim radius As Double
	center(0) = 0: center(1) = 0: center(2) = 0
	radius = 1
	Set circleObj = blockObj.AddCircle(center, radius)
   
	' Insert the block
	Dim blockRefObj As AcadBlockReference
	insertionPnt(0) = 2#: insertionPnt(1) = 2#: insertionPnt(2) = 0
	Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, "CircleBlock", 1#, 1#, 1#, 0)
	ZoomAll

	' Find the current ZScaleFactor for the block reference
	Dim currZScaleFactor As Double
	currZScaleFactor = blockRefObj.ZScaleFactor
	MsgBox "The current ZScaleFactor for the block reference is " & blockRefObj.ZScaleFactor, , "ZScaleFactor Example"

	' Change the ZScaleFactor for the block reference
	blockRefObj.ZScaleFactor = currZScaleFactor + 2

	' Change the viewing direction of the viewport
	' to better see the zscale change
	Dim NewDirection(0 To 2) As Double
	NewDirection(0) = -1: NewDirection(1) = -1: NewDirection(2) = 1
	ThisDrawing.ActiveViewport.direction = NewDirection
	ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport
	ZoomAll

	MsgBox "The new ZScaleFactor for the block reference is " & blockRefObj.ZScaleFactor, , "ZScaleFactor Example"

End Sub

 

   Comments?