IsXRef Example |
Using Programming Languages other than VBA
Sub Example_IsXRef() ' This example cycles through each Block object in a drawing ' and determines the style of each Block by accessing the ' IsLayout and IsXRef properties. A Block ' object is also added at runtime so the results are mixed and do not only ' come from the default Blocks. Dim circleObj As AcadCircle Dim centerPoint(0 To 2) As Double, InsertPoint(0 To 2) As Double Dim radius As Double Dim newBlock As AcadBlock, insertedBlock As AcadBlockReference Dim tempBlock As AcadBlock Dim msg As String ' Define the Circle object that will be inserted into the block centerPoint(0) = 0: centerPoint(1) = 0: centerPoint(2) = 0 InsertPoint(0) = 1: InsertPoint(1) = 1: InsertPoint(2) = 0 radius = 0.5 ' Create a new block to hold the Circle object Set newBlock = ThisDrawing.Blocks.Add(centerPoint, "CBlock") ' Add the Circle object to the new block object Set circleObj = ThisDrawing.Blocks("CBlock").AddCircle(centerPoint, radius) ' Add the new block to model space Set insertedBlock = ThisDrawing.ModelSpace.InsertBlock(InsertPoint, "CBlock", 1, 1, 1, 0) ThisDrawing.Application.ZoomAll msg = vbCrLf & vbCrLf For Each tempBlock In ThisDrawing.Blocks If Not (tempBlock.IsLayout) And Not (tempBlock.IsXRef) Then ' Block is simple msg = msg & tempBlock.name & ": Simple" ElseIf tempBlock.IsXRef Then ' Block is an external reference msg = msg & tempBlock.name & ": External Reference" If tempBlock.IsLayout Then ' Block also contains layout geometry msg = msg & tempBlock.name & " and Contains Layout Geometry" End If ElseIf tempBlock.IsLayout Then ' Block contains layout geometry msg = msg & tempBlock.name & ": Contains Layout Geometry" End If msg = msg & vbCrLf ' Move to next line Next ' Display Block information for this drawing MsgBox "Blocks in this drawing have the following styles: " & msg End Sub
Comments? |