The method I posted is the only way I know in vba.
This will keep a block ref name "BlockName" from
being deleted. Add the code to your "ThisDrawing"
class and change "BlockName" to the block you
dont' want deleted. Note: not meant to be complete
code - test and edit!~
[code]
Dim layerLocked As String
Const blockName As String = "BlockName"
Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
Select Case CommandName
Case "ERASE", "CUTCLIP"
Dim ss As AcadSelectionSet
Dim ent As AcadEntity
Set ss = ThisDrawing.PickfirstSelectionSet
For Each ent In ss
If TypeOf ent Is AcadBlockReference _
And ent.Name = blockName Then
Dim layer As AcadLayer
Set layer = ThisDrawing.Layers(ent.layer)
layer.Lock = True
layerLocked = layer.Name
ThisDrawing.SendCommand Chr(27) & Chr(27)
End If
Next ent
End Select
End Sub
Private Sub AcadDocument_SelectionChanged()
If Not layerLocked = "" Then
Dim layer As AcadLayer
Set layer = ThisDrawing.Layers(layerLocked)
layer.Lock = False
layerLocked = ""
End If
End Sub
[/code]
wrote in message news:5624462@discussion.autodesk.com...
I want to control the values of a block atributtes with a an access database
link. It´s very important that nobody delete this block by a error. This
block will be linked by its handler so always must be the same block. The
drawing will be revised several times , the changes in these revisions will
be controled by a database linked to the drawing and reflected in the
atributtes on the block i want to lock.
Thanks for your interest in helping.