Macro command for Scaling Operation using BoxEdit

Hey guys thanks in advance, I am dealing with several .step 3d parts which need to be imported and converted to flat panels. I have figured out a way to automate most of the process using Macro’s one part that I am having problems with is a scaling holes (which are sketched circles) to clearance size. I have been using Group and BoxEdit manually to do this. I would like to know how to write a macro for the box edit scaling command.

Hello - BoxEdit not really macro-able in the sense that I tihnk you want. It really sounds like you need to do a little bit of scripting here. What was BoxEdit going to do, exactly, if you could tell it what to do? Is the fact that it can scale from the bounding box center ‘the thing’?


Yes Pascal, scaling from the bounding box center is important as each part has over 100 circles which need to be scale by a factor of 1.5 about their center. Selecting this group of circles is easy using the SelColor option. Scripting would be nice but I donot really know scripting.

Hello - here’s a very quick shot at that:

import Rhino
import scriptcontext as sc
import rhinoscriptsyntax as rs

def ScaleCircles():
    def CircleFilter( rhino_object, geometry, component_index):
        if geometry.TryGetCircle()[0]:
            return True
        return False

    ids = rs.GetObjects("Select circles", 4, preselect=True, custom_filter = CircleFilter)
    if not ids: return
    factor = 1.5
    if sc.sticky.has_key('CIRCLE_SCALE'):
        factor = sc.sticky['CIRCLE_SCALE']
    factor = rs.GetReal("Scale factor", factor)
    if not factor: return
    sc.sticky['CIRCLE_SCALE'] = factor
    for id in ids:
        crv = rs.coercecurve(id)
        rc, circle = crv.TryGetCircle()
        if rc:
            circle.Radius = circle.Radius*factor
            sc.doc.Objects.Replace(id, circle)

if __name__ == "__main__":

To use the Python script use RunPythonScript, or a macro:

_-RunPythonScript "Full path to py file inside double-quotes" (977 Bytes)


Thanks a tonne Pascal that’s exactly what I needed.