Axis Center
-
On 10/07/2014 at 07:22, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R15
Platform: Windows ; Mac ; Mac OSX ;
Language(s) : C++ ;---------
Hello guys, I'm trying to replicate the behavior of the axis center command of C4D but it's not working.I have a clone of the scene because I can't modify de original.
I tried with:
pObject->SetBit(BIT_ACTIVE); CallCommand(1011982); pObject->DelBit(BIT_ACTIVE);
And this
Matrix64 m; m.TransformVector(pObject->GetMp()); pObject->SetModelingAxis(m);
And none of these worked.
What is the right way to do it?
Thank you.
-
On 14/07/2014 at 08:15, xxxxxxxx wrote:
I still looking into it.
Any ideas?
-
On 15/07/2014 at 12:15, xxxxxxxx wrote:
Your first code snippet is correct. And should work fine.
The only ways I can see this code failing are:
A- The object is a primitive type object. Not a polygon type object
B- You're not grabbing the object correctlyYou mentioned it's in another document. So I suspect that's where the problem is happening.
-ScottA
-
On 15/07/2014 at 12:28, xxxxxxxx wrote:
Thank you for your answer.
I don't know why is failing, all the objects are polygons because I convert all objects to polygons and delete the objects that i can't convert.
You're not grabbing the object correctly
What do you mean? Do I need to do something else to grab the object?
The plugin is iterating over the entire scene and doing it to every object that match the parameters, the code is executing but does nothing.
I think the command is not executing in objects that aren't in the active document, I don't have any other explanation.
-
On 15/07/2014 at 15:04, xxxxxxxx wrote:
Are you trying to center the axis of objects in the current scene(document)?
Or are you trying to center the axis of objects in a different document than the currently active document?
Maybe both?The code you posted should work if you're selecting the objects and documents properly.
Have you tested that you're actually selecting the objects with something like GePrint(obj->GetName()); or something similar?Without seeing your source code. That's the most obvious place I can think of for the code not working.
-ScottA
-
On 16/07/2014 at 05:58, xxxxxxxx wrote:
Thank you, I really apreciate your answers.
It is too much code to look at... this is the simplified version of the code
void MyClass::FreezeAllTransforms(BaseObject* pFirstObject) BaseObject* pObject = pFirstObject; while (pObject != nullptr) { const String& objectName = pObject->GetName(); pObject->SetBit(BIT_ACTIVE); CallCommand(1011982); pObject->DelBit(BIT_ACTIVE); FreezeAllTransforms(pObject->GetDown()); pObject = pObject->GetNext(); } }
The code is executing right but does not do anything.
Are you trying to center the axis of objects in the current scene(document)?
Or are you trying to center the axis of objects in a different document than the currently active document?
Maybe both?I'm trying to center the axis of objects in a clone of the active document, so it is not the active document.
The code you posted should work if you're selecting the objects and documents properly.
Ok, maybe I'm not selecting the document properly, what do you mean with select the document. (I will search into the documentation for it)
Have you tested that you're actually selecting the objects with something like GePrint(obj->GetName()); or something similar?
Yes, I have tested and is executing right, but have no effect.
Thank you.
-
On 16/07/2014 at 07:11, xxxxxxxx wrote:
I think is working now thanks to you.
What i did is:
BaseDocument* pClone = (BaseDocument* )(pDoc->GetClone(COPYFLAGS_0, NULL)); //Clone setting //... SetActiveDocument(pClone); //critical code here //... SetActiveDocument(pDoc);
It is ok? Or I'm doing it wrong?
-
On 16/07/2014 at 07:34, xxxxxxxx wrote:
Yes, It looks ok to me.
We have to be careful to target the right document. Especially with cloned documents and when rendering.
Rendering automatically uses a cloned document too.-ScottA
-
On 16/07/2014 at 08:32, xxxxxxxx wrote:
I will keep it on mind. I'm not rendering the cloned scene, I'm just using the scene to do some checks and export the result into another file.
Thank you very much.