示例#1
0
def IterateHierarchy(op, materials):
    global useFound  # Get access to global variable
    if op is None:
        return
    while op:
        found = False  # Initialize found variable to false
        for m in materials:  # Loop through materials
            if m.GetName() == op.GetName(
            ):  # If object's name matches with material's name
                tags = op.GetTags()  # Get object's tags
                for t in tags:  # Loop through tags
                    if t.GetType() == 5616:  # If tag is texture tag
                        if t[c4d.
                             TEXTURETAG_MATERIAL] == m:  # If object already has texture tag with this material
                            found = True  # Set foun variable to true
                if found != True and useFound == True:  # If texture tag with same material not found
                    t = c4d.BaseTag(5616)  # Initialize texture tag
                    t[c4d.TEXTURETAG_MATERIAL] = m  # Set material to tag
                    op.InsertTag(t)  # Insert texture tag to object
                    doc.AddUndo(c4d.UNDOTYPE_NEW,
                                t)  # Add undo command for inserting new tag
                elif useFound == False:
                    t = c4d.BaseTag(5616)  # Initialize texture tag
                    t[c4d.TEXTURETAG_MATERIAL] = m  # Set material to tag
                    op.InsertTag(t)  # Insert texture tag to object
                    doc.AddUndo(c4d.UNDOTYPE_NEW,
                                t)  # Add undo command for inserting new tag
        op = GetNextObject(op)
示例#2
0
    def creerTagTex(self, obj, displayTag=True):
        if displayTag:
            tgdisp = c4d.BaseTag(c4d.Tdisplay)  #tag affichage
            tgdisp[c4d.DISPLAYTAG_AFFECT_DISPLAYMODE] = True
            tgdisp[c4d.DISPLAYTAG_SDISPLAYMODE] = 7  #Ombrage constant

            obj.InsertTag(tgdisp)

        tgtex = c4d.BaseTag(c4d.Ttexture)  #tag affichage
        tgtex[c4d.TEXTURETAG_MATERIAL] = self.mat
        tgtex[c4d.TEXTURETAG_PROJECTION] = 2  #projection planaire
        tgtex[c4d.TEXTURETAG_TILE] = False  #r\p\titions
        tgtex[c4d.TEXTURETAG_SIZE] = c4d.Vector(self.size.x / 2,
                                                self.size.z / 2, 1)
        tgtex[c4d.TEXTURETAG_ROTATION] = c4d.Vector(0, -math.pi / 2, 0)

        tgtex[CONTAINER_ORIGIN] = self.centre

        #dernier tag
        last = None
        tags = obj.GetTags()
        if len(tags):
            last = tags[-1]

        obj.InsertTag(tgtex, last)
        return tgtex
示例#3
0
def georefObj(obj,doc):
    if isGeoref(obj) : return
    tg = c4d.BaseTag(ID_GEOTAG)
    pos = obj.GetAbsPos()
    tg[CONTAINER_ORIGIN] = doc[CONTAINER_ORIGIN]+pos
    obj.InsertTag(tg)
    doc.AddUndo(c4d.UNDOTYPE_NEW,tg)
示例#4
0
    def addConstraint(self, slave, master, mode="Parent"):
        doc = documents.GetActiveDocument()
        slaveObj = doc.SearchObject(slave)
        masterObj = doc.SearchObject(master)
        self.removeConstraintTags(slaveObj)

        if mode == "Parent":
            constraintTAG = c4d.BaseTag(1019364)

            constraintTAG[c4d.EXPRESSION_ENABLE] = True
            constraintTAG[c4d.ID_CA_CONSTRAINT_TAG_PSR_MAINTAIN] = True
            constraintTAG[c4d.ID_CA_CONSTRAINT_TAG_PSR] = True
            constraintTAG[10005] = True
            constraintTAG[10007] = True
            constraintTAG[10001] = masterObj

            PriorityDataInitial = c4d.PriorityData()
            PriorityDataInitial.SetPriorityValue(
                c4d.PRIORITYVALUE_MODE, c4d.CYCLE_EXPRESSION
            )
            PriorityDataInitial.SetPriorityValue(c4d.PRIORITYVALUE_PRIORITY, 0)
            PriorityDataInitial.SetPriorityValue(c4d.PRIORITYVALUE_CAMERADEPENDENT, 0)
            constraintTAG[c4d.EXPRESSION_PRIORITY] = PriorityDataInitial
        try:
            slaveObj.InsertTag(constraintTAG)
        except:
            print("constr skip")
            pass
