Jump to content

VBScript Block Attribute error


Recommended Posts

Posted

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


Posted

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.

Posted

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...

Posted

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..

Posted
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. :thumbsup:

 

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.

Posted

Correct on both points RenderMan, thanks for clearing the point. :thumbsup:

 

No worries; happy to help. :beer:

 

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. :thumbsup:

 

 

Separately, I am seemingly mistaken... After a quick search on how to debug VBScript, apparently one can use Visual Studio as the IDE (oops! :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

Posted

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. :twisted:

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...