Esempio n. 1
0
def main():
    # Large Icons
    c4d.CallCommand(100004708, 100004708)

    # Lines
    c4d.CallCommand(12540, 12540)

    # seleted object
    obj = doc.GetActiveObject()

    if obj == None:
        gui.MessageDialog('Please Select the Object!')
        return
    else:
        AddUserData(obj, "Show Points Index", True)
        AddUserData(obj, "Show Edge Index", False)
        AddUserData(obj, "Show Primitive Index", False)

    # Insert the cloner object
    displayEdgeIndex(obj)
    displayPrimIndex(obj)
    displayPntIndex(obj)
    doc.GetActiveObject()

    # Add python Tag
    c4d.CallCommand(100004788, 50056)
    c4d.EventAdd()
def CreateC4DDocs(DocPath,
                  DocNameShort,
                  curFrame,
                  rDat,
                  rDatIncr,
                  rOctIncr,
                  octane,
                  forward=True):
    saveAs = DocPath + "\\" + DocNameShort + "_r" + str(curFrame) + ".c4d"

    #Save every Frame Functionality------------------------------------------------------

    #Change RenderPath
    rDatIncr += "_r" + str(curFrame)

    if not rOctIncr == None:  # Only execute if Octane Renderer is set
        rOctIncr += "_r" + str(curFrame)
        octane[c4d.SET_PASSES_SAVEPATH] = rOctIncr

    rDat[c4d.RDATA_PATH] = rDatIncr
    c4d.EventAdd()

    c4d.documents.SaveDocument(doc, saveAs, c4d.SAVEDOCUMENTFLAGS_0,
                               c4d.FORMAT_C4DEXPORT)

    #FrameForward
    if forward:
        c4d.CallCommand(12414)
    else:
        c4d.CallCommand(12413)
Esempio n. 3
0
def main():
    hair = doc.GetActiveObject()
    if hair.GetType() == 1017305:
        #       hair settings
        hair[c4d.HAIRSTYLE_GENERATE] = 1
        hair[c4d.HAIRSTYLE_SEGMENTS] = 1
        c4d.CallCommand(12236)

        #       spline settings
        spline = doc.GetActiveObject()
        points = [c4d.Vector(0, 0, 0)]
        points = spline.GetAllPoints()

        #       Make new list of every other point
        even_list = []
        for i in points[::2]:
            even_list.append(i)


#       Remove the first list item
        even_list.pop(0)

        #       Update the spline with new settings
        spline.ResizeObject(len(even_list))
        spline.SetAllPoints(even_list)
        spline.Message(c4d.MSG_UPDATE)
        c4d.CallCommand(12568)  # Join Segments

    else:
        print " No Hair Object selected "
        return
    c4d.EventAdd()
Esempio n. 4
0
    def sceneToZero(self):
        doc = documents.GetActiveDocument()
        obj = doc.GetFirstObject()
        scene = ObjectIterator(obj)
        baseObjs = []
        errorDetected = False

        for obj in scene:
            if scene.depth == 0:
                if obj.GetType() == 5100:
                    baseObjs.append(obj)
                if obj.GetType() == 1007455:
                    objSub = obj
                    objMesh = obj.GetDown()
                    c4d.CallCommand(100004767, 100004767)  # Deselect All
                    objSub.SetBit(c4d.BIT_ACTIVE)
                    c4d.CallCommand(100004773)  # Expand Object Group
                    objSub.Remove()
                    c4d.EventAdd()
                    if objMesh:
                        if objMesh.GetType() == 5100:
                            baseObjs.append(objMesh)

        if len(baseObjs) > 0:
            if errorDetected == False:
                getLowestY = self.rasterizeObj(self.sceneLowestYobj())
                self.moveAllToZero(baseObjs, getLowestY)
                c4d.DrawViews(
                    c4d.DRAWFLAGS_ONLY_ACTIVE_VIEW
                    | c4d.DRAWFLAGS_NO_THREAD
                    | c4d.DRAWFLAGS_STATICBREAK
                )
                c4d.EventAdd()