示例#5
0
        def aimObj(slave, master, mode="", searchObj=1):
            doc = documents.GetActiveDocument()
            if searchObj == 1:
                slaveObj = doc.SearchObject(slave)
                masterObj = doc.SearchObject(master)
            else:
                slaveObj = slave
                masterObj = master
            mg = slaveObj.GetMg()

            constraintTAG = c4d.BaseTag(1019364)

            if mode == "ROTATION":
                constraintTAG[c4d.ID_CA_CONSTRAINT_TAG_PSR] = True
                constraintTAG[10005] = False
                constraintTAG[10006] = False
                constraintTAG[10001] = masterObj
            if mode == "AIM":
                constraintTAG[c4d.ID_CA_CONSTRAINT_TAG_AIM_MAINTAIN] = False
                constraintTAG[c4d.ID_CA_CONSTRAINT_TAG_AIM] = True
                constraintTAG[c4d.ID_CA_CONSTRAINT_TAG_AIM_CONSTRAIN_X] = True
                constraintTAG[c4d.ID_CA_CONSTRAINT_TAG_AIM_CONSTRAIN_Y] = True
                constraintTAG[c4d.ID_CA_CONSTRAINT_TAG_AIM_CONSTRAIN_Z] = True
                constraintTAG[20004] = 0  # Axis X-
                constraintTAG[20001] = masterObj

            slaveObj.InsertTag(constraintTAG)

            c4d.EventAdd()
            c4d.DrawViews(
                c4d.DRAWFLAGS_ONLY_ACTIVE_VIEW
                | c4d.DRAWFLAGS_NO_THREAD
                | c4d.DRAWFLAGS_STATICBREAK
            )
            constraintTAG.Remove()
示例#6
0
def new_rig(object):
    doc.AddUndo(c4d.UNDOTYPE_CHANGE, object)

    #create a Python tag and attach it to the first joint
    pythontag = c4d.BaseTag(c4d.Tpython)
    object.InsertTag(pythontag)
    doc.AddUndo(c4d.UNDOTYPE_NEW, pythontag)
    #set the Python code inside the tag
    pythontag[c4d.TPYTHON_CODE] = pythontagcode

    #add a 'link' field to the python tag's user data -
    #this link will determine which previous bend to attach to
    userdata_link = c4d.GetCustomDataTypeDefault(c4d.DTYPE_BASELISTLINK)
    userdata_link[c4d.DESC_NAME] = "Previous Bend"
    pythontag.AddUserData(userdata_link)

    #add an offset field to the user data
    userdata_offset = c4d.GetCustomDataTypeDefault(c4d.DTYPE_REAL)
    userdata_offset[c4d.DESC_NAME] = "Offset"
    pythontag.AddUserData(userdata_offset)

    #add an offset field to the user data
    userdata_rotation = c4d.GetCustomDataTypeDefault(c4d.DTYPE_REAL)
    userdata_rotation[c4d.DESC_NAME] = "Rotation"
    userdata_rotation[c4d.DESC_UNIT] = c4d.DESC_UNIT_DEGREE
    userdata_rotation[c4d.DESC_STEP] = math.pi / 180.0
    pythontag.AddUserData(userdata_rotation)

    return pythontag
示例#7
0
def main():
    doc.StartUndo()
    tag = op.GetLastTag()
    tags = op.GetTags()
    md = mo.GeGetMoData(op)
    cnt = md.GetCount()
    selection = mo.GeGetMoDataSelection(tag)
    prefix = "ms"
    sep = "_"
    x = 0
    for k in reversed(tags):
        if k.GetName().split("_")[0] == prefix:
            x = x + 1
    for i in reversed(xrange(0, cnt)):
        if selection.IsSelected(i) == True:
            t = c4d.BaseTag(1021338)
            t[c4d.ID_BASELIST_NAME] = prefix + sep + str(x)
            s = c4d.BaseSelect()
            s.Select(i)
            op.InsertTag(t)
            doc.AddUndo(c4d.UNDOTYPE_NEW, t)
            mo.GeSetMoDataSelection(t, s)
            x = x + 1
    tag.Remove()
    doc.AddUndo(c4d.UNDOTYPE_DELETE, tag)
    doc.EndUndo()
    c4d.EventAdd()
