Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    New CallUVcommand

    Scheduled Pinned Locked Moved PYTHON Development
    11 Posts 0 Posters 1.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      On 05/10/2016 at 08:27, xxxxxxxx wrote:

      `Hi all !

      ``c4d.modules.bodypaint.CallUVCommand( points , pointCount , polys , polyCount , uvw , polySelection , pointSelection , op , mode , cmdid , settings )

      I'm trying to use this CallUvCommand to automatically do a cubic optimal mapping on any object. But I can't feed it with all the arguments it requires... If I just want it to be applied to the whole object, do I always need to specify all of them (point + polys + selections + uvw ...)? I tried to skip "useless" arguments with None but it always claims for them.

      What would the command look like for applying such an optimal mapping on a polygon converted cube?
      `
      >
      > c4d.modules.bodypaint.CallUVCommand(points = op.GetAllPoints() , pointCount = len(op.GetAllPoints()), polys = ?, polyCount = ?,uvw = ?, polySelection = None, pointSelection = None, op = op, mode = c4d.Mobject, cmdid = c4d.UVCOMMAND_OPTIMALCUBICMAPPING, settings = settings)
      >
      > Thanks for some help on how to use this.
      >
      > Mike
      >

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 06/10/2016 at 06:29, xxxxxxxx wrote:

        Hi Mike,

        we have an example script how to use the CallUVCommand(). See here: CallUVCommand.py
        Let me know, if you are still missing anything.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 06/10/2016 at 06:45, xxxxxxxx wrote:

          This seems to be exactly what I was looking for !

          I will dig into it, lots of thanks !

          Mike

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 06/10/2016 at 16:15, xxxxxxxx wrote:

            Hi Andreas,

            I used your example, I can now fill all the needed arguments successfully, but even if the CallUVCommand is correctly executed there is no visible result in the UV set.

            Do you obtain some result using it ? (I also directly tried the UVCOMMAND_TRANSFORM from the example, and no result neither... )

            \> def main() :  
            \>       
            \>     op = doc.GetActiveObject()  
            \>       
            \>     handle = bodypaint.GetActiveUVSet(doc, c4d.GETACTIVEUVSET_ALL)  
            \>     if not handle:  
            \>         print "No active UVSet!"  
            \>         return  
            \>       
            \>     # Prints UVSet information  
            \>     print "UV handle data:"  
            \>     print "handle:", handle  
            \>     print "handle Mode:", handle.GetMode()  
            \>     print "handle Points:", handle.GetPoints()  
            \>     print "handle Polygons:", handle.GetPolys()  
            \>     print "handle Polygon selection:", handle.GetPolySel()  
            \>     print "handle hidden Polygons:", handle.GetPolyHid()  
            \>     print "handle Point selection:", handle.GetUVPointSel()  
            \>     print "handle Point count:", handle.GetPointCount()  
            \>     print "handle Polygon count:", handle.GetPolyCount()  
            \>     print "handle Object:", handle.GetBaseObject()  
            \>     print "handle Editable:", handle.IsEditable()  
            \>     uvw = handle.GetUVW()  
            \>     print "handle UVW:", uvw  
            \>     print "handle set UVW:", handle.SetUVW(uvw)  
            \>     print "handle set UVW (from texture view) :", handle.SetUVWFromTextureView(uvw, True, True, True)  
            \>       
            \>       
            \>     # Builds UVCOMMAND_TRANSFORM container for the command settings  
            \>     settings = c4d.BaseContainer()  
            \>     settings[c4d.OPTIMALMAPPING_PRESERVEORIENTATION] = 1  
            \>     settings[c4d.OPTIMALMAPPING_STRETCHTOFIT] = 0  
            \>     settings[c4d.OPTIMALMAPPING_SPACING] = 0.02  
            \>     settings[c4d.OPTIMALMAPPING_AREAFAK] = 0  
            \>     settings[c4d.OPTIMALMAPPING_TWOD] = 0  
            \>     settings[c4d.OPTIMALMAPPING_PROGRESSBAR] = 0   
            \>     settings[c4d.OPTIMALMAPPING_RELAXCOUNT] = 0   
            \>     # Calls UVCOMMAND_TRANSFORM  
            \>       
            \>     ret =bodypaint.CallUVCommand(handle.GetPoints(), handle.GetPointCount(), handle.GetPolys(), handle.GetPolyCount(),handle.GetUVW(), handle.GetPolySel(), handle.GetUVPointSel(), op,handle.GetMode(), c4d.UVCOMMAND_OPTIMALCUBICMAPPING, settings)  
            \>     if not ret:  
            \>         print "CallUVCommand() failed!"  
            \>         return  
            \>       
            \>     # Tries to set UVW from Texture View  
            \>     print "CallUVCommand() successfully called"  
            \>     if handle.SetUVWFromTextureView(handle.GetUVW(), True, True, True) :  
            \>         print "UVW from Texture View successfully set"  
            \>     else:  
            \>         print "UVW from Texture View failed to be set!"  
            \>   
            \>     # Releases active UVSet  
            \>     bodypaint.FreeActiveUVSet(handle)      
            \>       
            \>       
            \>       
            \> if __name__=='__main__':  
            \>     main()  
            \> 
            

            >
            > Any hint ?
            >
            >

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              On 07/10/2016 at 07:24, xxxxxxxx wrote:

              Hi Mike,

              Yannick will get back to you on Monday on this issue. Sorry, for the delay.

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                On 10/10/2016 at 09:36, xxxxxxxx wrote:

                Hi Mike,

                I'm terribly sorry I've bad news for this issue with the newly added CallUVCommand() in R18: it has an important issue and can't work in its current form.
                The issue is CallUVCommand() doesn't change the passed UVW list so handle.SetUVWFromTextureView() is always called with the initial UVW list...

                The example script hasn't been tested thoroughly. We have to make sure this won't happen again.

                We will keep you updated when we know about a fix.

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  On 10/10/2016 at 15:42, xxxxxxxx wrote:

                  Hi Yannick,

                  No problem, as long as it is on the fix list 😉

                  Thanks for investigating and keeping me informed.

                  Mike

                  1 Reply Last reply Reply Quote 0
                  • H Offline
                    Helper
                    last edited by

                    On 21/11/2016 at 12:42, xxxxxxxx wrote:

                    Do I understand correctly that the new CallUVCommand does not work ... for any of the UVcommands?
                    Or is there only a problem with handle.SetUVWFromTextureView ?

                    Additionally, when I tried using the relaxation command:

                      
                    settings = c4d.BaseContainer()  
                    settings[c4d.RELAXUV_CUT_EDGESEL] = True  
                    bs = obj.GetSelectedEdges(nbr, c4d.EDGESELECTIONTYPE_SELECTION)  
                    settings[c4d.RELAXUV_EDGESEL_POINTER] = bs  
                                                
                    ret = bodypaint.CallUVCommand(handle.GetPoints(), handle.GetPointCount(), handle.GetPolys(), handle.GetPolyCount(), handle.GetUVW(), handle.GetPolySel(), handle.GetUVPointSel(), obj, handle.GetMode(), c4d.UVCOMMAND_RELAX, settings)  
                    

                    I got TypeError: could not convert 'c4d.BaseSelect',
                    settings[c4d.RELAXUV_EDGESEL_POINTER] doesn't seem to accept a c4d.BaseSelect ?

                    1 Reply Last reply Reply Quote 0
                    • H Offline
                      Helper
                      last edited by

                      On 22/11/2016 at 00:31, xxxxxxxx wrote:

                      If i'm right [c4d.RELAXUV_EDGESEL_POINTER] is waiting for a string corresponding to the tag name not directly to the base select.

                      Like all others elements that work with a selection set.

                      1 Reply Last reply Reply Quote 0
                      • H Offline
                        Helper
                        last edited by

                        On 22/11/2016 at 01:59, xxxxxxxx wrote:

                        Originally posted by xxxxxxxx

                        If i'm right [c4d.RELAXUV_EDGESEL_POINTER] is waiting for a string corresponding to the tag name not directly to the base select.

                        Like all others elements that work with a selection set.

                        Thanks gr4ph0s,
                        Didn't think about that. I tried creating a selectiontag, and passing the name via the settings container. This seemed to be OK as I didn't get any errors in the console, but no change in UVs. So I guess the whole CallUVCommand simply doesn't work.

                        Then again, why does the command require a selection tag? Why not allow to perform the relaxation via the currently selected edges ... just like the way it works in Cinema4D?

                        1 Reply Last reply Reply Quote 0
                        • H Offline
                          Helper
                          last edited by

                          On 24/11/2016 at 08:31, xxxxxxxx wrote:

                          Hi,

                          Do not be confused by the dialog for UV Relax and the actual settings container to be passed to CallUVCommand(). These are different.
                          RELAXUV_EDGESEL_POINTER should be set a BaseSelect pointer like in C++ but that's not possible in Python. It's a limitation and this special case has to be handled by the Python API.

                          And yes CallUVCommand() is currently broken, the UVs aren't changed. We're aware of that.

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post