def main():
    doc.StartUndo()
    doc.AddUndo(c4d.UNDO_OBJECT, op)
    c4d.CallCommand(12139)
    # Enter Point Mode

    if (op and isinstance(op,
                          c4d.SplineObject)):  # only spline objects allowed

        selection = op.GetPointS()
        selection.DeselectAll()
        c4d.EventAdd()

        pCount = op.GetPointCount()
        i = 0

        while i < pCount:
            selection.Select(i)
            i += 1
            selection.Select(i)
            c4d.CallCommand(14029)
            # disconnect
            selection.DeselectAll()
            pCount = op.GetPointCount()
            i += 1
            escape_pressed()

    selection.DeselectAll()
    c4d.CallCommand(13316)
    # Explode Segments
    c4d.EventAdd()
    print("Spline Split: Created ", pCount / 2, " splines.")

    doc.EndUndo()
    def SpawnObjects(self):
        self.doc.InsertObject(c4d.BaseObject(c4d.Onull))
        parent = self.doc.SearchObject("Null")
        parent.SetName(self.GetComboboxSelected())
        InstanceMode = True
        self.FilterObjects()

        self.baseobject = self.GetSelectedObject()
        for obj in self.outarray:
            if InstanceMode == True:
                c4d.CallCommand(5126)
            else:
                c4d.CallCommand(12107)  # Copy
                c4d.CallCommand(12108)  # Paste
            position = obj['Transform']['Position']
            rotation = obj['Transform']['Rotation']
            scale = obj['Transform']['Scale']
            self.currentinstance = self.GetSelectedObject()
            self.currentinstance.SetAbsPos(
                c4d.Vector(position[0], position[1], position[2]))
            self.currentinstance.SetAbsRot(
                c4d.Vector(rotation[0], rotation[1], rotation[2]))
            self.currentinstance.SetAbsScale(
                c4d.Vector(scale[0], scale[1], scale[2]))
            self.currentinstance.InsertUnder(parent)

            self.baseobject.SetBit(c4d.BIT_ACTIVE)
            self.doc.SetActiveObject(self.baseobject)

        c4d.EventAdd()
Esempio n. 7
0
def insertObject(pX, pY, pZ, pWidth, pHeight, pDepth, pIndex):
    #INSERT A CUBE
    obj = c4d.BaseObject(c4d.Ocube)
    obj[c4d.PRIM_CUBE_SUBX] = 2
    obj[c4d.PRIM_CUBE_SUBY] = 2
    obj[c4d.PRIM_CUBE_SUBZ] = 2

    #INITIAL TEXTURE FOR STRUCTURE
    tex = obj.MakeTag(c4d.Ttexture)
    tex[c4d.TEXTURETAG_MATERIAL] = doc.SearchMaterial("dk_gray_metal")
    tex[c4d.TEXTURETAG_PROJECTION] = 6  #UVW

    obj[c4d.PRIM_CUBE_LEN] = c4d.Vector(pWidth, pHeight, pDepth)
    res = utils.SendModelingCommand(command=c4d.MCOMMAND_CURRENTSTATETOOBJECT,
                                    list=[obj],
                                    mode=c4d.MODELINGCOMMANDMODE_ALL,
                                    bc=c4d.BaseContainer(),
                                    doc=doc)[0]
    res[c4d.ID_BASEOBJECT_REL_POSITION, c4d.VECTOR_X] = pX
    res[c4d.ID_BASEOBJECT_REL_POSITION, c4d.VECTOR_Y] = pY
    res[c4d.ID_BASEOBJECT_REL_POSITION, c4d.VECTOR_Z] = pZ
    res[c4d.ID_BASELIST_NAME] = "cuby_" + str(pIndex)

    doc.InsertObject(res)
    doc.SetActiveObject(res, c4d.SELECTION_NEW)
    c4d.EventAdd()

    #EXTRUDE THE SURFACES TO RANDOM LENGTHS
    sel = res.GetPolygonS()
    c4d.CallCommand(12187)  # Polygons

    saveToPath = "D:\_projects\3d_sandbox\cubic_transformations\render\cuby_"
    outerCounter = 1
    innerCounter = 1

    for growthCounter in range(0, 10):
        for f in range(0, 23):
            c4d.CallCommand(13324)  # Deselect All
            sel.Select(f)

            c4d.CallCommand(1011183)  # Extrude
            getTool()[c4d.MDATA_EXTRUDE_OFFSET] = randrange(10, 40) * 1.0
            fireAction(obj)

        #print(saveToPath + str(outerCounter) + "_" + str(innerCounter))
        #kick out a render
        doc[c4d.RDATA_PATH] = ""
        c4d.CallCommand(12098)  # Save
        c4d.CallCommand(12099)  # Render to Picture Viewer
        #time.sleep(1)
        innerCounter = innerCounter + 1

        outerCounter = outerCounter + 1
        '''
        doc[c4d.RDATA_PATH] = "D:\_projects\3d_sandbox\cubic_transformations\render\cuby_" + str(growthCounter) + str(f)
        c4d.CallCommand(465003525) # Add to Render Queue...
        c4d.CallCommand(465003513) # Start Rendering
        '''

    return obj
