ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to obtain the bounding box coordinates of an AcDbMText?

2 REPLIES 2
Reply
Message 1 of 3
zhengyunyang2019
235 Views, 2 Replies

How to obtain the bounding box coordinates of an AcDbMText?

I tried using getGeomExtents() to obtain it, but the results are inaccurate.

Sometimes, the height of the border obtained by getGeomExtents may be larger than expected.

For example, with a text consisting of only two lines, the height obtained by getGeomExtents may be equivalent to three lines.

(The border is drawn using getGeomExtents.)

123.jpg

 

If I attempt to reduce the amount of text in this section, then the getGeomExtents obtained is accurate. I hope to always obtain precise borders.

555.jpg

2 REPLIES 2
Message 2 of 3

explode the mtext,get each geoextent,take a try

Message 3 of 3
daniel_cadext
in reply to: 835700012

how about getBoundingPoints?

from pyrx_imp import Rx
from pyrx_imp import Ge
from pyrx_imp import Gi
from pyrx_imp import Db
from pyrx_imp import Ap
from pyrx_imp import Ed
import traceback

def swap(list, pos1, pos2):
    list[pos1], list[pos2] = list[pos2], list[pos1]
    return list

def PyRxCmd_doit():
    try:
        es = Ed.Editor.entSel("\nPick a Mtext: ",Db.MText.desc())
        if es[0]!= Ed.PromptStatus.eOk:
            raise Exception(es) 
        
        mt = Db.MText(es[1])
        
        pts = mt.getBoundingPoints()
        swap(pts,2,3)
        
        Ed.Core.grDraw(pts[0],pts[1], 1, 0)
        Ed.Core.grDraw(pts[1],pts[2], 1, 0)
        Ed.Core.grDraw(pts[2],pts[3], 1, 0)
        Ed.Core.grDraw(pts[3],pts[0], 1, 0)

    except Exception as err:
        traceback.print_exception(err)

 

bp.png

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx

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

Post to forums  

Autodesk Design & Make Report

”Boost