On 30/12/2016 at 20:56, xxxxxxxx wrote:
How I can modify the Y Axis to -100% using python as shown in the screenshot below:
On 31/12/2016 at 11:59, xxxxxxxx wrote:
I found the solution below :
import c4d def main() : world_pos = op.GetMg().off bBox_pos = op.GetMp() bBox_size = op.GetRad() local_bottom = c4d.Vector(0,bBox_pos.y - bBox_size.y,0) world_bottom = local_bottom + world_pos yPos = c4d.Vector(0,world_bottom.y,0) oldm = op.GetMg() points = op.GetAllPoints() pcount = op.GetPointCount() op.SetAbsPos(yPos) newm = op.GetMg() for p in xrange(pcount) : op.SetPoint(p,~newm*oldm*points[p]) op.Message(c4d.MSG_UPDATE) c4d.EventAdd() if __name__=='__main__': main()
On 01/01/2017 at 08:23, xxxxxxxx wrote:
Take care of this and using child objects ! Since you modify the original axis and since children use relative position this will affect the position of their.
A good way is to store gobal position/scale/rotation (or simply get the global matrix of it) change the axis and then reasign those data
On 02/01/2017 at 03:12, xxxxxxxx wrote:
You can find a nice solution inside this post.
On 02/01/2017 at 11:23, xxxxxxxx wrote:
At the outset I wanted to find a solution to dropping an object to a floor, so I wanted to modify the y axis and put it at the bottom of my object then I set the y position to zero.
But I find a new solution and it works with all type of object.
import c4d def main() : if not op: return world_pos = op.GetMg().off bBox_pos = op.GetMp() bBox_size = op.GetRad() local_bottom = c4d.Vector(0,bBox_pos.y - bBox_size.y,0) world_bottom = local_bottom + world_pos op[c4d.ID_BASEOBJECT_REL_POSITION,c4d.VECTOR_Y] += -world_bottom.y c4d.EventAdd() if __name__=='__main__': main()
I don't know if can do that differently, and thank you guys for your replies.
On 07/08/2017 at 01:52, xxxxxxxx wrote:
Thank you for for the nice code example! But it works incorrectly with scaled objects.