def CreateNulls(obj):
    doc = c4d.documents.GetActiveDocument()  # Get active Cinema 4D document
    try:  # Try to execute following script
        objectNull = c4d.BaseObject(c4d.Onull)  # Initialize null object
        objectNull.SetName(str(obj.GetName()) + " Points")  # Set null's name
        objectNull[
            c4d.NULLOBJECT_DISPLAY] = 14  # Set null's display mode to none
        SetGlobalPosition(
            objectNull,
            GetGlobalPosition(obj))  # Set global position, rotation and scale
        SetGlobalRotation(objectNull, GetGlobalRotation(obj))
        SetGlobalScale(objectNull, GetGlobalScale(obj))
        doc.InsertObject(objectNull)  # Insert null to document
        objectNull.SetName(obj.GetName() + "_Null")  # Set null's name
        objectNull[
            c4d.NULLOBJECT_DISPLAY] = 2  # Set null's display mode circle
        objectNull.InsertTag(
            c4d.BaseTag(1019364))  # Insert constraint tag to null
        tag = objectNull.GetFirstTag()  # Select constraint tag
        tag[c4d.ID_CA_CONSTRAINT_TAG_PSR] = 1  # Activate PSR constraint
        tag[10001] = obj  # Set Target
        doc.AddUndo(c4d.UNDOTYPE_NEW,
                    objectNull)  # Add undo command for adding new object
    except:  # If something went wrong
        pass  # Do nothing
def MgSelTagsFromSelectedClones(obj):
    tag = obj.GetLastTag()  # Get object's last tag
    tags = obj.GetTags()  # Get object's tags
    md = mo.GeGetMoData(obj)  # Get object's MoGraph data
    cnt = md.GetCount()  # Get clone count
    selection = mo.GeGetMoDataSelection(
        tag)  # Get selection from MoGraph selection tag
    prefix = "ms"  # Prefix
    sep = "_"  # Separator
    x = 0  # Initialize iteration variable
    for k in tags:  # Loop through reversed list of tags
        if k.GetName().split("_")[0] == prefix:
            x = x + 1  # Increase iteration variable
    for i in range(0, cnt):  # Loop through reversed list of clones
        if selection.IsSelected(i) == True:
            t = c4d.BaseTag(1021338)  # Initialize MoGraph selection tag
            t[c4d.ID_BASELIST_NAME] = prefix + sep + str(x)  # Set tag name
            s = c4d.BaseSelect()  # Initialize BaseSelect
            s.Select(i)  # Select clone
            obj.InsertTag(t, obj.GetLastTag())  # Insert new tag to object
            doc.AddUndo(c4d.UNDOTYPE_NEW,
                        t)  # Add undo command for inserting new tag
            mo.GeSetMoDataSelection(t, s)  # Set MoGraph selection
            x = x + 1  # Increase iteration variable
    tag.Remove()  # Remove old tag
    doc.AddUndo(c4d.UNDOTYPE_DELETE, tag)  # Add undo command for removing tag
示例#10
0
文件: build_biped.py 项目: satan/eve
    def c4d_insert_ik(self, ik_parent, ik_target, group_parent):

        startObj = doc.SearchObject(ik_parent)
        endObj = doc.SearchObject(ik_target)

        ikTag = c4d.BaseTag(IKTag)
        startObj.InsertTag(ikTag)

        find_group_parent = doc.SearchObject(group_parent)
        IK_Goal = c4d.BaseObject(null)

        IK_Goal.SetName(ik_parent + '.Goal')
        doc.InsertObject(IK_Goal, parent=find_group_parent)

        ikTag[c4d.ID_CA_IK_TAG_TIP] = endObj
        ikTag[c4d.ID_CA_IK_TAG_TARGET] = IK_Goal

        if 'Leg' in ik_parent:
            IK_Pole = c4d.BaseObject(null)
            IK_Pole.SetName(ik_parent + '.Pole')
            dire = ik_parent.rsplit('Up', 1)[0]

            find_group = doc.SearchObject(dire + 'UpLeg.Goal')

            startObj = doc.SearchObject(ik_parent)
            endObj = doc.SearchObject(ik_target)

            doc.InsertObject(IK_Pole, parent=find_group)
            ikTag[c4d.ID_CA_IK_TAG_POLE] = IK_Pole

        ik_target_pos = doc.SearchObject(ik_target)
        mg = ik_target_pos.GetMg()
        IK_Goal.SetMg(mg)
