@cristian.donaire.roj wrote:
Hello,
I have a question with scripting when assigning a userString to a mesh. I leave two scripts but only one works.#This Works import Rhino import scriptcontext as sc go = Rhino.Input.Custom.GetObject() go.SetCommandPrompt("Select Mesh") go.GeometryFilter = Rhino.DocObjects.ObjectType.Mesh go.GetMultiple(1, 0) objRefs = [] if go.CommandResult()==Rhino.Commands.Result.Success: objRefs = go.Objects() go.Dispose() for objRef in objRefs: mesh = objRef.Mesh() textString = "This is a Mesh" meshCopy = mesh.Duplicate() meshCopy.SetUserString("key",textString) sc.doc.Objects.AddMesh(meshCopy) userText = meshCopy.GetUserString("key") print userText
With this other form I can not do the same
import Rhino import scriptcontext as sc go = Rhino.Input.Custom.GetObject() go.SetCommandPrompt("Select Mesh") go.GeometryFilter = Rhino.DocObjects.ObjectType.Mesh go.GetMultiple(1, 0) objRefs = [] if go.CommandResult()==Rhino.Commands.Result.Success: objRefs = go.Objects() go.Dispose() for objRef in objRefs: mesh = objRef.Mesh() textString = "This is a Mesh" meshCopy2 = mesh.Duplicate() #This part don´t Works atributtes = Rhino.DocObjects.ObjectAttributes() atributtes.SetUserString("key2",textString) sc.doc.Objects.AddMesh(meshCopy2,atributtes) userText = meshCopy2.GetUserString("key2") print userText
Any suggestions? Please help me.
SetGetUserString.3dm (2.5 MB)
Posts: 1
Participants: 1