Mograph selections
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/03/2012 at 18:22, xxxxxxxx wrote:
How exactly does one utilize the mograph selection using python?(not inside a python effector, btw, but in a real plugin.)
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 20/03/2012 at 03:58, xxxxxxxx wrote:
What do you mean by utilizing? Reading/writing data from the MoGraph Selection Tag? Being able to select clones made by your plugin?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 20/03/2012 at 18:29, xxxxxxxx wrote:
The indices of the selected clones are stored in a BaseSelect object in the MoGraph Selection tag.
The tag can be accessed like this:
tags = obj.GetTags() for tag in tags: if tag.GetType() is c4d.Tmgselection and tag.GetName() is "MoGraph Selection": moSelTag = tag break
In C++ the selection is accessed with BaseTag::Message(). The result is sent to a GetMGSelectionMessage struct, which contains a single BaseSelect member.
As far as I can see there is currently no Python equivalent.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/03/2012 at 11:47, xxxxxxxx wrote:
Sorry to hijack this thread into C++ land. But maybe seeing it working in C++ will help Python users.
Do you have a more complete example of this David?
There's no information about this in the forum archives.I've been trying to figure out how to get the index number from the moselection tag. And toggle them on/off as needed. And I'm not having any luck.
I can get all the parts. But I can't figure out how to make them work together to toggle the bits in the moselection tag.The parts of the moselection code:
BaseObject *obj = doc->GetActiveObject(); if(!obj) return FALSE; BaseTag *moSelTag = obj->GetTag(Tmgselection,0); //Look for a moselection tag starting from the first tag if(!moSelTag) return FALSE; LONG bits = moSelTag->GetAllBits(); GetMGSelectionMessage *gms = NULL; //Create a struct that will hold the selection data BaseSelect *sel = gms->sel; BaseSelectData *bsd = sel->GetData(); bsd->a; bsd->b; LONG count = sel->GetCount(); GePrint(LongToString(count)); SelectionTag *tag = static_cast<SelectionTag*>(obj->GetTag(Tmgselection)); //Cast the moselection tag to a BaseSelect type variable BaseSelect *sel = tag->GetBaseSelect(); LONG count = sel->GetCount(); GePrint(LongToString(count));
I've got all this stuff to work with. Yet I still can't use them to find and toggle the various moselection bits.
I keep getting strange bit results. And crashing in my experiments.-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/03/2012 at 17:37, xxxxxxxx wrote:
You have to use BaseTag::Message(), Scott.
GetMGSelectionMessage msm = GetMGSelectionMessage(); tag->Message(MSG_GET_MODATASELECTION, &msm;); msm.sel->CopyTo(bs);
Use IsSelected(), GetRange() etc as you would with point and poly selections.
Selections can be toggled like this:
bs->Select(index); bs->CopyTo(msm.sel);
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/03/2012 at 18:33, xxxxxxxx wrote:
Thanks David.
But I'm still not getting it.BaseObject *obj = doc->GetActiveObject(); if(!obj) return FALSE; BaseTag *moSelTag = obj->GetTag(Tmgselection,0); //Look for a moselection tag starting from the first tag if(!moSelTag) return FALSE; GetMGSelectionMessage msm = GetMGSelectionMessage(); //Create a struct to hold the tag data moSelTag->Message(MSG_GET_MODATASELECTION, &msm); //Grab the data from the tag and save it in the struct BaseSelect *bs= static_cast<SelectionTag*>(moSelTag)->GetBaseSelect(); msm.sel->CopyTo(bs); LONG count = bs->GetCount(); GePrint(LongToString(count));
This crashes on me. I think I might be using BaseSelect wrong.
This is the way I usually convert point & polygon tags holding data into a BaseSelect type variable. But it seems that this is wrong in this case. And I can't figure out how to make it work.-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/03/2012 at 18:51, xxxxxxxx wrote:
Just create a new BaseSelect object with Alloc() or AutoAlloc.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/03/2012 at 19:37, xxxxxxxx wrote:
Thanks a lot David.
I'm finally on my way with it now.Sorry for de-railing this thread Avd007.
But maybe this example will be of some help to get started with it. Once it is supported in python:BaseObject *obj = doc->GetActiveObject(); //The cloner object if(!obj) return FALSE; BaseTag *moSelTag = obj->GetTag(Tmgselection,0); //Look for a moselection tag starting from the first tag if(!moSelTag) return FALSE; AutoAlloc<BaseSelect> bs; //Create an empty BaseSelect GetMGSelectionMessage msm = GetMGSelectionMessage(); //Create a struct to hold the tag data moSelTag->Message(MSG_GET_MODATASELECTION, &msm); //Grab the data from the tag and save it in the struct msm.sel->CopyTo(bs); //Copy it to the BaseSelect variable LONG count = bs->GetCount(); //Gets how many clones are currently selected GePrint(LongToString(count)); LONG tgl = bs->Toggle(0); //Toggle the first moselection tag's element on/off bs->CopyTo(msm.sel); //Update the struct to reflect the changes made with BaseSelect
Sometimes seeing the way things work in C++ helps me to figure them out in python.
-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 22/03/2012 at 17:38, xxxxxxxx wrote:
Originally posted by xxxxxxxx
What do you mean by utilizing? Reading/writing data from the MoGraph Selection Tag? Being able to select clones made by your plugin?
to answer your question niklas, i am trying to retrieve the position and rotation of a clone based on a mo-selection tag. pretty simple concept, but retrieving the id's stored in the mograph selection tag is proving elusive. mabye you geniuses have some ideas!?
and scott,
im glad you guys hijacked the thread! thats great! im glad people are having the same issue as me.
It looks to me as if the mograph selection is retrieved using the .message() command? that seems... way different from other tags/objects, but am i wrong about this? or Am i to understand this is not fully implemented in python yet? thanks again you magnificent gents! -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 22/03/2012 at 19:15, xxxxxxxx wrote:
Maybe a work around (possibly using a second cloner for it)
let an effector hide selected/unselected clones using the moselection.
Then use GetArray(c4d.MODATA_FLAGS) and then read the values
from the array only for clones MOGENFLAG_CLONE_ON and not MOGENFLAG_DISABLE?Cheers
Lennart -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 23/03/2012 at 19:27, xxxxxxxx wrote:
That is so crazy it just might work! thanks lennart!