Esempio n. 8
0
def main():
    fbx_plugin_id = 1026370
    path=c4d.storage.SaveDialog(c4d.FILESELECTTYPE_ANYTHING,"Export FBX","")
    if not path:return
    if path=="":return
    container = c4d.plugins.GetWorldPluginData(fbx_plugin_id)
    doc = c4d.documents.GetActiveDocument()
    selected = doc.GetActiveObjects(0)
    
    index = 0
    
    for ob in selected:
        obIndex = selected.index(ob)
        obName = ob.GetName()
        savePath = path+"index"+str(obIndex)+"_"+obName
        c4d.CallCommand(100004767, 100004767) #Deselect All
        for remOb in selected:
            remObName = remOb.GetName()
            if remObName!=obName:
                doc.SetActiveObject(remOb, mode=c4d.SELECTION_ADD)
        c4d.CallCommand(100004787) # Delete Active Objects
        c4d.CallCommand(12168, 12168) # Remove Unused Materials
        c4d.plugins.SetWorldPluginData(fbx_plugin_id, container)
        #print "saving to: " + savePath
        c4d.documents.SaveDocument(doc, savePath, c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, fbx_plugin_id)

        c4d.CallCommand(12105, 12105) # Undo remove unused mats
        c4d.CallCommand(12105, 12105) # Undo delete other objects
def addValueAtFrame(xtrack, ytrack, ztrack, XYFrameNum, ZFrameNum, fps,
                    valueVec):

    # linear interpolation
    animation_interpolation_val = 465001092

    # Add a key to each CubeSat linear position tracks
    xtrack = xtrack.GetCurve()
    xkey = xtrack.AddKey(c4d.BaseTime(XYFrameNum, fps))['key']
    xkey.SetValue(xtrack, valueVec[0])

    # set the track position variation to linear
    c4d.CallCommand(animation_interpolation_val)

    ytrack = ytrack.GetCurve()
    ykey = ytrack.AddKey(c4d.BaseTime(XYFrameNum, fps))['key']
    ykey.SetValue(ytrack, valueVec[1])

    # set the track position variation to linear
    c4d.CallCommand(animation_interpolation_val)

    ztrack = ztrack.GetCurve()
    zkey = ztrack.AddKey(c4d.BaseTime(ZFrameNum, fps))['key']
    zkey.SetValue(ztrack, valueVec[2])

    # set the track position variation to linear
    c4d.CallCommand(animation_interpolation_val)
