Public Sub importLifterTemplate(ByRef myDocuments As AcadDocumentManagerExample)
Dim lifterBlock As AcadBlock = Nothing
Dim insertionPt(2) As Double
If lifterTemplateImported Then Exit Sub
Try
lifterBlock = myDocuments.ThisDrawing.Blocks.Item("EasiCADLifter")
lifterBlock.Name = "EasiCADLifterTemp"
Try
Dim filepath As String = System.IO.Path.GetDirectoryName(New System.Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath) + "\\EasiCADLifter.dwg"
Dim lifterBlockRef As AcadBlockReference = myDocuments.ThisDrawing.ModelSpace.InsertBlock(insertionPt, filepath, 1, 1, 1, 0.0)
lifterBlockRef.Delete()
' Delete existing entities from EasiCADLifterTemp block
For Each entity As AcadEntity In lifterBlock
entity.Delete()
Next
Dim newBlk As AcadBlock = myDocuments.ThisDrawing.Blocks.Item("EasiCADLifter")
Dim entities(newBlk.Count - 1) As AcadEntity
For index As Integer = 0 To newBlk.Count - 1
entities(index) = newBlk.Item(index)
Next
newBlk.Delete()
' Copy all the entities to the block
Dim copiedObj As Object = myDocuments.ThisDrawing.CopyObjects(entities, lifterBlock)
Catch ex1 As System.Exception
' ignored
End Try
lifterBlock.Name = "EasiCADLifter"
Dim attrCoreNumber As AcadAttribute
attrCoreNumber = lifterBlock.AddAttribute(75, AcAttributeMode.acAttributeModeNormal, "LifterCoreNumber", insertionPt, "LifterCoreNumber", "")
attrCoreNumber.Visible = False
' Refresh drawing
myDocuments.ThisDrawing.Regen(AcRegenType.acActiveViewport)
Catch ex As System.Exception
Dim filepath As String = System.IO.Path.GetDirectoryName(New System.Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath) + "\\EasiCADLifter.dwg"
Dim lifterBlockRef As AcadBlockReference = myDocuments.ThisDrawing.ModelSpace.InsertBlock(insertionPt, filepath, 1, 1, 1, 0.0)
lifterBlockRef.Delete()
Dim attrCoreNumber As AcadAttribute
lifterBlock = myDocuments.ThisDrawing.Blocks.Item("EasiCADLifter")
attrCoreNumber = lifterBlock.AddAttribute(75, AcAttributeMode.acAttributeModeNormal, "LifterCoreNumber", insertionPt, "LifterCoreNumber", "")
attrCoreNumber.Visible = False
End Try
lifterTemplateImported = True
End Sub