Add atributte

Add atributte

Anonymous
Not applicable
386 Views
2 Replies
Message 1 of 3

Add atributte

Anonymous
Not applicable
Hello people:
The next code add attribute in a existing block, but anyone reason is not adhered :

Sub AddAttribute()
'the block identified
Set objBlock = ThisDrawing.HandleToObject(handleBlock)
'add new atributte
Set objAtributo = objBlock.AddAttribute(1#, acAttributeModeNormal, "New Prompt", insertPoint, "txtFe2", name(1))

End Sub

And change objBlock.AddAttribute for ThisDrawing.ModelSpace.AddAttribute either can't create this attribute. Thanx
0 Likes
387 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
When you post code like this, it would be greatly appreciated if you posted
the declarations too, i.e. what is objBlock dim'ed to? (Naturally it should
be a block, but we don't know that you did that.)

And if you are using a sub, why aren't you passing the data in, such as
handleBlock, or even better, the actual block object? Surely you are not
using global variables?!

You are aware that AddAttribute only works on Block objects, not
BlockReference objects?
If you want to add attributes to already inserted blocks, I'm sure there are
examples in this group.

Sub Test()
Dim pt1(0 To 2) As Double
pt1(0) = 0.25: pt1(1) = 0.25: pt1(2) = 0#
AddAttributeToBlock ThisDrawing.Blocks.Item("Test"), pt1, "Hello"
ThisDrawing.ModelSpace.InsertBlock pt1, "Test", 1#, 1#, 1#, 0#
End Sub

Private Function AddAttributeToBlock(Block As AcadBlock, InsertionPoint As
Variant, NewValue As String) As AcadAttribute
Set AddAttributeToBlock = Block.AddAttribute(1#, acAttributeModeNormal,
"New prompt", InsertionPoint, "txtFe2", NewValue)
End Function


--
R. Robert Bell


wrote in message news:5212087@discussion.autodesk.com...
Hello people:
The next code add attribute in a existing block, but anyone reason is
not adhered :

Sub AddAttribute()
'the block identified
Set objBlock = ThisDrawing.HandleToObject(handleBlock)
'add new atributte
Set objAtributo = objBlock.AddAttribute(1#, acAttributeModeNormal, "New
Prompt", insertPoint, "txtFe2", name(1))

End Sub

And change objBlock.AddAttribute for ThisDrawing.ModelSpace.AddAttribute
either can't create this attribute. Thanx
0 Likes
Message 3 of 3

Anonymous
Not applicable
Hi , thank you for you answer.
sorry I not to do declarations.
I know addAttribute only objBlock.

Thank you very much for you answer.
0 Likes