VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

lock an object

6 REPLIES 6
Reply
Message 1 of 7
junagore
470 Views, 6 Replies

lock an object

Is it possible to lock an object to avoid the object from deleting?
I need another way than locking the layer object.

Thanks and sorry for my bad English
6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: junagore

junagore said the following On 6/12/2007 4:19 AM:
> Is it possible to lock an object to avoid the object from deleting?
> I need another way than locking the layer object.
>
> Thanks and sorry for my bad English

To keep who from deleting it?

You?
Others in your office?
A client/partner outside your office?

--
R.K. McSwain
http://rkmcswain.blogspot.com
Message 3 of 7
junagore
in reply to: junagore

to keep other from deleting it. I mean that the only way to delete it were by a lisp or vba code.
Message 4 of 7
Anonymous
in reply to: junagore

No sure why you don't want to lock the layer but have a look here.
It just locks the layer to keep from deleting the circle and thens unlocks
it.
http://discussion.autodesk.com/thread.jspa?messageID=4978299

wrote in message news:5623214@discussion.autodesk.com...
Is it possible to lock an object to avoid the object from deleting?
I need another way than locking the layer object.

Thanks and sorry for my bad English
Message 5 of 7
junagore
in reply to: junagore

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.
Message 6 of 7
Anonymous
in reply to: junagore

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.
Message 7 of 7
junagore
in reply to: junagore

Thanks Paul Richardson, I´ll try it.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost