Script to center axis but have Y axis 0, or bottom of model
-
Hi Everyone, had a question. First I have little Python experience but lots of C# and Objective-C, and C. I have Kitbash libraries that I am trying to create a script to copy to a new document, process the object and export as an OBJ file. The problem that I am having is when I run the command to to open the Center Axis, it opens but continues to execute the code. I thought I might be able to have a MessageDialog pop up to pause the script, which it does, but I can't axis the Axis Center window.
My guess is the best approach is to try and move the axis center to the center of the model but the Y axis to 0.
import c4d from c4d import gui # Welcome to the world of Python # Script state in the menu or the command palette # Return True or c4d.CMD_ENABLED to enable, False or 0 to disable # Alternatively return c4d.CMD_ENABLED|c4d.CMD_VALUE to enable and check/mark #def state(): # return True # Main function def main(): c4d.CallCommand(12107, 12107) # Copy c4d.CallCommand(12094, 12094) # New Project c4d.CallCommand(100004821) # Paste c4d.CallCommand(100004768, 100004768) # Select Children c4d.CallCommand(16768, 16768) # Connect Objects + Delete c4d.CallCommand(1010819) # Center Axis printScript() def printScript(): gui.MessageDialog('Delay Program') # Execute main() if __name__=='__main__': main()
If anyone can help me, or direct me to documentation that will outline the steps needed to set the axis of the object to the bottom center, the reset of the code to export works fine, but I didn't include it here. Thanks you!
-
hello and welcome to this forum.
For your next threads, please help us keeping things organised and clean. I know it's not your priority but it really simplify our work here.
- Q&A New Functionality.
- How to Post Questions especially the tagging part.
I've added the tags and marked this thread as a question so when you considered it as solved, please change the state
About your question :
The problem with your code is that you are opening a dialog box but you can't interact with it. (as most dialog box)
Using CallCommand are cool and sometimes useful but in many cases you will find yourself in a dead end. (and pretty fast)
A better approche is to use the Maxon API and read our documentation. You will also find a lot of example in our github repository.
We have some manuals also. They are a nice way to start.That said, how can you handle this problem ?
In Cinema 4D you can "move" the axis. You have to move the points.
To know where a point is, c4d need two things. The matrix's object and the local coordinate of the point. If you open your structure's tab you will see that how ever the object's position is, the coordinate of the points doesn't change.
As you can find using the search tool, you are not the first to ask that question
You have to move the axis where you want it, and update the points position (so visually they don't change).
This is often done by converting the local coordinates to global and the inverse.Last but not least, Maxime have create a pretty complete example that do exactly what you need.
You can find it here
It can be scary if you are new to the world of development you will do that kind of stuff in no time.Don't be afraid to ask questions here. We are here to help.
Cheers,
Manuel -
Manuel, thanks for taking the time and posting some links. Last night I was reading up on the Matrix and trying wrapping my head around it. I think I was stuck in the wrong area, I was trying to convert a baseObject to a pointObject to do the transformations.I would perfer not to have to open the axis window, but instead handle all this in a Python Function. I will look over the docs and samples to get a better idea of what I need to do.
Thanks again for taking the time to respond to my post!