Esempio n. 10
0
    def addLipsMaterial(self):
        doc = documents.GetActiveDocument()
        obj = doc.GetFirstObject()
        scene = ObjectIterator(obj)
        objTags = TagIterator(obj)
        for ob in scene:
            objTags = TagIterator(ob)
            if objTags:
                for tag in objTags:
                    matSel = tag[c4d.TEXTURETAG_RESTRICTION]
                    if matSel == "Lips":
                        try:
                            old_mat = tag[c4d.TEXTURETAG_MATERIAL]

                            doc.SetActiveMaterial(old_mat)
                            c4d.CallCommand(300001022, 300001022)  # Copy
                            c4d.CallCommand(300001023, 300001023)  # Paste
                            newMat = doc.GetFirstMaterial()
                            newMat[c4d.ID_BASELIST_NAME] = "Lips"

                            tag[c4d.TEXTURETAG_MATERIAL] = newMat
                        except:
                            pass

        c4d.EventAdd()
Esempio n. 11
0
    def convertTo(self, matType="Std"):
        doc = c4d.documents.GetActiveDocument()

        success = False

        self.NewMatList = []

        myMaterials = doc.GetMaterials()
        for mat in myMaterials:
            success = self.convertMat(mat, matType)

        self.ApplyMaterials()

        if success:
            print("Done Material Conversion.")
        else:
            c4d.gui.MessageDialog(
                "A problem has occurred or no mats to convert.")

        if matType == "Octane":
            dzc4d.del_unused_mats()
            c4d.CallCommand(100004766, 100004766)  # Select All
            c4d.CallCommand(100004819, 100004819)  # Cut
            c4d.CallCommand(100004821, 100004821)  # Paste

        return True
Esempio n. 12
0
def setMode(s="object"):
    returns = ""
    if s == "model":
        returns = "model"
        c4d.CallCommand(12298)  # Model Mode
    elif s == "object":
        returns = "object"
        c4d.CallCommand(12101)  # Object Mode
    return returns
Esempio n. 13
0
def main():
    sph = c4d.BaseObject(c4d.Osphere)
    sph.SetRelPos(c4d.Vector(0))
    sph[c4d.PRIM_SPHERE_RAD] = 100
    sph[c4d.PRIM_SPHERE_SUB] = 96
    sph[c4d.PRIM_SPHERE_TYPE] = 2
    doc.InsertObject(sph)
    doc.SetActiveObject(sph)
    c4d.CallCommand(12236)  # Make Editable
    c4d.CallCommand(17105)  # Gouraud Shading (Lines)
Esempio n. 14
0
def main():
    # Large Icons
    c4d.CallCommand(100004708, 100004708) 

    # Lines
    c4d.CallCommand(12540, 12540) 
    
    # merge object
    fn = "preset://ShowIndex.lib4d/ShowIndex"
    c4d.documents.MergeDocument(doc, fn, c4d.SCENEFILTER_OBJECTS)
    c4d.EventAdd()
def Select(obj, source, doc, keyMod):
    doc.AddUndo(c4d.UNDOTYPE_BITS, obj)  # Add undo command for changing bits
    if keyMod == "None":
        obj.DelBit(c4d.BIT_ACTIVE)  # Deselect original object
        doc.AddUndo(c4d.UNDOTYPE_BITS,
                    source)  # Add undo command for changing bits
        source.SetBit(c4d.BIT_ACTIVE)  # Select object
        c4d.CallCommand(100004769)  # Scroll to First Active
    elif keyMod == "Shift":
        source.SetBit(c4d.BIT_ACTIVE)  # Select object
        c4d.CallCommand(100004769)  # Scroll to First Active
def main():

    # clear all simulation objects
    # Select All
    c4d.CallCommand(100004766)
    # Delete
    c4d.CallCommand(100004787)
    # Clear Console
    c4d.CallCommand(13957, 13957)

    (settingsFile, configFileName, configSetupFile) = getConfigFile()
    runAndSaveSimulation(settingsFile, configFileName, configSetupFile)