def main():
    doc.StartUndo()
    tags = op.GetTags()
    mstag = c4d.BaseTag(1021338)
    i = 0
    for x in tags:
        if x.GetType() == 1021338:
            plain = c4d.BaseObject(1021337)
            plain[c4d.ID_MG_BASEEFFECTOR_SELECTION] = x.GetName()
            #plain[c4d.ID_BASELIST_NAME] = plain[c4d.ID_BASELIST_NAME]+"_"+str(i)
            doc.InsertObject(plain)
            effList = c4d.InExcludeData()
            if op.GetType() == 1019268:
                effList = op[c4d.MGTEXTOBJECT_EFFECTORLIST_CHAR]
                effList.InsertObject(plain, 1)
                op[c4d.MGTEXTOBJECT_EFFECTORLIST_CHAR] = effList
            elif op.GetType() == 1018544 or op.GetType(
            ) == 1018791 or op.GetType() == 1018545:
                effList = op[c4d.ID_MG_MOTIONGENERATOR_EFFECTORLIST]
                effList.InsertObject(plain, 1)
                op[c4d.ID_MG_MOTIONGENERATOR_EFFECTORLIST] = effList
            elif op.GetType() == 1036557:
                effList = op[c4d.ID_MG_VF_MOTIONGENERATOR_EFFECTORLIST]
                effList.InsertObject(plain, 1)
                op[c4d.ID_MG_VF_MOTIONGENERATOR_EFFECTORLIST] = effList
            i = i + 1
            doc.AddUndo(c4d.UNDOTYPE_NEW, plain)
        doc.EndUndo()
    c4d.EventAdd()
def InitObj(obj):
    sel = obj.GetPointS()
    count = obj.GetPointCount()
    null = c4d.BaseObject(c4d.Onull)
    null.SetName(str(obj.GetName()) + "_points")
    null[c4d.NULLOBJECT_DISPLAY] = 14
    SetGlobalPosition(null, GetGlobalPosition(obj))
    SetGlobalRotation(null, GetGlobalRotation(obj))
    SetGlobalScale(null, GetGlobalScale(obj))
    doc.InsertObject(null)
    for i in range(count):
        if (sel.IsSelected(i)):
            point = c4d.BaseObject(c4d.Onull)
            point.SetName("p_" + str(i))
            point[c4d.NULLOBJECT_DISPLAY] = 2
            pointpos = obj.GetPoint(i)
            fposx = pointpos[0]
            fposy = pointpos[1]
            fposz = pointpos[2]
            point.SetAbsPos(c4d.Vector(fposx, fposy, fposz))
            point.InsertTag(c4d.BaseTag(1019364))
            tag = point.GetFirstTag()
            tag[c4d.ID_CA_CONSTRAINT_TAG_CLAMP] = 1
            tag[50004, 1] = 3
            tag[50004, 4] = 3
            tag[50001] = obj
            tag[50004, 7] = 1
            point.InsertUnder(null)
            doc.AddUndo(c4d.UNDOTYPE_NEW, null)
示例#13
0
def DummyObject(obj, doc):
    dummyObject = obj.GetClone()  # Initialize a camera object
    RemoveTags(dummyObject)
    dummyObject.SetName("Dummy " + obj.GetName())  # Set name
    doc.InsertObject(dummyObject)  # Insert dummyObject to document
    MoveToLast(dummyObject, doc)  # Move new camera in the object hierarchy
    pythontag = c4d.BaseTag(c4d.Tpython)  # Initialize python tag
    dummyObject.InsertTag(pythontag)  # Insert python tag to object
    prioritydata = c4d.PriorityData()  # Initialize a priority data
    prioritydata.SetPriorityValue(
        c4d.PRIORITYVALUE_MODE,
        c4d.CYCLE_GENERATORS)  # Set priority to 'Generators'
    prioritydata.SetPriorityValue(
        c4d.PRIORITYVALUE_PRIORITY,
        449)  # Set priority value to last possible value
    prioritydata.SetPriorityValue(c4d.PRIORITYVALUE_CAMERADEPENDENT,
                                  False)  # Set camera dependent to false
    pythontag[c4d.EXPRESSION_PRIORITY] = prioritydata  # Set priority data
    pythontag[c4d.TPYTHON_FRAME] = True  # Set frame dependet to true
    link1 = CreateUserDataLink(pythontag, "Object",
                               obj)  # Create user data link
    pythontag[c4d.TPYTHON_CODE] = ("import c4d\n"
                                   "def main():\n"
                                   "\tcam = op[c4d.ID_USERDATA,1]\n"
                                   "\tmat = cam.GetMg()\n"
                                   "\tobj = op.GetObject()\n"
                                   "\tobj.SetMg(mat)")
    return dummyObject
