Skip to content

Instantly share code, notes, and snippets.

@ilayshp
Created March 21, 2019 07:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilayshp/e207b0fc0958486b965667e051af1fe2 to your computer and use it in GitHub Desktop.
Save ilayshp/e207b0fc0958486b965667e051af1fe2 to your computer and use it in GitHub Desktop.
[python] node creation, add connection in xpresso, c4d
import c4d
def main():
global vecoutp
obj = doc.GetActiveObject()
tag = doc.GetActiveTag()
if not tag:
tag = c4d.BaseTag(c4d.Texpresso)
obj.InsertTag(tag)
nm = tag.GetNodeMaster()
xg = nm.GetRoot()
print "pass 1"
for i in xrange(xg.GetOutPortCount()):
port = xg.GetOutPort(i)
print port, port.GetName(xg), port.GetMainID()
bbox = nm.CreateNode(nm.GetRoot(),c4d.ID_OPERATOR_BOX,None, 0, 0)
nm.InsertFirst(xg, bbox)
if not xg.GetOutPort(0):
vecoutp = xg.AddPort(c4d.GV_PORT_OUTPUT, 536870935)
c = vecoutp.Connect(bbox.GetOutPort(0)) # <<<<< not connect
print vecoutp, vecoutp.GetName(xg), vecoutp.GetMainID()
print bbox.GetOutPort(0), bbox.GetOutPort(0).GetName(bbox), bbox.GetOutPort(0).GetMainID()
print c
print "pass 2"
for i in xrange(xg.GetOutPortCount()):
port = xg.GetOutPort(i)
print port, port.GetName(xg), port.GetMainID()
xg.Redraw()
nm.Message(c4d.MSG_UPDATE)
c4d.EventAdd()
if __name__=='__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment