Remove gh component with python script

Hi every one ,

i’ve got a problems , I’m trying to remove gh component with Rhinoscript . Here is the code we tried:

if x:
    for obj in ghObjects:
        name = obj.NickName
        guid = obj.InstanceGuid
        Guid.append(guid)
        
        Names.append(name)
        print Name
        #gh.Kernel.IGH_DocumentObject.ComponentGuid.SetValue(
            #gh.Kernel.GH_Document.RemoveObject(ghDoc ,obj,True)

But i think Kernel is not the good library, do you now wich library i have to use?

Thanks you very much

@giuliopiacentino

I have a method, but it is not perfect.,Maybe you need gh.Kernel.GH_Document.NewSolution(ghDoc,False).


I hope this help you.
this is my GhFile:Remove_gh_components.gh (7.3 KB)