set/unset parent

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
D3CEPTION
Senior Member
Posts: 129
Joined: Tue Jan 26, 2016 1:24 pm
Location: Switzerland

set/unset parent

Postby D3CEPTION » Tue Jan 24, 2017 8:12 pm

im trying to unset a parent to an entity after setting it this way:

Syntax: Select all

ent.set_parent(parententity.pointer)


this is how i would think to remove it, but doesnt work:

Syntax: Select all

ent.set_parent(Entity(0).pointer)


error is:

Code: Select all

Exception ignored in: <bound method __del__ of <entities.helpers.EntityMemFuncWrapper object at 0x2E838BC0>>
TypeError: No registered converter was able to extract a C++ pointer to type class CPointer from this Python object of type EntityMemFuncWrapper


my previous working method was this:

Syntax: Select all

parententity.targetname = "name"
ent.call_input("SetParent",parententity.targetname)
ent.call_input("SetParent","")
User avatar
D3CEPTION
Senior Member
Posts: 129
Joined: Tue Jan 26, 2016 1:24 pm
Location: Switzerland

Re: set/unset parent

Postby D3CEPTION » Tue Jan 24, 2017 8:17 pm

will ent.clear_parent() remove the parent?
User avatar
D3CEPTION
Senior Member
Posts: 129
Joined: Tue Jan 26, 2016 1:24 pm
Location: Switzerland

Re: set/unset parent

Postby D3CEPTION » Tue Jan 24, 2017 8:22 pm

okay clear_parent() actually does remove the parent correctly. the error i had was due to not setting the .model_name
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: set/unset parent

Postby L'In20Cible » Wed Jan 25, 2017 12:33 am

You can directly pass an Entity instance to set_parent, no need to retrieve its pointer yourself.
User avatar
D3CEPTION
Senior Member
Posts: 129
Joined: Tue Jan 26, 2016 1:24 pm
Location: Switzerland

Re: set/unset parent

Postby D3CEPTION » Wed Jan 25, 2017 2:10 am

is it also possible to check for a parents entity existance?

like this:

Syntax: Select all

if ent.parent:
print("ent has parent")


Syntax: Select all

if ent.get_parent():
print("ent has parent")
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: set/unset parent

Postby satoon101 » Wed Jan 25, 2017 2:16 am

We don't currently have parent in our entity data, but one of these properties will probably work (all a part of CBaseEntity). I'm unable to test, currently.

Code: Select all

    m_Network.m_hParent
    m_iParent
    m_pParent
Image
User avatar
D3CEPTION
Senior Member
Posts: 129
Joined: Tue Jan 26, 2016 1:24 pm
Location: Switzerland

Re: set/unset parent

Postby D3CEPTION » Wed Jan 25, 2017 2:25 am

yeah, im looking through some old code too where i used ent.get_property_int("m_pParent"). its btw returning the inthandle/-1.

might be worth adding .parent as playerentity imo
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: set/unset parent

Postby L'In20Cible » Wed Jan 25, 2017 2:27 am


Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 9 guests