示例#14
0
文件: build_biped.py 项目: satan/eve
    def __init__(self):

        nul = c4d.BaseObject(null)
        nul.SetName('Root')
        doc.InsertObject(nul)

        self.BuildBones()
        self.BuildLegIK()
        self.BuildVisuals()
        self.BuildEnds()
        self.build_controllers()
        self.build_spine_controllers(body_controllers)
        self.build_leg_controllers(leg_controllers)
        self.BuildHandIK()
        # parenting
        merged_top_body_group = self.groupObjects(GroupTopBody, 'TopBody',
                                                  'Root_Controls')
        find_head = doc.SearchObject('Head_CTRL')
        find_neck = doc.SearchObject('Neck_CTRL')

        mg = find_head.GetMg()
        find_head.InsertUnder(find_neck)
        find_head.SetMg(mg)

        self.BuildPoles()
        self.build_finger_controllers()
        pythontag = c4d.BaseTag(c4d.Tpython)

        rC = doc.SearchObject('Root_Controls')
        rC.InsertTag(pythontag)
        pythontag[c4d.TPYTHON_CODE] = pythontagcode
示例#15
0
        def parse_normals():
            normal = []
            if 'NORMAL' in prim.attributes:
                normal = BinaryData.get_data_from_accessor(
                    gltf, prim.attributes['NORMAL'])

            if normal:
                normaltag = c4d.NormalTag(nb_poly)
                for polyidx in range(nb_poly):
                    poly = c4d_mesh.GetPolygon(polyidx)
                    normal_a = self.switch_handedness_v3(
                        self.list_to_vec3(normal[poly.a]))
                    normal_b = self.switch_handedness_v3(
                        self.list_to_vec3(normal[poly.b]))
                    normal_c = self.switch_handedness_v3(
                        self.list_to_vec3(normal[poly.c]))
                    normal_d = c4d.Vector(0.0, 0.0, 0.0)

                    set_normals(normaltag, polyidx, normal_a, normal_b,
                                normal_c, normal_d)

                c4d_mesh.InsertTag(normaltag)

                # A Phong tag is needed to make C4D use the Normal Tag (seems to be done for Collada)
                phong = c4d.BaseTag(5612)
                c4d_mesh.InsertTag(phong)
def sweepSplines():
    splines = doc.GetActiveObjects(1)

    for i in splines:
        if (i.GetType() == 5101) or (i.GetType() == 5186) or (i.GetType()
                                                              == 5181):

            doc.AddUndo(c4d.UNDOTYPE_CHANGE, i)  #undo
            sweep = c4d.BaseObject(5118)

            doc.AddUndo(c4d.UNDOTYPE_NEW, sweep)  #undo
            doc.InsertObject(sweep)

            parent = i.GetUp()
            if parent != None:
                sweep.InsertUnder(parent)
            i.InsertUnder(sweep)

            square = c4d.BaseObject(5186)
            square[c4d.SPLINEOBJECT_INTERPOLATION] = 1
            square[c4d.SPLINEOBJECT_SUB] = 3
            square[c4d.PRIM_RECTANGLE_WIDTH] = userInput
            square[c4d.PRIM_RECTANGLE_HEIGHT] = userInput
            square.InsertUnder(sweep)

            newTag = c4d.BaseTag(c4d.Tphong)
            sweep.InsertTag(newTag)
            doc.AddUndo(c4d.UNDOTYPE_NEW, newTag)
示例#17
0
def CreateNullsFromObjects(obj):
    doc = c4d.documents.GetActiveDocument()  # Get active Cinema 4D document
    try:  # Try to execute following script
        objectNull = c4d.BaseObject(c4d.Onull)  # Initialize null object
        SetGlobalPosition(
            objectNull,
            GetGlobalPosition(obj))  # Set global position, rotation and scale
        SetGlobalRotation(objectNull, GetGlobalRotation(obj))
        SetGlobalScale(objectNull, GetGlobalScale(obj))
        doc.InsertObject(objectNull)  # Insert null to document
        objectNull.SetName(obj.GetName() + "_Null")  # Set null's name
        objectNull[
            c4d.NULLOBJECT_DISPLAY] = 2  # Set null's display mode circle

        bbox = obj.GetRad()
        sizes = [bbox.x, bbox.y, bbox.z]
        sizes.sort()
        width = sizes[-1]
        height = sizes[-2]
        diagonal = math.sqrt(pow((width * 2), 2) + pow((height * 2), 2))
        radius = diagonal / 2
        objectNull[c4d.NULLOBJECT_RADIUS] = radius

        objectNull.InsertTag(
            c4d.BaseTag(1019364))  # Insert constraint tag to null
        tag = objectNull.GetFirstTag()  # Select constraint tag
        tag[c4d.ID_CA_CONSTRAINT_TAG_PSR] = 1  # Activate PSR constraint
        tag[10001] = obj  # Set Target
        doc.AddUndo(c4d.UNDOTYPE_NEW,
                    objectNull)  # Add undo command for adding new object
        objectNull.SetBit(c4d.BIT_ACTIVE)

    except:  # If something went wrong
        pass  # Do nothing
