AttachExternalReference Example |
Using Programming Languages other than VBA
Sub Example_AttachExternalReference() ' This example displays all the blocks in the current drawing ' before and after adding an external reference. ' ' This example uses the "city map.dwg" found in the Sample ' directory. If you do not have this drawing, or if it is ' in a different directory, insert a valid path and file name ' for the PathName variable below. Dim InsertPoint(0 To 2) As Double Dim insertedBlock As AcadExternalReference Dim tempBlock As AcadBlock Dim msg As String, PathName As String ' Define external reference to be inserted InsertPoint(0) = 1: InsertPoint(1) = 1: InsertPoint(2) = 0 PathName = "c:\program files\autocad\sample\city map.dwg" ' Display current Block information for this drawing GoSub ListBlocks ' Add the external reference to the drawing Set insertedBlock = ThisDrawing.ModelSpace.AttachExternalReference(PathName, "XREF_IMAGE", InsertPoint, 1, 1, 1, 0, False) ThisDrawing.Application.ZoomAll ' Display new Block information for this drawing GoSub ListBlocks Exit Sub
ListBlocks: msg = vbCrLf ' Reset message For Each tempBlock In ThisDrawing.Blocks msg = msg & tempBlock.name & vbCrLf ' Add Block to list Next MsgBox "The current blocks in this drawing are: " & msg Return End Sub
Comments? |