Jump to content

Block References


bigr1822

Recommended Posts

Hey All,

I have searched and Search for what I am about to tell you here and can not find anything on it. There HAS to be a way.

 

I have a Block inserted into a drawing. I want to use the "GetAttributes" Method to get the attributes of that Block, but the only way I can use that is by using the Insert Block Method. I already have the Block Inserted.

 

Does this make any sense?

 

Again, thanks to all of you who respond

 

Big R

Link to comment
Share on other sites

I would imagine that over the years there have been numerous routines written that include attribute extraction. Why the emphasis on using 'GetAttributes'? Please forgive my lack of knowledge.

Link to comment
Share on other sites

Sorry Guys, again I failed to get you enough info. First I am using VB6 to accomplish this. Secondly, what I am trying to do exactly is this. We put info into a database for our TitleBlocks. I have already figured out how to store that info into a user form. Now, what I need to do is put that info into the attributes of that specific block.

 

Again, I have figured that out, but only by inserting the block over and over again. Now I have multiple Block References, I think, or Blocks, with the old attr's and the new attr's???

 

Hope this makes more sense?

 

Big R

Link to comment
Share on other sites

It seems simple enough. Just get a selection set of the blocks or set a BlockRef object to the one you want then do a .getattributes on the block and then change the attrbute by its tag.

 

Public Function SetBlkAttByTag(ByRef vAtts As Variant, ByVal sTag As String, _
Optional sTxt As String = "") As Boolean
'------------------------------------------------------------------------------
'Set attribute textstring
'Arguments:     vAtts - variant list of acadAttributes
'               sTag - Tag name to look for
'               sTxt - attribute text , defaults to non-null (space)
'Returns:       NA
'Revisions:     Added vTxt to allow Empty to be used to avoid error when setting
'               TextString to empty string 20080506
'------------------------------------------------------------------------------
Dim acAtt As AcadAttributeReference
Dim lCnt As Long
Dim vTxt As Variant
'''''''''''''''''''''''''''''''''''''''
On Error GoTo ErrHandler

If sTag = "" Then
   Exit Function
End If
vTxt = IIf(sTxt = "", Empty, sTxt)

For lCnt = LBound(vAtts) To UBound(vAtts)
   Set acAtt = vAtts(lCnt)
   If acAtt.TagString = sTag Then
       acAtt.TextString = vTxt
       SetBlkAttByTag = True
       Exit Function
   End If
Next lCnt

ExitHere:
   Exit Function
ErrHandler:
   Debug.Print Err.description & ":" & Err.Number & ":" & _
    "Function 'SetBlkAttByTag' Failed"
End Function

Link to comment
Share on other sites

borgunit, I am going to show my ignorance here. This is a Function, so I created a Sub to call this function and I can not get it to run, what am I doing wrong???

 

Big R

Link to comment
Share on other sites

Just an FYI, functions can return a value back to whatever calls the function. It can, but does not have to. Subs can't return a value.

Link to comment
Share on other sites

Just a bit more as above you can search all blocks find the correct blocks with the same name if you want to only update 1 single block then you need to re-search the cut down list for a unique attribute value.

 

Eg we have a drainage pit schedule 10 items in the block called schedtext, the first attibute is always unique its the pit name and is not repeated so find all schedtxt's then search for correct pitname change attributes all done. We pick a block to get name and then update schedtxt and the blocks are in different model & layout tabs and it all works great.

 

Like wise I search for blocks same name but update attrib1 in all occurences (title block prelim to issued) search forum here VBA for code

Link to comment
Share on other sites

Thanks to ALL of you guys!!!! I really mean that. I can't stop saying how much this site kicks butt!!!

 

I figured out what I needed to do. I pretty much had all the code already, I just needed to modify some of it, and also took from the help files.

 

Everyone, I hope you have a GREAT weekend!

 

Big R over and out.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...