Esempio n. 17
0
    def prop_import(self, file_path, dtu, sss_value, normal_value, bump_value):

        mat = StandardMaterials.StdMaterials()
        if os.path.exists(file_path) == False:
            gui.MessageDialog(
                "Nothing to import.\nYou have to export from DAZ Studio first",
                c4d.GEMB_OK,
            )
            return 0
        print("Import FBX from : {0}".format(os.path.dirname(file_path)))
        self.import_daz_fbx(file_path)
        c4d.DrawViews(c4d.DRAWFLAGS_ONLY_ACTIVE_VIEW
                      | c4d.DRAWFLAGS_NO_THREAD
                      | c4d.DRAWFLAGS_STATICBREAK)
        dzc4d.deselect_all()  # Deselect All

        screen = c4d.gui.GeGetScreenDimensions(0, 0, True)

        c4d.EventAdd()
        dzc4d.update_viewport()
        c4d.CallCommand(300001026, 300001026)  # Deselect All
        dzc4d.del_unused_mats()
        c4d.EventAdd()
        print("Import Done")

        print("Starting Material Updates")
        c4d.EventAdd()
        c4d.DrawViews(c4d.DRAWFLAGS_ONLY_ACTIVE_VIEW
                      | c4d.DRAWFLAGS_NO_THREAD
                      | c4d.DRAWFLAGS_STATICBREAK)
        c4d.EventAdd()
        c4d.CallCommand(300001026, 300001026)  # Deselect All
        dzc4d.del_unused_mats()
        mat.store_materials(dtu)
        mat.store_sliders(sss_value, normal_value, bump_value)
        mat.update_materials()

        print("Material Conversion Done")
        c4d.EventAdd()

        c4d.DrawViews(c4d.DRAWFLAGS_ONLY_ACTIVE_VIEW
                      | c4d.DRAWFLAGS_NO_THREAD
                      | c4d.DRAWFLAGS_STATICBREAK)
        c4d.EventAdd()

        self.dialog = guiASKtoSave()
        self.dialog.Open(
            dlgtype=c4d.DLG_TYPE_MODAL,
            xpos=screen["sx2"] // 2 - 210,
            ypos=screen["sy2"] // 2 - 100,
            defaultw=200,
            defaulth=150,
        )
Esempio n. 18
0
def main(undo = True):
    now = c4d.GeGetTimer() # start stopwatch
    c4d.CallCommand(13957) # Konsole löschen
    # c4d.CallCommand(12305) # Konsole...

    if GetActiveDocument():
        doc     = GetActiveDocument()
        if doc.GetFirstObject():
            c4d.StatusSetSpin()
            op = doc.GetFirstObject()
            myobject = op
            counter = numberofobjects(op)
            secondcounter = 0
            c4d.StatusSetText ('%s Objects are processed.' %(counter))
            opactive = None
        else:
            print "Error: No Objects"
            return False
    else:
        print "Error: No Document"
        return False
    
    #doc.StartUndo() # Start undo support
    # iterate over all objects in the document
    c4d.CallCommand(12113) # Alles deselektieren
    
    while op:
        
        optemp = op
        op = GetNextObject(op) # get next object    
            
        secondcounter += 1        
        statusbar(counter, secondcounter)

        if optemp.CheckType(c4d.Opolygon):
            optemp.SetBit(c4d.BIT_ACTIVE)
  
            if selchildren(optemp,optemp.GetNext()):
                c4d.CallCommand(16768) #Connect And Delete
                c4d.CallCommand(16768) #Connect And Delete
            
            opactive = doc.GetActiveObject()
            opactive.DelBit(c4d.BIT_ACTIVE)
                    
        optemp.DelBit(c4d.BIT_ACTIVE)
            

    c4d.StatusClear()
    #doc.EndUndo() # Do not forget to close the undo support
    c4d.EventAdd()        # update cinema 4d
    print 'END OF SCRIPT %s ms ' %(c4d.GeGetTimer() - now)
    return 
