VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Reading blocks from model space

5 REPLIES 5
Reply
Message 1 of 6
wilbert.barten
597 Views, 5 Replies

Reading blocks from model space

Hi,

 

I use a routine to read all blocks from model space. It normally reads all blocks but now we have one issue.

A block is not read when it's placed below Y-coordinate -170.

- this is only on certain computers, on other computers it runs fine.

- this is only when the VBA program is started from paper space, if it's started from modelspace it reads all blocks.

 

Code I use to read all blocks:

 

  Set objAutoCad = ThisDrawing.Application

  Set objModelSpace = objAutoCad.ActiveDocument.ModelSpace()

  For Each objEntity In objModelSpace

    With objEntity

    If StrComp(.EntityName, "AcDbBlockReference", 1) = 0 Then

      If VBA.Left(VBA.UCase(objEntity.Name), 2) = "*U" Then

        MyBlockName = VBA.UCase(objEntity.EffectiveName)

      Else

        MyBlockName = VBA.UCase(objEntity.Name)

      End If

...

 

    End If

    End With

  Next

 

Since the problem is not on all computers I expect this problem is related to some setting in AutoCAD.

 

Any advice is appreciated.

 

Regards,

Wilbert.

5 REPLIES 5
Message 2 of 6
Hallex
in reply to: wilbert.barten

Just on the quick glance... Change:
"*U"
on
"`*U"
_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 3 of 6

The extra ' makes no difference.

Message 4 of 6
truss_85
in reply to: wilbert.barten

Add to this,

 

objAutoCad.ActiveSpace = acModelSpace

 
What are the differences between two PC s operating system and acad versions.

Message 5 of 6
wilbert.barten
in reply to: truss_85

Hi,

 

objAutoCad.ActiveSpace = acModelSpace gives me Run-tiem error 438 Object doesn't support this propery or method.

I added:   

ThisDrawing.ActiveLayout = ThisDrawing.Layouts("Model")

 

This solved the problem! THANK YOU!

 

Still strange to me it was running correct on 1 computer and not on another.

Both computers have Windows 7 enterprise, Service Pack 1.

Both computers have AutoCAD 2012 - 64 bits installed.

 

Kind regards,

Wilbert.

Message 6 of 6
truss_85
in reply to: wilbert.barten

I am glad to help. Since microsoft did not give any support to vba autodesk do it. If there is slightly difference between to machines libraries, it is effectable.

 

Best Regards...

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost