简体   繁体   中英

How to destroy a HARFANG object from a scene?

I would like to know how to destroy an object from a HARFANG scene? I'm using the Python HG API

I tried calling hg.DestroyObject(Object) and scene.DestroyObject(Object) but both failled.

Should I call the method differently or is my object referenced incorrectly (the object was created with Object = hg.CreateObject(...) )?

If you need to destroy what you call an "object" but is actually a node carrying an object component, you have to make your way back to the node.

By addressing only the object level you will destroy the component but the node will still be there...

What's happening here is that CreateObject has returned a node that contains this:

+-- node --+
           |
           +-- transform (component)
           |
           +-- object (component)

...indeed, your confusion is understandable: what you call an "object" by its generic definition is actually an object geometry.

anways... to destroy your "object" (actually your node) you just have to call my_scene.DestroyNode(my_node) followed by a my_scene.GarbageCollect()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM