Thank you man ! I see how to fix it now！~~
ViewportSelect.Init(width, height, bd, pick_obj, c4d.Mpolyedgepoint, True, c4d.VIEWPORTSELECTFLAGS_IGNORE_HIDDEN_SEL) pick_obj = ViewportSelect.PickObject(bd, doc, mx, my, 0, c4d.VIEWPORT_PICK_FLAGS_0)
Like this? But C4D giving feedback: UnboundLocalError: local variable 'pick_obj' referenced before assignment.
Hi! guys! Here's the problem with utils.ViewportSelect()
This is my code:
ViewportSelect = c4d.utils.ViewportSelect() frame = bd.GetFrame() left = frame["cl"] right = frame["cr"] top = frame["ct"] bottom = frame["cb"] width = right - left + 1 height = bottom - top +1 pick_obj = ViewportSelect.PickObject(bd, doc, mx, my, 0, c4d.VIEWPORT_PICK_FLAGS_0) print pick_obj ViewportSelect.Init(width, height, bd, pick_obj, c4d.Mpolyedgepoint, True, c4d.VIEWPORTSELECTFLAGS_IGNORE_HIDDEN_SEL) for obj in pick_obj: print obj nearest_poly = ViewportSelect.GetNearestPolygon(obj, mx, my, 0, False)
Cinema 4D giving feedback: RuntimeError: Object is not initialized yet.
How can i fix it?
No spline path,just surface of object
Hello! guys! I want to make a tool plugin like a brush tool, and i can use this tool draw objects on other object surface.And now, i want my drawn object to follow the direction of my mouse, like this:
Actually, i have a simple idea for this;
next_obj = parent_obj.GetDown().GetNext() while next_obj: pos = -(next_obj.GetPred().GetRelPos() - next_obj.GetRelPos()) normalized = pos.GetNormalized() rot = c4d.utils.VectorToHPB(normalized) pred = obj.GetPred() pred.SetRelRot(rot) next_obj = next_obj.GetNext()
But I think this method is too forced, I don't know if I can get the mouse direction information
Thank you very much for your reply. Maybe I did not describe the problem clearly. Actually, the problem I encountered is like this：
For example : if i use rotate tool rotate my object and click my script.
1.the axis can move correctly.
2.but the object moves with it.(this is my problem)
I don't want my objects to move,and I want my object to stay in place and only move the object axis
thank you again.
Hi, guys! i'm a new python guy and i want to move my object axis only, like center axis tool .and now i can move the axis on Y axis like this:
it's work fine
but if i rotate the object , it's have a problem(I don't know why i can't upload my next GIF).
I think this is a matrix problem, but matrix a little bit hard for me ,i have no idea how to fix it.
Hope you guys can help me.
This is my code:
import c4d def main(): obj = doc.GetActiveObject() axis_offset = c4d.Vector(0,100,0) points = obj.GetAllPoints() count = obj.GetPointCount() obj_pos = obj.GetAbsPos() doc.AddUndo(c4d.UNDOTYPE_CHANGE,obj) for i in xrange(len(points)): points[i] = points[i] + (axis_offset*-1) obj.SetAllPoints(points) obj.SetAbsPos(obj_pos+axis_offset) obj.Message(c4d.MSG_UPDATE) c4d.EventAdd() if __name__=='__main__': main()