Restore old Pointselection
-
On 22/12/2015 at 02:45, xxxxxxxx wrote:
Hi, I want to store a Pointsselection and later restore that Selection on another Identical Object.
I tried this...but with no luckpoints = obj.GetPointS() count = NewObj.GetPointCount() newPoints = NewObj.GetPointS() newPoints.DeselectAll() for i in xrange(count) : if points.IsSelected(i) : newPoints.Select(i)
-
On 22/12/2015 at 03:02, xxxxxxxx wrote:
Hi Holgar,
You can simply use BaseSelect.CopyTo() to copy a selection to another. Note you have to send a MSG_UPDATE after changing the selection:
sel = obj.GetPointS() otherSel = newObj.GetPointS() sel.CopyTo(otherSel) newObj.Message(c4d.MSG_UPDATE)
-
On 22/12/2015 at 03:49, xxxxxxxx wrote:
Thanks Yannick. But it does not work for me. What I do is I make CallCommand with Shrinkselection and than I want to restore the old selection. Its not working.
-
On 22/12/2015 at 03:52, xxxxxxxx wrote:
Could you post some code?
-
On 22/12/2015 at 04:16, xxxxxxxx wrote:
def main() : selobj=doc.GetSelection() obj=selobj[0] sel = obj.GetPointS() obj.Message(c4d.MSG_UPDATE) c4d.CallCommand(12559) # Shrink Selection newobj=obj.GetClone() newobj.InsertAfter(obj) otherSel = newobj.GetPointS() sel.CopyTo(otherSel) newobj.Message(c4d.MSG_UPDATE) obj.Remove() c4d.EventAdd() if __name__=='__main__': main()
-
On 22/12/2015 at 05:26, xxxxxxxx wrote:
Just some question:
selobj=doc.GetSelection() Why dont you use doc.GetActiveObject() or doc.GetActiveObjects? You just wanna work with Objects, rigth? obj.Message(c4d.MSG_UPDATE) Why do you send this message befor the selection change? c4d.CallCommand(12559) # Shrink Selection Isnt it more comfortable to use c4d.utils.SendModelingCommand(command = c4d.MCOMMAND_SELECTSHRINK, list = [selobj], mode = c4d.MODELINGCOMMANDMODE_POINTSELECTION, bc = c4d.BaseContainer(), doc = doc) Ok, in this case selobj is the active object in any cases. And finally just to clearify: - you store the selection of an object - you shrink the selection - you create and insert a clone of the object with the shrinked selection - you put the unshrinked selection at the clone and remove the object Where is the difference before and after the script?
-
On 22/12/2015 at 06:19, xxxxxxxx wrote:
This is just an example copied from a script. I store the selection before I shrink the selection. So I would expect i can restore it later from the state before I shrink it. But I guess something is wrong with my logic.
-
On 22/12/2015 at 06:33, xxxxxxxx wrote:
Ok, I understand.
I think sel isnt an instance or clone of obj.GetPointS(), so you change sel with SELECTSHRINK, too.
import c4d from c4d import gui #Welcome to the world of Python def main() : obj = doc.GetActiveObject() if obj == None: return sel = c4d.BaseSelect() obj.GetPointS().CopyTo(sel) c4d.utils.SendModelingCommand(command = c4d.MCOMMAND_SELECTSHRINK, list = [obj], mode = c4d.MODELINGCOMMANDMODE_POINTSELECTION, bc = c4d.BaseContainer(), doc = doc) newobj = obj.GetClone() newobj.InsertAfter(obj) newobj.SetRelPos(c4d.Vector(0,0,200)) other_sel = newobj.GetPointS() sel.CopyTo(other_sel) newobj.Message(c4d.MSG_UPDATE) c4d.EventAdd() if __name__=='__main__': main()
-
On 23/12/2015 at 00:30, xxxxxxxx wrote:
so How would I be able to restore my old selection than? Any Idea?
Edit: Sorry..just realized that your code is now working. I see. Thanks.