SuperDDD Posted October 25, 2012 Posted October 25, 2012 Greetings All My VBScript is having trouble trying to read block attributes - an error message keeps stating that an Object is required for line #34 chr #10 (800A01A8). Any ideas?. Thanks in advance. DDD Dim fso Dim oFolder Dim colFiles Dim oFile Dim oAcad Dim pSpace Dim i Dim c Dim ent Dim varAtt Set fso = WScript.CreateObject("Scripting.FileSystemObject") If fso.FolderExists(WScript.Arguments(0)) Then Set oFolder = fso.GetFolder(WScript.Arguments(0)) Set oAcad = CreateObject("AutoCAD.Application") oAcad.Visible = True Set colFiles = oFolder.Files For each oFile in colFiles if Right(oFile.Name, 3) = "dwg" Then oAcad.Documents.Open oFile Set doc = oAcad.ActiveDocument Set pSpace = doc.PaperSpace For c = 0 To pSpace.Count -1 Set ent = pSpace.Item(c) If ent.EntityName = "AcDbBlockReference" Then 'LINE 30====== If ent.HasAttributes Then varAtt = ent.GetAttributes For i = LBound(varAtt) To UBound(varAtt) If varAtt.Item(i).TagString = "TITLE1" Then MsgBox varAtt.TegxtString End If Next End If End If Next End If Next End If Quote
Tyke Posted October 25, 2012 Posted October 25, 2012 First of all welcome to the Forum. Try removing the spelling mistake from line #35 first. MsgBox varAtt.TegxtString should be "MsgBox varAtt.TextString" Put a break in at line #33 and examine the contents of varAtt. It would appear that varAtt is empty, hence the error message. Quote
SuperDDD Posted October 26, 2012 Author Posted October 26, 2012 Thanks for your advice. Quite so - I mistyped the TextString.... When you say 'break' I assume you mean 'Exit For' - trouble is that the varAtt variable loses its value... Quote
BlackBox Posted October 26, 2012 Posted October 26, 2012 I believe that Tyke means a break point, as in so that you could inspect the value of varAtt. That said, I'm not sure what IDE one would apply a break point in, given that VBScript can be coded in Notepad, etc.. Quote
Tyke Posted October 26, 2012 Posted October 26, 2012 I believe that Tyke means a break point, as in so that you could inspect the value of varAtt. That said, I'm not sure what IDE one would apply a break point in, given that VBScript can be coded in Notepad, etc.. Correct on both points RenderMan, thanks for clearing the point. Would it be possible to print the value of "varAtt" to the command line? Something like the Debug.Print method. I don't have any experience with VBScript. Quote
BlackBox Posted October 26, 2012 Posted October 26, 2012 Correct on both points RenderMan, thanks for clearing the point. No worries; happy to help. FWIW - This has been a topic burning a hole in my suggestion box... Specifically to segregate the VBA/VBScript from .NET (and perhaps even ARX?) into separate forums. I don't know how many times I've gotten to the end of an OP only to realize that it's a request for help with VBA, which I am only loosely adept (I jumped straight from Visual LISP into .NET). Would it be possible to print the value of "varAtt" to the command line? Something like the Debug.Print method. I don't have any experience with VBScript. Not sure how to Debug.Print, but I know that the MsgBox function works well. Separately, I am seemingly mistaken... After a quick search on how to debug VBScript, apparently one can use Visual Studio as the IDE (oops! ). This thread has very clear instructions on how to debug using Visual Studio 2010 (see the two posts marks as answers just under to OP). This post offers yet another option that may be of help to the OP. HTH Quote
BlackBox Posted October 26, 2012 Posted October 26, 2012 FWIW - This has been a topic burning a hole in my suggestion box... Specifically to segregate the VBA/VBScript from .NET (and perhaps even ARX?) into separate forums. I don't know how many times I've gotten to the end of an OP only to realize that it's a request for help with VBA, which I am only loosely adept (I jumped straight from Visual LISP into .NET). ... Oh yeah, almost forgot one... Now Autodesk has added DesignScript to the myriad of programming languages. Quote
Recommended Posts
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.