Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > SDK Help
  New Posts New Posts
  FAQ FAQ  Forum Search   Register Register  Login Login

GetChildren in c++

 Post Reply Post Reply
Author
Message
pgrooff View Drop Down
Member
Member


Joined: 2010 Nov 05
Online Status: Offline
Posts: 693
Post Options Post Options   Quote pgrooff Quote  Post ReplyReply Direct Link To This Post Topic: GetChildren in c++
    Posted: 2017 Apr 14 at 6:35am

User Information:

Cinema 4D Version:   R16 
Platform:   Windows  ;   
Language(s):     C++  ;   

---------

In python you have the nice function GetChildren().
Is there something similar in c++?

I want to get all the children of a cloner after a SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, cd)

-Pim

Back to Top
Yannick Puech View Drop Down
Forum Moderator
Forum Moderator


Joined: 2011 Apr 13
Location: Spain
Online Status: Offline
Posts: 1009
Post Options Post Options   Quote Yannick Puech Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Apr 17 at 8:41am
Hi Pim,

To loop trough all the children of an object (and also gather them into a BaseArray for instance), call GetDown() on the parent to get the first child, then GetNext() on each of the child while the object returned is not nullptr.
Python API GeListNode.GetChildren() is just as simple as this.




MAXON
Developer Support
Back to Top
pgrooff View Drop Down
Member
Member


Joined: 2010 Nov 05
Online Status: Offline
Posts: 693
Post Options Post Options   Quote pgrooff Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Apr 18 at 3:52am
Ok, so I make my own GetChildren();

I am using SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, cd) to convert a MoGraph Cloner to separate objects (get all the children of the new null).
After that I use a function that uses a C4DObjectList.

Can I use the result of SendModelingCommand (a AtomArray* result) directly or should I use convert the AtomArray to a C4DObjectList or should I use a BaseArray?

Is C4DObjectList the same as a BaseArray?

-Pim

Back to Top
Yannick Puech View Drop Down
Forum Moderator
Forum Moderator


Joined: 2011 Apr 13
Location: Spain
Online Status: Offline
Posts: 1009
Post Options Post Options   Quote Yannick Puech Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Apr 18 at 11:59am
Hi,

Originally posted by pgrooff

Can I use the result of SendModelingCommand (a AtomArray* result) directly or should I use convert the AtomArray to a C4DObjectList or should I use a BaseArray?
Is C4DObjectList the same as a BaseArray?
The result of SendModelingCommand()+MCOMMAND_CURRENTSTATETOOBJECT for a Cloner is a Null object with all the clones as children.
C4DObjectList was designed to be used with SelectionListCreate() for editor/view selection. It has nothing to do with BaseArray.
I think using this class to just store objects is too much overhead. You should better use BaseArray class.





Edited by Yannick Puech - 2017 Apr 18 at 12:01pm
MAXON
Developer Support
Back to Top
pgrooff View Drop Down
Member
Member


Joined: 2010 Nov 05
Online Status: Offline
Posts: 693
Post Options Post Options   Quote pgrooff Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Apr 19 at 5:05am
Ok, thanks you.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.094 seconds.