Esempio n. 19
0
def main():
    cube = c4d.BaseObject(c4d.Ocube)
    cube.SetRelPos(c4d.Vector(0))
    cube[c4d.PRIM_CUBE_LEN, c4d.VECTOR_X] = 100
    cube[c4d.PRIM_CUBE_LEN, c4d.VECTOR_Y] = 100
    cube[c4d.PRIM_CUBE_LEN, c4d.VECTOR_Z] = 100
    cube[c4d.PRIM_CUBE_SUBX] = 3
    cube[c4d.PRIM_CUBE_SUBY] = 3
    cube[c4d.PRIM_CUBE_SUBZ] = 3
    doc.InsertObject(cube)
    doc.SetActiveObject(cube)
    c4d.CallCommand(12236)  # Make Editable
    c4d.CallCommand(17105)  # Gouraud Shading (Lines)
Esempio n. 20
0
def main():

    selection = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_NONE)

    i = 0
    for item in selection:
        layer_name = selection[i].GetName()
        doc.SetSelection(selection[i])
        c4d.CallCommand(100004768)
        c4d.CallCommand(100004809)  # Add to New Layer
        new_layer = selection[i][c4d.ID_LAYER_LINK]
        new_layer.SetName(layer_name)
        i = i + 1
Esempio n. 21
0
def main():
    grid = c4d.BaseObject(c4d.Oplane)  # Create Grid
    grid.SetRelPos(c4d.Vector(0))  # Set position
    grid[c4d.PRIM_PLANE_WIDTH] = 100
    grid[c4d.PRIM_PLANE_HEIGHT] = 100
    grid[c4d.PRIM_PLANE_SUBW] = 1
    grid[c4d.PRIM_PLANE_SUBH] = 1
    grid[c4d.PRIM_AXIS] = 2
    doc.InsertObject(grid)  # Insert Grid
    doc.SetActiveObject(grid)  # Select Grid
    c4d.CallCommand(12236)  # Make Editable
    c4d.CallCommand(100004788, 50058)  # New Python Tag
    c4d.CallCommand(100004788, 50059)  # New Xpresso Tag
Esempio n. 22
0
def main():
    getEnvList()

    filePath = c4d.storage.SaveDialog(c4d.FILESELECTTYPE_ANYTHING,
                                      "Export path...", "mtlx")

    # fire off the IPR to gather arnold nodes
    c4d.CallCommand(ARNOLD_RENDER_COMMAND, 1)

    if filePath != "":
        writeMatX(filePath)

    c4d.CallCommand(ARNOLD_RENDER_COMMAND, 0)
Esempio n. 23
0
def main():
    c4d.CallCommand(100004766, 100004766)  # Select All
    c4d.CallCommand(100004787, 100004787)  # Delete
    c4d.CallCommand(100004797, 100004797)  # Select All
    c4d.CallCommand(100004735, 100004735)  # Delete
    c4d.CallCommand(300001025, 300001025)  # Select All
    c4d.CallCommand(300001024, 300001024)  # Delete
    c4d.CallCommand(12149, 12149)  # Frame Default
    c4d.CallCommand(12091, 12091)  # Gouraud Shading
    c4d.CallCommand(12093, 12093)  # Wireframe
def arnolditerationtests():
    # fire off the IPR to gather arnold nodes
    c4d.CallCommand(ARNOLD_RENDER_COMMAND, 1)

    # next we go though the shaders themselves picking up all root shaders and making networks
    aiNodeIterator = AiUniverseGetNodeIterator(AI_NODE_SHADER)

    while not AiNodeIteratorFinished(aiNodeIterator):
        node = AiNodeIteratorGetNext(aiNodeIterator)

        if AiNodeGetName(node) != '':
            print AiNodeGetName(node)

    c4d.CallCommand(ARNOLD_RENDER_COMMAND, 0)
