Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5938

LinearDimension.GetTextRectangle beeing weird on generated dims

$
0
0

It seems that GetTextRectangle behaves differently with “generated” dimensions than with the ones “selected” from the model.

The third test (“spooked”) kind of “refresh” the object table (I guess). How could I emulate that without user interaction ?

Tested on Rhino 6 SR35 & 7 SR28

import rhinoscriptsyntax as rs 
import Rhino 
import scriptcontext 
from scriptcontext import doc 
import Rhino.Geometry as rg 


def main() : 
    
    generated()
    selected()
    spooked()

def FindAndGet(dimId, mode):
    dimObj = doc.Objects.Find(dimId).Geometry
    print(mode, dimObj.GetTextRectangle())


def generated():
    dim = rg.LinearDimension(rg.Plane.WorldXY, rg.Point2d(0,0), rg.Point2d(100,0), rg.Point2d(50,0))
    dimId = doc.Objects.Add(dim)
    
    FindAndGet(dimId, "generated")


def selected():
    dimId = rs.GetObject()
    
    FindAndGet(dimId, "selected")

def spooked():
    dim = rg.LinearDimension(rg.Plane.WorldXY, rg.Point2d(0,0), rg.Point2d(100,0), rg.Point2d(50,0))
    dimId = doc.Objects.Add(dim)
    rs.GetObject("don't, just press escape")
    
    FindAndGet(dimId, "spooked")
    
main()

result :

Cheers !
Sylvain

2 posts - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles