Hi Jeff
I really like the code you posted for the event procedure Object Added, thank you.
I have been messing around with it for the last hour or so.
It is working very except for this part:
oBlkRef.Layer = "Co-I-SYMB-48
The other thing to consider is that the block will be inserted as a non-exploded block but the user will (more then likely) explode it eventually for other reasons.
After the block is exploded, it will then adopt its original layer which was:
Co-I-SYMB
This makes me wonder if my original method of renaming the block from
Co-I-SYMB to Co-I-SYMB-48 if the scale is 48 is a better approach? I do like this method better as well.
I modified your code to this :
Private Sub AcadDocument_ObjectAdded(ByVal Object As Object)
Dim oBlkRef As AcadBlockReference
Dim layer As AcadLayer
If Object.ObjectName = "AcDbBlockReference" Then
Set oBlkRef = Object
Set layer = ThisDrawing.Layers.Item("CO-I-SYMB")
If oBlkRef.Name = "Intercomm1" Then
'or use If oBlkRef.Name Like "SYM*" 'for a wildcard match
Select Case oBlkRef.XScaleFactor
Case Is = 48#, Is = ThisDrawing.Layers.Item("CO-I-SYMB")
layer.Name = ("CO-I-SYMB-48")
Case Is = 96#, Is = ThisDrawing.Layers.Item("CO-I-SYMB")
layer.Name = ("CO-I-SYMB-96")
'Add all other cases.....
End Select
End If
End If
End Sub
Like all of my prior code attemtps, the first inserted block works perfectly but the second inserted block does not.
With the above code, I inserted the Intercomm1 block at 48,
it remaned the layer and all.
After I inserted the second one at 96, It highlighted this line:
Case Is = 48#, Is = ThisDrawing.Layers.Item("CO-I-SYMB")
and said object does not support this method.
Jeff, do you have any idea where the conflict could be?
I think what is happening is that after you insert the second block (scale 96), it still runs through the code that is addressing the scale 48 and there is a conflict.
I wonder if it has to do with the fact that they both share the original layer name CO-I-SYMB?
What do you think?
I hope you understand what I am explaining?
If not, I will clarify
I appreciate the help
Mark