Esempio n. 25
0
def main():

    #c4d.CallCommand(100004768)
    selection = doc.GetSelection()
    selection_len = len(selection)
    i = 0
    for item in selection:
        layer_name = selection[i].GetName()
        doc.SetSelection(selection[i])
        c4d.CallCommand(100004768)
        c4d.CallCommand(100004809)  # Add to New Layer
        new_layer = selection[i][c4d.ID_LAYER_LINK]
        new_layer.SetName(layer_name)
        i = i + 1
Esempio n. 26
0
    def Setting():
        if c4d.gui.GetInputState(c4d.BFM_INPUT_KEYBOARD, c4d.BFM_INPUT_CHANNEL,
                                 bc):

            if bc[c4d.BFM_INPUT_QUALIFIER] == 0:
                c4d.CallCommand(1031195)  # Octane Settings
                c4d.EventAdd()

            elif bc[c4d.BFM_INPUT_QUALIFIER] == 2:
                c4d.CallCommand(1031195)  # Octane Settings
                rdata = doc.GetActiveRenderData()
                rdata[c4d.RDATA_RENDERENGINE] = 1029525
                OctaneRender = 1029525

                videopost = rdata.GetFirstVideoPost()
Esempio n. 27
0
    def mergeObjects(self, objs, name):
        for o in objs:
            doc.InsertObject(o)
            o.ToggleBit(c4d.BIT_ACTIVE)
            o.GetBit(c4d.BIT_ACTIVE)

        c4d.CallCommand(16768)

        group = doc.GetActiveObject()
        group.SetName(name)

        result = group
        c4d.CallCommand(100004767)

        return result
Esempio n. 28
0
    def fix_rig_joints(self, c_joints):
        doc = documents.GetActiveDocument()
        c4d.CallCommand(12102)
        c4d.EventAdd()

        for joint in c_joints:
            doc.SetActiveObject(joint, c4d.SELECTION_NEW)
            doc.AddUndo(c4d.UNDOTYPE_CHANGE, joint)
            rig_joint = self.find_matching_joint(joint)
            if rig_joint:
                self.update_rig_axis(joint, rig_joint)
            c4d.EventAdd()

        c4d.CallCommand(12102)
        c4d.EventAdd()
Esempio n. 29
0
def main():
    doc.StartUndo()
    selection = doc.GetSelection()

    i = 0
    for item in selection:
        doc.AddUndo(c4d.UNDOTYPE_CHANGE, item)
        bs = op.GetPointS()
        sel = bs.GetAll(op.GetPointCount())
        np = []
        zPos = 0
        zList = []

        for index, selected in enumerate(sel):
            if selected:
                v = item.GetPoint(index)
                zList.append(v.z)

        zPos = (min(zList) + max(zList)) / 2.0

        for index, selected in enumerate(sel):
            if not selected:
                np.append(item.GetPoint(index))
            else:
                v = item.GetPoint(index)
                np.append(c4d.Vector(v.x, v.y, zPos))

        item.SetAllPoints(np)
        item.CreatePhongNormals()
        c4d.CallCommand(14039)
        c4d.EventAdd(c4d.EVENT_ENQUEUE_REDRAW)

    doc.EndUndo()
Esempio n. 30
0
    def CreateMaterial(self, MatType=1000, doc=None):
        """Create a new redshift material.

        :param MatType: The type of the Redshift shader (from 1001, Material to 1010 Volume)
        :type MatType: int
        :type doc: c4d.documents.BaseDocument the document to insert material
        :return: Created material or None if it's fail
        :rtype: c4d.Material or None.
        """
        if not isinstance(MatType, int):
            raise TypeError('MatType is not an Integer')

        if doc is not None and not isinstance(doc, c4d.documents.BaseDocument):
            raise TypeError('doc is not a BaseDocument')

        if doc is None:
            doc = c4d.documents.GetActiveDocument()

        if MatType < 1000 or MatType > 1010:
            raise ValueError('Invalid value for matType, must be from 1000 to 1010')

        c4d.CallCommand(1036759, MatType)
        mat = doc.GetFirstMaterial()
        if not mat:
            return None

        return mat