Graphics

 View Only
  • 1.  setParent doesn't work?

    Posted 09-07-2016 00:30
    I have a dummy textobject that I want to copy and place in a specific group:

    Dim group, obj As xpBaseObject
    Dim source As xpTextObject
    scene.GetObjectByName("NewsAnimGroup", group)
    scene.GetObjectByName("DummyNewsField", source)
    obj = scene.GetObjectCopy(source)
    obj.Name = "test_object"
    obj.SetParent(group)

    It creates and names the object under scene, but SetParent does not work (and returns false).

    Also does not work if I try it on an object after scene.CreateObject. If I specify the parent in CreateObject it works, but if I use setParent afterwards, it doesn't.



  • 2.  RE: setParent doesn't work?

    Posted 09-08-2016 17:30
    It does look like a bug. SetParent does indeed work, but the Object Manager doesnt redraw to show the new parent. If you change to a different scene and come back, it will show the node with the new parent.

    There is an alternative method you can use which does redraw correctly, using xpScene.MoveTo()

    e.g. (This is a script I attached to a keyboard event, to duplicate and move an object).

    dim scene as xpScene
    dim ob as xpBaseObject
    dim ob1 as xpBaseObject

    engine.GetSceneByName("Scene1", scene, false)
    scene.GetObjectByName("Quad1", ob)
    ob1 = scene.GetObjectCopy(ob)
    scene.GetObjectByName("Group1", ob)
    scene.MoveTo(ob1, ob, MoveMode.mmAddChildLast)


    #XPression