|
-
Nov 22nd, 2000, 03:14 AM
#1
Thread Starter
Lively Member
Can I do a VB program to read an Acad R14 Dwg file then do a global search for some text string inside the dwg file. Would appreciate very much if someone from this forum can share their experience or suggest a good reference source on this subject.
-
Nov 22nd, 2000, 07:52 AM
#2
Junior Member
It can be done. I have written thousands of lines of code to automate AutoCAD. Unfortunately, I have not done anything like this and therefore, don't have any sample code to post. Sorry!
-
Nov 22nd, 2000, 08:54 AM
#3
Black Cat
Yes, when you install AutoCAD it will put the appropriate ActiveX Controls/.dlls on your computer. While I don't have any code handy, the logic would be similar to this:
set the reference in VB/VBA etc.
create a AutoCAD object
open the drawing
loop through all items on paperspace or modelspace
if they are an item that has text, manipulate them as desired
close the drawing
close AutoCad
Hope that helps,
Josh
-
Nov 22nd, 2000, 10:57 AM
#4
Thread Starter
Lively Member
Thanks guys! some samples posting should help to save many hours of hard works.
Regards
-
Nov 22nd, 2000, 11:16 AM
#5
Black Cat
I had code that did pretty much what you want to do at one time, but I changed the specs to just deal with Blocks and rewrote the code, and I can't find a backup of the old code for you unfortunately.
AutoCAD actually comes with decent help files for ActiveX/ VB, since you can use VBA within AutoCAD just like with MS Office Programs.
Josh
-
Nov 22nd, 2000, 05:43 PM
#6
Junior Member
CT,
I've done what you are asking. I am a bit pushed for time at the moment so this is a bit rough. If you are still having problems contact me at my e-mail address.
Make sure you have AutoCAD selected in the 'Project / Preferences' menu of VB.
Dim acad As Object
Dim doc As Object
Dim mspace As Object
Dim elem As Object
' Start AutoCAD
Set acad = CreateObject("AutoCAD.Application")
' Make AutoCAD appear
acad.Visible = True
' Define the current drawing as mspace
Set doc = acad.ActiveDocument
Set mspace = doc.ModelSpace
' Open a specific drawing
doc.Open ("darwingname.dwg")
For Each elem In mspace
If (elem.EntityName = "AcDbText") Then
If elem.TextString = "what ever you're looking or" then
etc.
etc.
End If
End if
Next elem
Good luck.
Graham.
-
Nov 22nd, 2000, 07:40 PM
#7
Thread Starter
Lively Member
Once again, many thanks to all that response to my question on the acad. Graham sample code should get me going for now. Will come back with more later.
Kind regards
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|