企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
https://discourse.mcneel.com/t/scale-objects-by-volume-centroid/28772 你这个问题外网有人问过,如果是gh的话很简单,![](https://img.kancloud.cn/f3/ad/f3ad3ac9149bbdd407417c7caace8f4b_928x446.png) 如果不会gh,只想用rhino的话,那就得借助人家已经写好的代码了,Rhino目前还么的这个功能: ![](https://img.kancloud.cn/43/d2/43d255808ce3c9a3bfc857760a947a30_1105x828.gif) ``` import rhinoscriptsyntax as rs import Rhino import scriptcontext as sc def ScaleEach(): factor=2 objrefs = [] if sc.sticky.has_key("SCALEFACTOR"): factor = sc.sticky["SCALEFACTOR"] while True: go = Rhino.Input.Custom.GetObject() go.AcceptNumber(True, False) optFactor = Rhino.Input.Custom.OptionDouble(factor) go.AddOptionDouble("Scale",optFactor) get_rc = go.GetMultiple(1, 0) if go.CommandResult()!=Rhino.Commands.Result.Success: return go.CommandResult() if get_rc==Rhino.Input.GetResult.Object: for n in range(go.ObjectCount): objrefs.append(go.Object(n)) break elif get_rc == Rhino.Input.GetResult.Number: factor = go.Number() sc.sticky["SCALEFACTOR"] = factor elif get_rc==Rhino.Input.GetResult.Option: factor = optFactor.CurrentValue sc.sticky["SCALEFACTOR"] = factor continue factor = sc.sticky["SCALEFACTOR"] if len(objrefs) == 0: return rs.EnableRedraw(False) for objref in objrefs: Id = objref.ObjectId obj = sc.doc.Objects.Find(Id) bbCen = obj.Geometry.GetBoundingBox(True).Center rs.ScaleObject(Id,bbCen,[factor, factor, factor],False) rs.EnableRedraw(True) ScaleEach() ```