示例#18
0
def create_standard_environment(doc, name, filepath):
    doc.StartUndo()
    # Create our Material for Sky Object
    mat = c4d.BaseMaterial(c4d.Mmaterial)

    mat.SetName(name)

    mat[c4d.MATERIAL_USE_COLOR] = False
    mat[c4d.MATERIAL_USE_LUMINANCE] = True
    mat[c4d.MATERIAL_USE_REFLECTION] = False
    mat[c4d.MATERIAL_PREVIEWSIZE] = c4d.MATERIAL_PREVIEWSIZE_1024

    _bmp_shader(doc, filepath, c4d.MATERIAL_LUMINANCE_SHADER, mat)

    doc.InsertMaterial(mat)
    doc.AddUndo(c4d.UNDOTYPE_NEW, mat)
    # mat.Message(c4d.MSG_UPDATE)
    # mat.Update(True, True)

    # Create Sky Object
    sky = c4d.BaseObject(c4d.Osky)
    sky.SetName(name)
    doc.InsertObject(sky)
    doc.AddUndo(c4d.UNDOTYPE_NEW, sky)

    # Create Texture Tag and set our Material
    tag = c4d.BaseTag(c4d.Ttexture)
    sky.InsertTag(tag)
    tag.SetMaterial(mat)
    doc.AddUndo(c4d.UNDOTYPE_NEW, tag)

    doc.EndUndo()
    c4d.EventAdd()
def CreateConnectorDynamics(obj):
    doc = c4d.documents.GetActiveDocument()  # Get active Cinema 4D document
    voroFrac = c4d.BaseObject(1036557)  # Initialize voronoi fracture object
    voroFrac[c4d.ID_BASELIST_NAME] = "Connector Dynamics"  # Set name
    voroFrac[c4d.ID_FRACTURE_COLORIZE] = 0  # Don't colorize fragments
    dynTag = c4d.BaseTag(180000102)  # Initialize dynamics body tag
    dynTag[
        c4d.
        RIGID_BODY_SPLIT_CACHE] = 2  # Set 'individual elements'' to 'top level'
    doc.AddUndo(c4d.UNDOTYPE_NEW,
                voroFrac)  # Add undo command for creating new object
    doc.InsertObject(voroFrac, None,
                     obj)  # Insert voronoi fracture object to document
    doc.AddUndo(c4d.UNDOTYPE_NEW,
                dynTag)  # Add undo command for creating new tag
    voroFrac.InsertTag(dynTag)  # Insert tag to voronoi fracture object
    doc.AddUndo(c4d.UNDOTYPE_CHANGE, obj)  # Add undo command
    obj.InsertUnder(voroFrac)  # Insert object under voronoi fracture object
    doc.ExecutePasses(None, 0, 1, 1,
                      0)  # Needed when pressing buttons virtually
    c4d.CallButton(
        voroFrac,
        c4d.ID_FRACTURE_AUTOCONNECTOR_ENABLE)  # Press 'Create Fixed Connector'
    connector = voroFrac.GetDown()  # Get connector object
    doc.AddUndo(c4d.UNDOTYPE_BITS,
                connector)  # Add undo command for changing bits
    connector.SetBit(c4d.BIT_ACTIVE)  # Select connector object
