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

Why do I get an exception "not open for write" when I try to read a AcadRotatedDim Measurement

4 REPLIES 4
Reply
Message 1 of 5
oransen
192 Views, 4 Replies

Why do I get an exception "not open for write" when I try to read a AcadRotatedDim Measurement

Sometimes when I try to read a rotated dimension property I get an exception.

 

Surely calling Dim.Measurement does not change the entity?

 

Here is the code fragment:

 

        else if (entity.EntityType == Support.ikRotatedDimEnt)
        {
            AcadDimRotated Dim = null;
            try
            {
                Dim = (AcadDimRotated)entity;
                double x = Dim.Measurement; // <--- cause exception
            }
            catch
            {
                ABSup.Log.WriteLn(CLog.Type_e.ekLog, "Skipping a rotated DIM" );
             }
        }

 

Labels (2)
4 REPLIES 4
Message 2 of 5
daniel_cadext
in reply to: oransen

I tried these with Python, no issues

 

import traceback
from pyrx_impx import Rx, Ge, Gi, Db, Ap, Ed, Ax

def PyRxCmd_xdoit1() -> None:
    try:
        dims = []
        ax_app = Ax.getApp()
        for ent in ax_app.ActiveDocument.ModelSpace:
            if ent.ObjectName == 'AcDbRotatedDimension':
                dim = Ax.AcadDimRotated(ent)
                dims.append(dim.Measurement)    
        print(dims)
    except Exception as err:
        traceback.print_exception(err)
        
def PyRxCmd_xdoit2() -> None:
    try:
        dims = []
        ikRotatedDimEnt = 15
        ax_app = Ax.getApp()
        for ent in ax_app.ActiveDocument.ModelSpace:
            if ent.EntityType == ikRotatedDimEnt:
                dim = Ax.AcadDimRotated(ent)
                dims.append(dim.Measurement)   
        print(dims)
    except Exception as err:
        traceback.print_exception(err)
        
Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
Message 3 of 5
oransen
in reply to: daniel_cadext

Many thanks for your reply. Unfortunately it does not always happen, even in C#. Not sure if I'm allowed to share the drawing or not though. I'll get back to you.

Message 4 of 5
daniel_cadext
in reply to: oransen

It could be that those dimensions are associated with some entity, something is causing them to update

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
Message 5 of 5
oransen
in reply to: daniel_cadext

I'll have to investigate deeper I think...

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report