Graphics

 View Only
  • 1.  API: "Unable to attach scene to non template SceneGroup"

    Posted 11-25-2015 05:44
    Hello,

    I'm trying to code a crawl. I've created a project with a scenegroup (just the group, no extra scenes in it) and a second scene that has the text object on it like you would normaly add to the scenegroup.

    Now i am trying to load the scenegroup, and load the scene, and try to add the scene to the scenegroup, and I get the message Unable to attach scene to non template SceneGroup "SceneGroup1".

    This is the code:

    [CODE]

    // Get the SceneGroup as a scene (is there an other way?)

    engine.GetSceneByID(1, out scene);

    // Turn the scene in a group

    scenegroup = (xpSceneGroup)scene;

    // Get another scene with textline, twice

    engine.GetSceneByID(2, out scene1, true);

    engine.GetSceneByID(2, out scene2, true);

    // Fill the scenes with text

    scene1.GetObjectByName("Text1", out obj1);

    tekst1 = (xpTextObject)obj1;

    tekst1.Text = "This is the first line of this crawl.";

    // Insert scene in the SceneGroup

    scenegroup.AddScene(scene1); //


  • 2.  RE: API: "Unable to attach scene to non template SceneGroup"

    Posted 11-25-2015 14:37
    That error msg indicates that the scenegroup was not a "copy" of a scene group. You can only use addscene on a "copy" of a scene group. However, your code looks correct since you call GetSceneByID which by default makes a copy of the scenegroup unless you add the option third parameter and set it to false.

    I actually added your code as is to a c# project and it works fine for me. I checked scenegroup.SceneCount and it was correctly set to 1 after you call AddScene.

    Try checking scenegroup.IsCopy after the GetSceneByID call to ensure IsCopy is actually set to True.

    You can also try changing `engine.GetSceneByID(1, out scene)` to `engine.GetSceneByID(1, out scene,true)` to explicitly set the scene to be a copy..

    #XPression


  • 3.  RE: API: "Unable to attach scene to non template SceneGroup"

    Posted 11-26-2015 08:14
    Thank you Brian. However the default of AsCopy in GetSceneByID is 'false', not 'true'.

    So changing the code to

    engine.GetSceneByID(1, out scene, true);

    solved my problem.

    #XPression