How to work with HyperNurbs



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 05/07/2008 at 08:42, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   10 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    Hi!
    I programmatically made a polygon-object and a hypernurbs-object. Now I want to put the polygon-object under the hypernurbs-object and return the hypernurbs. I tried it with poly->InsertUnder(hypernurbs);, but for some reasons in Cinema 4D I can only see an empty object.
    How is it possible to do that?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 05/07/2008 at 09:35, xxxxxxxx wrote:

    Hi!

    Didn't work with the Obj.-Manager, but I thought, to put it under another object, you have to use a member of the BaseDocument.

    Try InsertObject and check the members.

    Bye!



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 05/07/2008 at 14:53, xxxxxxxx wrote:

    If I do that, Cinema 4D crashes.

    This is my code:
              copydoc->InsertObject(hypernurbs,NULL,NULL,FALSE);
    copydoc->InsertObject(poly, hypernurbs, NULL, FALSE);



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 05/07/2008 at 17:45, xxxxxxxx wrote:

    I don't know, but I could imagine, that you have to "refresh" the ObjectManager. Means you have to add EventAdd() or something else like a Update_Message (MSG_UPDATE) after your first InsertObject.

    Bye :)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 09/07/2008 at 16:10, xxxxxxxx wrote:

    Still can't get it running. Can somebody please give me an example?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 09/07/2008 at 16:38, xxxxxxxx wrote:

    Make sure that you haven't *already* inserted the object before calling InsertObject()! If you need to RE-insert an object it MUST be first removed:

    poly->Remove();
    copydoc->InsertObject(poly, hypernurbs, NULL, FALSE);

    And EventAdd() is required after such an operation as inserting objects into the document.

    Sometimes this is more appropo as the third argument can be tichy:

    copydoc->InsertObject(poly, hypernurbs, hypernurbs->GetDownLast(), FALSE);

    As a final check, verify that copydoc, poly, and hypernurbs are VALID pointers!!! Specifying invalid pointers as arguments is an inevitable crash.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 18/07/2008 at 06:17, xxxxxxxx wrote:

    I got now the code:

    > <code>
    >           BaseObject *hypernurbs = BaseObject::Alloc(Ohypernurbs);          
    >      
    >           BaseContainer* hypernurbsData = hypernurbs->GetDataInstance();
    >           hypernurbsData->SetLong(HYPERNURBSOBJECT_SUBEDITOR, hypernurbs_unterteilung);
    >           hypernurbsData->SetLong(HYPERNURBSOBJECT_SUBRAY, hypernurbs_unterteilung);
    >           copydoc->Message(MSG_UPDATE);
    >           poly->Remove();
    >           copydoc->InsertObject(hypernurbs,NULL,NULL,FALSE);
    >           copydoc->Message(MSG_UPDATE);
    >           copydoc->InsertObject(poly, hypernurbs, NULL, FALSE);
    >           copydoc->Message(MSG_UPDATE);
    >           AddEvent(EVENT_FORCEREDRAW);
    > </code>

    Why does that not work? Is it possible, that this is not allowed in GetVirtualObjects()?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 18/07/2008 at 06:37, xxxxxxxx wrote:

    What's happening (that doesn't work)?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 18/07/2008 at 06:44, xxxxxxxx wrote:

    Cinema is crashing



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 18/07/2008 at 07:33, xxxxxxxx wrote:

    if (!poly) // ERROR!
    if (!copydoc) // ERROR!
    BaseObject *hypernurbs = BaseObject::Alloc(Ohypernurbs);          
    if (!hypernurbs) // ERROR!
    BaseContainer* hypernurbsData = hypernurbs->GetDataInstance();
    if (!hypernurbsData) // ERROR! (this shouldn't really occur but caution)
    hypernurbsData->SetLong(HYPERNURBSOBJECT_SUBEDITOR, hypernurbs_unterteilung);
    hypernurbsData->SetLong(HYPERNURBSOBJECT_SUBRAY, hypernurbs_unterteilung);
    //copydoc->Message(MSG_UPDATE);
    poly->Remove();
    copydoc->InsertObject(hypernurbs,NULL,NULL,FALSE);
    //copydoc->Message(MSG_UPDATE);
    copydoc->InsertObject(poly, hypernurbs, NULL, FALSE);
    //copydoc->Message(MSG_UPDATE);
    AddEvent(EVENT_FORCEREDRAW);



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 18/07/2008 at 08:06, xxxxxxxx wrote:

    At least got the error: The Hypernurbs-Object is not generated (!hypernurbs is true)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 18/07/2008 at 08:23, xxxxxxxx wrote:

    If I'm correct here, you need to allocate as Osds instead:

    BaseObject* hypernurbs = BaseObject::Alloc(Osds);

    This is the new form of HyperNURBS.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/07/2008 at 07:15, xxxxxxxx wrote:

    Hm, maybe youre right. This is my code now:

    > <code>
    >           BaseObject *hypernurbs = BaseObject::Alloc(Osds);                    
    >           if(!hypernurbs)
    >           {
    >                GePrint("HN");
    >                return false;
    >           }
    >      
    >           BaseContainer* hypernurbsData = hypernurbs->GetDataInstance();
    >
    >                    hypernurbsData->SetLong(SDSOBJECT_TYPE, SDSOBJECT_TYPE_R7);
    >           hypernurbsData->SetLong(SDSOBJECT_SUBEDITOR_R7, 2);
    >           hypernurbsData->SetLong(SDSOBJECT_SUBRAY_R7, 2);
    >
    >           
    >           poly->Remove();
    >           copydoc->InsertObject(hypernurbs,NULL,NULL,FALSE);
    >
    >           copydoc->InsertObject(poly, hypernurbs, NULL, FALSE);
    >
    >           EventAdd(EVENT_FORCEREDRAW);
    >
    >                return poly;
    > </code>

    Nothing crashes, but also nothing happens. I tried to return hypernurbs, but then it crashes again. At the moment I think, this isn't possible in the GetVirtualObjects()-Funktion.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/07/2008 at 07:28, xxxxxxxx wrote:

    The methodology might be a bit shaky for GetVirtualObjects(). You're returning 'poly' but also inserting it into copydoc. It can't be owned by two things simultaneously without repercussion. If the intention is to return the hypernurbs result, then you'll need to do CurrentStateToObject() (which is usually not possible here but in another document it may be).


Log in to reply