Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem Getting AcadBlockReference Object

4 REPLIES 4
Reply
Message 1 of 5
dhaverstick
401 Views, 4 Replies

Problem Getting AcadBlockReference Object

Has anyone else had problems getting an AcadBlockReference object by setting it this way: Set AcadBlockRef = ModelSpaceObj.Item("AcadBlockRefName") where "AcadBlockRefName" is the name of the block reference object. Sometimes this method works and sometimes it doesn't. The only way I can get the BlockRef object 100% of the time is by iterating through all the items in Modelspace like this
For Each EntityObj in ModelSpaceObj
If TypeOf EntityObj is AcadBlockReference Then
Set AcadBlockRef = EntityObj
If AcadBlockRef.Name = "AcadBlockRefName" Then
Exit For
Endif
Next


Thanks,

Darren
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: dhaverstick

Where did you get the idea that the Item method accepts the name of a block reference? It doesn't. Common sense would suggest that since there can be more than one insertion of a block of a given name, that you could not use the name as an index key. -- http://www.caddzone.com AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005 http://www.acadxtabs.com "dhaverstick" wrote in message news:9442839.1098713061273.JavaMail.jive@jiveforum1.autodesk.com... > Has anyone else had problems getting an AcadBlockReference object by > setting it this way: Set AcadBlockRef = > ModelSpaceObj.Item("AcadBlockRefName") where "AcadBlockRefName" is the > name of the block reference object. Sometimes this method works and > sometimes it doesn't. The only way I can get the BlockRef object 100% of > the time is by iterating through all the items in Modelspace like this > For Each EntityObj in ModelSpaceObj > If TypeOf EntityObj is AcadBlockReference Then > Set AcadBlockRef = EntityObj > If AcadBlockRef.Name = "AcadBlockRefName" Then > Exit For > Endif > Next > > > Thanks, > > Darren
Message 3 of 5
Anonymous
in reply to: dhaverstick

In addition to any replies you might receive or already received, you may find more information or responses by posting future VBA related questions in the following discussion group: By NNTP discussion group reader at news://discussion.autodesk.com/autodesk.autocad.customization.vba By HTTP (web-based) interface at http://discussion.autodesk.com/forum.jspa?forumID=33 -- Autodesk Discussion Group Facilitator "dhaverstick" wrote in message news:9442839.1098713061273.JavaMail.jive@jiveforum1.autodesk.com... > Has anyone else had problems getting an AcadBlockReference object by setting it this way: Set AcadBlockRef = ModelSpaceObj.Item("AcadBlockRefName") where "AcadBlockRefName" is the name of the block reference object. Sometimes this method works and sometimes it doesn't. The only way I can get the BlockRef object 100% of the time is by iterating through all the items in Modelspace like this > For Each EntityObj in ModelSpaceObj > If TypeOf EntityObj is AcadBlockReference Then > Set AcadBlockRef = EntityObj > If AcadBlockRef.Name = "AcadBlockRefName" Then > Exit For > Endif > Next > > > Thanks, > > Darren
Message 4 of 5
dhaverstick
in reply to: dhaverstick

1) In my particular case, all block reference objects have unique names. 2) I got the idea of setting object references using the Item method from this discussion group. I tried it and it worked in my test case.
Message 5 of 5
Anonymous
in reply to: dhaverstick

You can use the name form of the item method on the block collection but I am sure the name form does not work in the modelspace collection. Why not use filtered selection sets? Regards, Doug "dhaverstick" wrote in message news:15958284.1098721080141.JavaMail.jive@jiveforum1.autodesk.com... > 1) In my particular case, all block reference objects have unique names. 2) I got the idea of setting object references using the Item method from this discussion group. I tried it and it worked in my test case.

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

Post to forums  

Autodesk Design & Make Report

”Boost