AcadDocument_ObjectModified

AcadDocument_ObjectModified

Anonymous
Not applicable
488 Views
6 Replies
Message 1 of 7

AcadDocument_ObjectModified

Anonymous
Not applicable
Private Sub AcadDocument_ObjectModified(ByVal Object As Object)
On Error GoTo HdlErr
Object.color = acByLayer

HdlErr:
MsgBox Err.Description & "(" & Err.Number & ")"
End Sub

The Object'Color can't change, why? thanks
0 Likes
489 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
What you are attempting is against the rules.

From VBA Developer Guide, Guidelines for Event Handlers

"You can write data to any object in the database, except the object that
issued the event"

Gary
0 Likes
Message 3 of 7

Anonymous
Not applicable
Gary,Thanks,I agree with you.
The type of object is AcadText,it's color is RGB(0,255,0),my purpose is that when the text's position changed,the color of it changes to bylayer.
when the following code runs,an error show which says"Object is open for reading",the number of error is "-2145386418"
Private Sub AcadDocument_ObjectModified(ByVal Object As Object)
On Error GoTo HdlErr
If TypeOf Object Is AcadText And Object.Layer = "JMD" Then
Dim iCor As AcadAcCmColor
Set iCor = Object.TrueColor
If iCor.Red = 0 And iCor.Green = 255 And iCor.Blue = 0 Then
Object.color = acByLayer
End If
End If

HdlErr:
MsgBox Err.Description & "(" & Err.Number & ")"
Exit Sub
End Sub

what can i do? thanks

JianDan Luo
0 Likes
Message 4 of 7

Anonymous
Not applicable
you could maybe put a procedure command_ended and then change layer of last
0 Likes
Message 5 of 7

Anonymous
Not applicable
Hi,cadger,thanks,that's a good idea,but I have a Doubt, in VBA,how to get the entity which edited last.entlast returns the Elements's name,I want to use HandleToObject(),is that right?

Finally,I use objectmodified to get the object's handle,and then,use handletoobject to get the object in endcommand

thanks

JianDan Luo
0 Likes
Message 6 of 7

Anonymous
Not applicable
maybe something like this, but modified for your use

Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
Select Case UCase(CommandName)
Case "REVCLOUD"
Dim ssetObj As AcadSelectionSet
Set ssetObj = ThisDrawing.SelectionSets.Add(Now())
ssetObj.Select acSelectionSetLast
ssetObj(0).layer = "Revision Cloud"
End Select
End Sub
0 Likes
Message 7 of 7

Anonymous
Not applicable
Hi,cadger,thanks for your help,the ssetObj(0) in your code is the last entity.

Thanks in advance
Best wishes to you and your family

Jiandan Luo
0 Likes