示例#20
0
def new_rig(object):
    doc.StartUndo()
    doc.AddUndo(c4d.UNDOTYPE_CHANGE, object)

    #create a Python tag and attach it to the first joint
    pythontag = c4d.BaseTag(c4d.Tpython)
    object.InsertTag(pythontag)
    doc.AddUndo(c4d.UNDOTYPE_NEW, pythontag)
    #set the Python code inside the tag - splines get their own code that deals with tangents
    if (object.GetType() == c4d.Ospline):
        pythontag[c4d.TPYTHON_CODE] = pythontagcode_spline
    else:
        pythontag[c4d.TPYTHON_CODE] = pythontagcode

    pointcount = object.GetPointCount()

    prevlist = None
    #loop through all the points, adding nulls for each one
    for i in xrange(pointcount):
        controlnull = addHandle(i, object)
        #if this is the first null, stick it under the object we're rigging,
        #otherwise put it after the last null ('prevlist') - then put this null into 'prevlist'
        #so the next null knows where to go
        if prevlist == None:
            controlnull.InsertUnder(object)
        else:
            controlnull.InsertAfter(prevlist)
        prevlist = controlnull
        doc.AddUndo(c4d.UNDOTYPE_NEW, controlnull)

    doc.EndUndo()
    c4d.EventAdd(c4d.EVENT_FORCEREDRAW)

    print "Point rig added successfully!"
def arnold_material_export(assdoc, fileName):
    matdoc = c4d.documents.BaseDocument()
    c4d.documents.InsertBaseDocument(matdoc)

    matdoc.SetDocumentName(fileName)
    mat = assdoc.GetFirstMaterial()

    while mat:
        newmat = mat.GetClone()

        matdoc.InsertMaterial(newmat)
        obj = c4d.BaseObject(c4d.Opolygon)
        obj.SetName(newmat.GetName())
        tag = c4d.BaseTag(c4d.Ttexture)
        tag[c4d.TEXTURETAG_MATERIAL] = newmat

        obj.InsertTag(tag)
        matdoc.InsertObject(obj)

        mat = mat.GetNext()

    options = c4d.BaseContainer()
    options.SetFilename(0, fileName.decode("utf-8"))
    options.SetInt32(6, 0)
    options.SetInt32(7, 0)
    matdoc.GetSettingsInstance(c4d.DOCUMENTSETTINGS_DOCUMENT).SetContainer(
        ARNOLD_ASS_EXPORT, options)

    c4d.CallCommand(ARNOLD_ASS_EXPORT)

    c4d.documents.KillDocument(matdoc)
示例#22
0
def IterateHierarchy(op):
    doc = c4d.documents.GetActiveDocument()  # Get active Cinema 4D document
    if op is None:
        return
    while op:
        phongFound = 0  # Initialize phongFound variable
        tags = op.GetTags()  # Get tags of object
        for t in tags:  # Loop Through tags
            if t.GetType() == 5612:  # If tag is a phong tag
                phongFound = 1  # Phong tag found
        if phongFound == 0:  # If phong tag is not found
            phongObjects = [
                5125, 1039861, 5173, 5169, 5166, 5161, 5167, 5165, 5172, 5171,
                5163, 5160, 5174, 5168, 5164, 5170, 5162, 5159, 5100
            ]  # Objects that uses phong tag
            if op.GetType(
            ) in phongObjects:  # If object is in phongObjects list
                phongTag = c4d.BaseTag(5612)  # Initialize phong tag
                phongTag[
                    c4d.PHONGTAG_PHONG_ANGLELIMIT] = 1  # Set angle limit on
                phongTag[c4d.PHONGTAG_PHONG_ANGLE] = c4d.utils.DegToRad(
                    40)  # Set phong angle to 40
                phongTag[
                    c4d.PHONGTAG_PHONG_USEEDGES] = 1  # Set use edge breaks
                op.InsertTag(phongTag)  # Insert phong tag to object
                doc.AddUndo(c4d.UNDOTYPE_NEW, phongTag)
        op = GetNextObject(op)  # Get next object
    return True
示例#23
0
文件: build_biped.py 项目: satan/eve
    def insertTargetConstraint(self, target, ctrl_label):

        constr_tag = c4d.BaseTag(Constraint)
        constr_tag[c4d.ID_CA_CONSTRAINT_TAG_AIM] = True
        constr_tag[10001] = ctrl_label
        corr_ik = doc.SearchObject(target)
        corr_ik.InsertTag(constr_tag)
def SetMoGraphWeightMap(op):
    md = mo.GeGetMoData(op)
    if md is None: return False
    cnt = md.GetCount()
    warr = md.GetArray(c4d.MODATA_WEIGHT)
    moWeightMapTag = c4d.BaseTag(c4d.Tmgweight)
    doc.AddUndo(c4d.UNDOTYPE_NEW, moWeightMapTag)
    op.InsertTag(moWeightMapTag)
    mo.GeSetMoDataWeights(moWeightMapTag, warr)
