Replace Parent Obj And Maintain History


Say I have two crvs that are lofted into a srf. Can I replace one of the curves, as in doc.Objects.Replace(crvA, crvB) to maintain the history? Maybe an undocumented command that swaps the GUID of two objs?

And just to be sure, the only way you can clone an object and its history is to import them?

(Pascal Golay) #2

Hi Eric - you can try something like this python - the second curve gets the ID of the first, the first gets a new id.

import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc

def ReplaceParentCurve():
    id1 = rs.GetObject("Select the curveto replace.", 4, preselect=True)
    if not id1: return
    id2 = rs.GetObject("Select the replacement curve.", 4)
    if not id2: return
    crv2 = sc.doc.Objects.Find(id2).Geometry
    sc.doc.Objects.Replace(id1, crv2)

if __name__ == "__main__":ReplaceParentCurve()



Thanks, Pascal. And there’s no way to clone something with its history other than import? I asked in V5, but just wanted to make sure in V6.

(Pascal Golay) #4

Hello - as far as I know that is the only available trick…