.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Read entities of a blockreference

5 REPLIES 5
Reply
Message 1 of 6
fantarama
477 Views, 5 Replies

Read entities of a blockreference

I have a block that is defined by two other blocks and i need to read the attributes inside them, how can i do? i can read the main blockreference but then?

Second problem: after a selecion using Editor.GetSelection the command line don't came back to Command: status, but it seem that the command is already active and all other functions are stopped (es. it doesn't raise the editor's events)

Thanks
5 REPLIES 5
Message 2 of 6
foruma000256
in reply to: fantarama

problem 1, This is how you process a block to insert attributes after the block has been inserted. The GetEnumerator is the method to see entities inside of a block. Then you just need to find the blockreference inside this block and get to its block table record, then get its enumerator, as deep as you can get. I put the attribute code in here so you can see how it is created/accessed.

btrenum = btr.GetEnumerator
While btrenum.MoveNext
ent = btrenum.Current.GetObject(OpenMode.ForWrite)
If TypeOf ent Is AttributeDefinition Then
Dim attdef As AttributeDefinition = ent
Dim attref As New AttributeReference
attref.SetAttributeFromBlock(attdef, br.BlockTransform)
attref.TextString = attdef.TextString
attColl.AppendAttribute(attref)
trans.AddNewlyCreatedDBObject(attref, True)
End If
End While

Problem 2. Dunno much, I just add ed.WriteMessage "Command: " to clean up the command line later. A vbcr should work too. Or is your problem with the user not escaping out of the getselection command?
Message 3 of 6
Anonymous
in reply to: fantarama

Not sure why you using GetEnumerator(), MoveNext(), and Current (saw it in Reflector's disassembly perhaps?), but you don't use that.

You just use 'For Each', which compiles to the same thing.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

wrote in message news:5981606@discussion.autodesk.com...
problem 1, This is how you process a block to insert attributes after the block has been inserted. The GetEnumerator is the method to see entities inside of a block. Then you just need to find the blockreference inside this block and get to its block table record, then get its enumerator, as deep as you can get. I put the attribute code in here so you can see how it is created/accessed.

btrenum = btr.GetEnumerator
While btrenum.MoveNext
ent = btrenum.Current.GetObject(OpenMode.ForWrite)
If TypeOf ent Is AttributeDefinition Then
Dim attdef As AttributeDefinition = ent
Dim attref As New AttributeReference
attref.SetAttributeFromBlock(attdef, br.BlockTransform)
attref.TextString = attdef.TextString
attColl.AppendAttribute(attref)
trans.AddNewlyCreatedDBObject(attref, True)
End If
End While

Problem 2. Dunno much, I just add ed.WriteMessage "Command: " to clean up the command line later. A vbcr should work too. Or is your problem with the user not escaping out of the getselection command?
Message 4 of 6
foruma000256
in reply to: fantarama

Our friend Jerry W. said so... Although I would much rather use for each if it works. So, where is your book on the subject, I'm sure it would be a best seller. :~)
Message 5 of 6
fantarama
in reply to: fantarama

Thank you for prob#1, for #2 the user select the object, i do what i need with picked pbject but after that the command line don't show the Command: message but the message i've set to the promptoption object. I've added vbcr but it just append blank line!!
Message 6 of 6
foruma000256
in reply to: fantarama

Yea, then use the:

ed.writemessage (vbcr & "Command: ")

to clean it up.

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost