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

How change text size of dim in pythonscript

$
0
0

@xiix.xoox wrote:

I use ‘Add Aligned Dimension’ in python script but text height so small. I change text height i but not.

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

def GetOffsetMidpoints(pl_ID,dist,plane):
    #get offset figure and offset points
    bb=rs.BoundingBox(pl_ID)
    xform=rs.XformScale(1.1,(bb[0]+bb[2])/2)
    bb=rs.PointArrayTransform(bb,xform)
    pl=rs.coercecurve(pl_ID)
    sharp=Rhino.Geometry.CurveOffsetCornerStyle.Sharp
    off_pl=pl.Offset(bb[2],plane.Normal,dist,sc.doc.ModelAbsoluteTolerance,sharp)
    if off_pl:
        segs=off_pl[0].DuplicateSegments()
        mids=[(seg.PointAtStart+seg.PointAtEnd)/2 for seg in segs]
        return mids
    
#closed planar polyline filter
def pl_filt(rhino_object, geometry, component_index):
    return rs.IsPolyline(geometry) and rs.IsCurveClosed(geometry) and rs.IsCurvePlanar(geometry)

def DimClosedPolylines2():
    msg="Select polylines to dimension"
    pl_IDs=rs.GetObjects(msg,4,preselect=True,custom_filter=pl_filt)
    if not pl_IDs: return
    dist=rs.GetReal("Distance to offset?",5,0)
    if dist is None: return
    
    rs.EnableRedraw(False)
    for pl_ID in pl_IDs:
        verts=rs.PolylineVertices(pl_ID)
        opts=GetOffsetMidpoints(pl_ID,dist,rs.CurvePlane(pl_ID))
        if opts:
            #checksum in case offset went wrong
            if len(opts)+1==len(verts):
                for i in range(len(verts)-1):
                    rs.AddAlignedDimension(verts[i],verts[i+1],opts[i])
DimClosedPolylines2()

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 5793

Trending Articles