Reorder paths using python

Dear all,
I’m trying to recreate the same “replace paths” component from grasshopper and I’m losing some information during the process. For example, I’m not able to access the keys and values in the processed geometry. Would be gratefull if someone could help with this topic.
The code:

from Grasshopper.Kernel.Data import GH_Path
from Grasshopper import DataTree

dataTreeOUT = DataTreeobject

for i in range(0,fromPath.Count):
TreeData = dataTreeIN.Branch(fromPath[i])



I don’t think that keys/values from referenced rhino geometry are passed/stored in GH. (Maybe something has changed in recent versions?) As far as I know, that info is stored in the rhino document. But, I guess you could store the GUID of the rhino object somehow, and then use that to read from the active rhino doc?
Here are some older examples of how to retrieve user text, (keys/values), from Rhino Objects.

Hi Chris,
My problem is not with the user text retrieval, my problem is with the transformation of the information. As you can see in the image, Replace paths is giving me Referenced Breps while the python code is giving closed brep from which I can not obtain any information on the attributes.

Thank you for taking care

If I had to guess, I would say that the native GH components are somehow keeping track of the actual Rhino Object IDs and/or Rhino Objects.
When you pass your referenced geometry through a component, it becomes a GH object, with a unique GH GUID.
As far as I know, GH objects do NOT store the attributes of their referenced Rhino counterparts.
You will need to someone, retrieve/store the RHINO obj and use that to retrieve attributes. Object attributes, (again, as far as I know,) are stored in the RHINO document.

from ghpythonlib.componentbase import executingcomponent as component
import Grasshopper, GhPython
import System
import Rhino

class MyComponent(component):
    def RunScript(self, x):
        GHobj = x #This is now a Grasshopper Object
        GHobjID = x.ToString() #Grasshopper Object ID
        RobjID = self.Params.Input[0].VolatileData[0][0].ReferenceID.ToString() #Referenced Rhino ObjectID
        Robj = self.Params.Input[0].VolatileData[0][0] #Referenced Rhino Object
        # return outputs if you have them; here I try it for you:
        return (GHobj, GHobjID, RobjID, Robj)

Let’s simplify the problem,
What do I have to do to keep the output information same as the input one?

With a simple a = x script I am obtaining the same results.

It’s not just accessing the internal info of the geometry, it’s avoiding any change in the input geometry.

Thank you in advance,