Navigation

    • Register
    • Login
    • Search
    1. Home
    2. chuanzhen
    chuanzhen

    chuanzhen

    @chuanzhen

    rigger

    8
    Reputation
    126
    Posts
    345
    Profile views
    2
    Followers
    0
    Following
    Joined Last Online
    Location 北京

    • Profile
    • More
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups
    chuanzhen Follow

    Best posts made by chuanzhen

    RE: ObjectData plugin Draw() question

    Hi,in another post I found a way to achieve my goal of converting the coordinate position to camera space and then scaling it to a small size so that he appears first.

    this is new code:

    def Draw(self,op, drawpass, bd, bh):
        
        
        if not op[c4d.S_MOTIONTRAIL_GTWO_DRAWENABLE]:
            return c4d.DRAWRESULT_OK
        #bd.SetMatrix_Matrix(None, c4d.Matrix())
        pmg = ~bd.GetMg()
        bd.SetMatrix_Camera()
    
        all_pos = self.parameters['all_pos']
        color_lis = self.parameters['color_lis']
        point_size = op[c4d.S_MOTIONTRAIL_GTWO_POINTSIZE]
        bd.SetPointSize(point_size)
        for per_pos,color in zip(all_pos,color_lis):
            bd.SetPen(color)
            cnt = len(per_pos)
            temp_lis = []
            for i in xrange(cnt-1):
                c = (pmg * per_pos[i]).GetNormalized() * 20
                f = (pmg * per_pos[i+1]).GetNormalized() * 20
                bd.DrawLine(c,f,c4d.NOCLIP_D)
                temp_lis.append(c)
            temp_lis.append(f)
            bd.DrawPoints(temp_lis)
        
    
        return c4d.DRAWRESULT_OK
    

    why * 20 will work, * 1or 2 not work (c = (pmg * per_pos[i]).GetNormalized() * 20)?

    posted in Cinema 4D SDK •
    RE: Discussions about spline ik

    @r_gigante @zipit
    The detailed explanation is shown below
    “up interpolattion”
    reback_01.png
    reback_02.png
    Try use "spline trail"
    reback_03.png

    I read some papers, but always been very slow, just only expanded know, such as Frenet–Serret formulas etc. But I did not directly find a better way to replace my current method, and I have been looking for it.

    Computation of Rotation Minimizing Frames This seems to be a good paper, I will read it carefully.

    posted in General Talk •
    RE: Some questions about PSD correction

    @m_adam Thank you for your team's reply.
    I will share my exploration in this post in the future.☺

    posted in Cinema 4D SDK •
    RE: Is there any way to check deformcache dirty

    try use GetDirty(DIRTYFLAGS_CACHE),compare last dirty and current dirty

    posted in Cinema 4D SDK •
    RE: Method to access CAMorphNode pointdata reference index?

    Hi,
    you can read this thread

    posted in Cinema 4D SDK •
    python sdk document error

    Hi,
    i read python sdk BaseContainer.FindIndex() return a bool but actually return a dict

    xxx.png

    posted in Cinema 4D SDK •
    RE: how to Scroll UserArea

    This is the sample code, I tried to dynamically create the element inside the group to achieve, the picture is not drawn completely as expected:

    import c4d
    import os
    import sys
    from c4d import gui,bitmaps,plugins,utils,modules,storage
    
    
    PLUGIN_ID = 10000000 #only for test
    
    
    
    GROUP_SCROLL = 1100
    USEEAREA_GROUP = 1102
    USERAREA = 1101
    
    ADD_BUTTON = 1200
    
    class PreViewArea(gui.GeUserArea):
        bmp = None
    
    
        def DrawMsg(self,x1, y1, x2, y2, msg):
            self.OffScreenOn()
            self.SetClippingRegion(x1, y1, x2, y2)
            BG_colorDict = self.GetColorRGB(c4d.COLOR_BG)
            BG_color = c4d.Vector(BG_colorDict['r'], BG_colorDict['g'], BG_colorDict['b']) / 255.0
            self.DrawSetPen(BG_color)
            self.DrawRectangle(x1, y1, x2, y2)
    
            if self.bmp:
                width = self.bmp.GetBw()
                height = self.bmp.GetBh()
                self.DrawBitmap(self.bmp, 0, 0, width, height, 0, 0, width, height, c4d.BMP_NORMAL)
    
    def dynamic_Group(dialog,ua):
        dialog.LayoutFlushGroup(USEEAREA_GROUP)
    
        if ua.bmp:
            width = ua.bmp.GetBw()
            height = ua.bmp.GetBh()
        else:
            width,height = 0,0
        dialog.AddUserArea(USERAREA, c4d.BFH_SCALE | c4d.BFV_SCALE,width,height)
        dialog.AttachUserArea(ua, USERAREA)
        dialog.LayoutChanged(USEEAREA_GROUP)
    
    class S_Lib_Dialog(gui.GeDialog):
        ua = PreViewArea()
    
    
        def CreateLayout(self):
            self.SetTitle("test")
            self.ScrollGroupBegin(PLUGIN_ID, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, c4d.SCROLLGROUP_HORIZ | c4d.SCROLLGROUP_VERT)
            self.GroupBegin(USEEAREA_GROUP,c4d.BFH_LEFT | c4d.BFV_TOP,1,1)
            self.GroupBorder(c4d.BORDER_ACTIVE_1)
            self.AddUserArea(USERAREA, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT)
            self.AttachUserArea(self.ua, USERAREA)
            self.GroupEnd()
    
            self.GroupEnd()
            self.AddButton(ADD_BUTTON,c4d.BFH_SCALEFIT,150,30,"Load image")
    
    
            return True
    
        def Command(self, id, msg):
            if id == ADD_BUTTON:
                path = storage.LoadDialog(type=c4d.FILESELECTTYPE_IMAGES)
                if path:
                    bmp = bitmaps.BaseBitmap()
                    result,ismovie = bmp.InitWith(path)
                    if result == c4d.IMAGERESULT_OK:
                        self.ua.bmp = bmp
                        dynamic_Group(self, self.ua)
                        self.ua.Redraw()
                    else:
                        print("Load image Fail")
                else:
                    print("Not select image")
    
    
    
                return True
    
            return True
    
    
    
    
    
    
    class S_Lib(plugins.CommandData):
    
        dialog = None
    
        def Execute(self,doc):
            # create the dialog
            if self.dialog is None:
                self.dialog = S_Lib_Dialog()
    
            return self.dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, pluginid=PLUGIN_ID, defaultw=800, defaulth=400)
    
        def RestoreLayout(self, sec_ref):
            # manage nonmodal dialog
            if self.dialog is None:
                self.dialog = S_Lib_Dialog()
    
            return self.dialog.Restore(pluginid=PLUGIN_ID, secret=sec_ref)
    
    
    # Execute main()
    if __name__=='__main__':
        path, fn = os.path.split(__file__)
        plugins.RegisterCommandPlugin(id=PLUGIN_ID,
                                      str="test",
                                      info=0,
                                      help="",
                                      dat=S_Lib(),
                                      icon=None)
    
    
    posted in Cinema 4D SDK •

    Latest posts made by chuanzhen

    RE: Check the user switch documents in CommandData plugins

    @ferdinand Thanks for your help!

    posted in Cinema 4D SDK •
    Check the user switch documents in CommandData plugins

    Hi,
    I want to refresh the dialog when switching documents. I tried to use the following code, but it seems that this cannot be achieved .
    When I switch documents, it seems that I only receive type==c4d.MSG_COMMANDINFORMATION

    code:

        def Message(self, type, data):
            print("msg type:{}".format(type))
            print("data:{}".format(data))
            if type == c4d.MSG_DOCUMENTINFO:
                if data['type'] == c4d.MSG_DOCUMENTINFO_TYPE_SETACTIVE:
                    print("doc Change!")
            return True
    

    Thanks for any help!

    posted in Cinema 4D SDK •
    RE: Copy info from one Object to other Object

    @manuel Thanks for your help!

    posted in Cinema 4D SDK •
    Copy info from one Object to other Object

    Hi,
    i want to Copy all info of one Object to other Object.Use source.CopyTo(aim), But object aim is dead after CopyTo().
    My purpose is to copy all the information of an object except the basic information to another object, so after CopyTo(), I want to use the backup information to restore the basic information of aim, but the object is dead and an exception will be thrown

    this is code:

    import c4d
    from c4d import gui
    
    def main():
        source,aim = doc.GetActiveObjects(2)
        doc.StartUndo()
        #backup basic properties
        info_list = []
        description = aim.GetDescription(c4d.DESCFLAGS_DESC_NONE)
        did_list = [c4d.DescID(c4d.DescLevel(110050, 1, 110050)),
                    c4d.DescID(c4d.DescLevel(1041666, 1, 110050))]
        for bc, paramid, groupid in description:
            if groupid in did_list:
                if aim[paramid]:
                    info_list.append((paramid, aim[paramid]))
        doc.AddUndo(c4d.UNDOTYPE_CHANGE,aim)
        source.CopyTo(aim, c4d.COPYFLAGS_NO_BRANCHES|c4d.COPYFLAGS_NO_MATERIALPREVIEW|c4d.COPYFLAGS_NO_BITS)
        #restore  basic properties
        for info in info_list:
            aim[info[0]] = info[1]
        
        doc.EndUndo()
        c4d.EventAdd()
    # Execute main()
    if __name__=='__main__':
        main()
    

    Thanks for any help!

    posted in Cinema 4D SDK •
    RE: Render Settings change Save state

    @ferdinand Thanks you for your help!

    posted in Cinema 4D SDK •
    RE: Render Settings change Save state

    @ferdinand Thanks

    posted in Cinema 4D SDK •
    RE: Render Settings change Save state

    xxxxxxxx.png

    pic 2 : Close Save, the regluar image Save must be not save

    pic 3:Open Save, the regluar image Save save or not save depends on itself

    posted in Cinema 4D SDK •
    RE: Render Settings change Save state

    @ferdinand Thanks,MyRenderSetting[c4d.RDATA_SAVEIMAGE] = True I use this method in my code, it can achieve the purpose of not save image, but I am wondering if I can access the state of the Save element in pic1, so that when I activate my renderSetting, I do not click Go in and check the status of [c4d.RDATA_SAVEIMAGE], you can also directly know whether it is a saved state or an unsaved state during the current rendersetting

    posted in Cinema 4D SDK •
    RE: how to Scroll UserArea

    @m_adam Thanks for your help,great work!

    posted in Cinema 4D SDK •
    RE: how to Scroll UserArea

    @m_adam Thanks!

    posted in Cinema 4D SDK •