Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

writing to autocad drawing from access database 1

Status
Not open for further replies.

rcnassoc

Technical User
Feb 14, 2007
3
US
I want to write block attribute values into an autocad drawing block by using a key number from one of the block attributes. This value is manually entered in each block in the drawing. The key number has a matching record in an access database and is unique in both the drawing and the database.

Once I find a key number match in the database, I want to then populate the rest of the block's attributes.

All of the names of the attributes in each block in the drawing have a matching field in the database I have created. I need to repeat this action on all blocks in the drawing. I wish to use vba in autocad to execute the action.
autocad2000i, access2002.
Thnks.
 
Thanks for the reply. I looked at faq5800 and have modified it for drawing updates rather than access updates. The only issue is this:

If ssTitleBlock.Count = 0 Then
' The title block wasn't found, notify the user and exit.
'
MsgBox "A Standard title block wasn't found, please correct and try again."
End
End If

' Collect the attributes.
'
varAttribs = AttribExtract(ssTitleBlock(0))

Since ssTitleBlock is an array of acadselections, do I just increment the array counter to get to the next block in the list before passing to the AttibExtract() function?
In other words, what is the easiest way to walk this array and extract the each block in the drawing?
Thanks.
 
Hi rcnassoc,

Actually, ssTtitleBlock is not an array per se, it is a collection. And if the count comes back as 0, it didn't find any "known" title blocks. You control what the selection find with the DXF codes by adding a "list" of known title blocks. In the example below, the selection set will filter out anything that is not a block ("INSERT") and any block name not starting with TB ("TB*"):

Code:
BuildFilter intData, varData, -4, "<and", _
                                  0, "INSERT", _
                                  2, "TB*", _
                              -4, "and>"

Check this link out for more information: faq-5792

To answer your question, if the count comes back with more than 1, you'll need to loop through the count to collect ALL the attributes from ALL the blocks the selection set found.

HTH
Todd
 
Hi TCARPENTER,

Success!
Thank you very much for getting me going. It certainly saved a lot of legwork and debugging. I will post the final code for others to use if you think its a good idea but beware I am a novice at this so error checking is minimal and style is cretaceous. :)

Rcnassoc
 
Hi rcnassoc,

Glad it worked out and by all means post it, I'm sure others would be glad to see it.

Todd
 
Hi Rcnassoc,

I am trying to do the same thing it appears you were trying to do and I would very much appreciate looking at your code. Like you, I am also a novice and I am just looking for a little direction right now. Thanks.

Mazing
 
Hi, I am also trying to do the same thig and would love to see your code. Any chance you could post it here?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top