Pressing Set button in Hair Constraint Tag
-
On 30/08/2017 at 12:16, xxxxxxxx wrote:
Hello! I'm trying to make a script that generates two nulls for a spline and attaches spline's first and last point to those nulls.
In this topic Andreas tells to use CallButton() function, but I can't get this script to work.
https://developers.maxon.net/forum/topic/9445/12661_clicking-set-button-of-constraint-tag-from-pygenThe script is for Script Manager. You have to select spline object first and then run the script.
import c4d def main() : doc = c4d.documents.GetActiveDocument() selo = doc.GetActiveObjects(0) if len(selo) > 0: for o in selo: select_points = o.GetPointS() pc = len(o.GetAllPoints()) select_points.DeselectAll() select_points.Select(0) nulla = c4d.BaseObject(c4d.Onull) if nulla is None: return nulla[c4d.NULLOBJECT_DISPLAY] = 2 nulla.SetAbsPos(c4d.Vector(o.GetPoint(0)[0],o.GetPoint(0)[1],o.GetPoint(0)[2])) nulla.SetName("A") doc.InsertObject(nulla) aTag = o.MakeTag(1018074) aTag[c4d.HAIR_CONSTRAINTS_TAG_ANCHOR_LINK] = nulla c4d.CallButton(aTag, c4d.HAIR_CONSTRAINTS_TAG_SET_ANCHOR) select_points.DeselectAll() select_points.Select(pc-1) nullb = c4d.BaseObject(c4d.Onull) if nullb is None: return nullb[c4d.NULLOBJECT_DISPLAY] = 2 nullb.SetAbsPos(c4d.Vector(o.GetPoint(pc-1)[0],o.GetPoint(pc-1)[1],o.GetPoint(pc-1)[2])) nullb.SetName("B") doc.InsertObject(nullb) bTag = o.MakeTag(1018074) bTag[c4d.HAIR_CONSTRAINTS_TAG_ANCHOR_LINK] = nullb c4d.CallButton(bTag, c4d.HAIR_CONSTRAINTS_TAG_SET_ANCHOR) o.InsertTag(c4d.BaseTag(1018068)) c4d.EventAdd() if __name__ == "__main__": main()
I made similar script that uses CallButton function with Spline Dynamics tag to set fixed points and it works. Weird...
-
On 31/08/2017 at 05:51, xxxxxxxx wrote:
Hi,
this got discussed just recently. Please have a look at CallButton Won't Work on new Tags.
-
On 31/08/2017 at 08:05, xxxxxxxx wrote:
Thank you Andreas. Now it works!