示例#25
0
 def create_tracking_xpresso(self, skeleton):
     xpresso_tag = c4d.BaseTag(c4d.Texpresso)
     # Set Tag priority to Animation
     pd = xpresso_tag[c4d.EXPRESSION_PRIORITY]
     pd.SetPriorityValue(c4d.PRIORITYVALUE_MODE, 1)
     xpresso_tag[c4d.EXPRESSION_PRIORITY] = pd
     xpresso_tag[c4d.ID_BASELIST_NAME] = "Movement Tracking"
     skeleton.InsertTag(xpresso_tag)
     return xpresso_tag
示例#26
0
def createObject(str):
    unit = c4d.BaseObject(eval('c4d.O' + str))
    unit.SetName('my' + str)

    if str != 'null':
        tag_phong = c4d.BaseTag(c4d.Tphong)
        tag_phong[c4d.PHONGTAG_PHONG_ANGLELIMIT] = True
        unit.InsertTag(tag_phong)

    return unit
示例#27
0
def creerGeoTag(obj, doc, centre):
    geoTag = c4d.BaseTag(1026472)  # GeoTag
    origine = doc[CONTAINER_ORIGIN]
    if not origine:
        origine = centre
        doc[CONTAINER_ORIGIN] = origine
    geoTag[CONTAINER_ORIGIN] = centre

    obj.InsertTag(geoTag)
    return geoTag
示例#28
0
def create_example_basetags_list():
    base_tags_list: List[c4d.BaseTag] = []

    for i in range(1, 10):
        base_tag = c4d.BaseTag(1019364)
        base_tag.SetName("BaseTag_{}_Constraint".format(i))

        base_tags_list.append(base_tag)

    return base_tags_list
示例#29
0
 def create_body_xpresso_tag(self, obj):
     """Create the Body Xpresso Tag"""
     xtag = c4d.BaseTag(c4d.Texpresso)
     # Set Tag priority to Animation
     pd = xtag[c4d.EXPRESSION_PRIORITY]
     pd.SetPriorityValue(c4d.PRIORITYVALUE_MODE, 1)
     xtag[c4d.EXPRESSION_PRIORITY] = pd
     xtag[c4d.ID_BASELIST_NAME] = "{0} Xpresso Tag".format(self.body_name)
     obj.InsertTag(xtag)
     self.body_xpresso_tag = xtag
示例#30
0
def main():
    doc = c4d.documents.GetActiveDocument()
    selected = doc.GetActiveObject()

    #tag
    xpressotag = c4d.BaseTag(c4d.Texpresso)
    xpressotag.SetName("My Xpresso Tag")
    selected.InsertTag(xpressotag)

    # xpresso master
    nodemaster = xpressotag.GetNodeMaster()

    # create nodes
    mathNode = nodemaster.CreateNode(nodemaster.GetRoot(),
                                     400001121,
                                     None,
                                     x=200,
                                     y=100)
    constantNodeA = nodemaster.CreateNode(nodemaster.GetRoot(),
                                          400001120,
                                          None,
                                          x=100,
                                          y=100)
    constantNodeB = nodemaster.CreateNode(nodemaster.GetRoot(),
                                          400001120,
                                          None,
                                          x=100,
                                          y=150)
    resultNode = nodemaster.CreateNode(nodemaster.GetRoot(),
                                       400001118,
                                       None,
                                       x=350,
                                       y=100)

    # change node values
    constantNodeA[c4d.GV_CONST_VALUE] = 10
    constantNodeB[c4d.GV_CONST_VALUE] = 5
    mathNode[c4d.GV_MATH_FUNCTION_ID] = 1

    # ports
    constantPortOutA = constantNodeA.GetOutPort(0)
    constantPortOutB = constantNodeB.GetOutPort(0)
    mathPortInA = mathNode.GetInPort(0)
    mathPortInB = mathNode.GetInPort(1)
    mathPortOut = mathNode.GetOutPort(0)
    resultPortIn = resultNode.GetInPort(0)

    # connect ports
    constantPortOutA.Connect(mathPortInA)
    constantPortOutB.Connect(mathPortInB)
    mathPortOut.Connect(resultPortIn)

    # refresh
    c4d.modules.graphview.RedrawMaster(nodemaster)
    c4d.EventAdd()