Generate UV-Tag [SOLVED]

On 13/03/2015 at 02:08, xxxxxxxx wrote:

Hi all,

I want to generate some polygons with a uv-Tag.
But something is going wrong:-(
The generation of the Polygon ist ok.
But the UV-tag sems to be empty ?!?

I searched in the forum but did not find any other example.

What is my fault?

  
    for i in xrange (0, anz_poly) :   
        width = size_list[i*2]   
        height = size_list[i*2+1]   
        width_halbe = width / 2   
        height_halbe = height / 2   
          
          
        obj = c4d.PolygonObject(4, 1)   
          
        p1 = c4d.Vector(width_halbe,   0, 0)   
        p2 = c4d.Vector(width_halbe, height, 0)   
        p3 = c4d.Vector(-width_halbe, height, 0)   
        p4 = c4d.Vector(-width_halbe, 0,   0)   
          
        obj.SetAllPoints([p1,p2,p3,p4])   
  
  
        obj.SetPolygon(0, c4d.CPolygon(0, 1, 2, 3))   
        doc.InsertObject(obj)   
          
        # Generate UV-Tag   
        obj.MakeTag(c4d.Tuvw)   
        UVWTag = obj.GetTag(c4d.Tuvw)   
        print UVWTag   
        UVWTag.SetSlow(0, p1, p2, p3, p4)   
  

Thanks a lot

On 13/03/2015 at 04:23, xxxxxxxx wrote:

Hi Ronny,

you need to set the size of a variable tag, like the uvwtag, if you create it.
Please don´t forget to update your polygonobject if you create a new polygon with MSG_UPDATE.

  
  size_list = [200,300,400,500]  
  
  for i in xrange (1) :  
      width = size_list[i*2]  
      height = size_list[i*2+1]  
      width_halbe = width / 2  
      height_halbe = height / 2  
       
       
      obj = c4d.PolygonObject(4, 1)  
       
      p1 = c4d.Vector(width_halbe,   0, 0)  
      p2 = c4d.Vector(width_halbe, height, 0)  
      p3 = c4d.Vector(-width_halbe, height, 0)  
      p4 = c4d.Vector(-width_halbe, 0,   0)  
       
      obj.SetAllPoints([p1,p2,p3,p4])  
  
  
      obj.SetPolygon(0, c4d.CPolygon(0, 1, 2, 3))  
      obj.Message(c4d.MSG_UPDATE)  
      doc.InsertObject(obj)  
       
      # Generate UV-Tag with data size  
      obj.MakeVariableTag(c4d.Tuvw,2 )  
      c4d.EventAdd()  
      UVWTag = obj.GetTag(c4d.Tuvw)  
  
      print UVWTag  
      print UVWTag.GetDataCount()  
        
      UVWTag.SetSlow(i, p1, p2, p3, p4)  
       
      uvwdict = UVWTag.GetSlow(i)  
      print uvwdict["a"]  
      print uvwdict["b"]  
      print uvwdict["c"]  
      print uvwdict["d"]  

Best wishes
Martin

On 13/03/2015 at 08:42, xxxxxxxx wrote:

Thank to you Martin.
But there is somethin not like i hoped:

First of all , I get the message:
"Es gibt ein Problem mit diesem Projekt: Object "Polygon-Objekt" - Tag 5671 not in sync. Speichern Sie es bitte und kontaktieren Sie unter Angabe Ihrer letzten verwendeten Befehle, Aktionen oder Plug-ins den MAXON-Support."

And this even after I places a "obj.Message(c4d.MSG_UPDATE)" at the end.

When I look to the UV-Mesh (in Bodypain UV Edit) of a plane whitch I convert to a polygon I see a recktangle.
When I look to the UV-Mesh (in Bodypain UV Edit) of the generated polygone, I only see a line in the UV-Mesh Editor.
Do I make a mistake when I whant to create the UV-Tag this way???
Isn' it the same????
I thought I would get now the same rectangle like from a converted Plane-Objekt.

  
import c4d   
from c4d import gui   
#Welcome to the world of Python   
  
  
def main() :   
    size_list = [200,300,400,500]   
  
    for i in xrange (1) :   
        width = size_list[i*2]   
        height = size_list[i*2+1]   
        width_halbe = width / 2   
        height_halbe = height / 2   
          
          
        obj = c4d.PolygonObject(4, 1)   
          
        p1 = c4d.Vector(width_halbe,   0, 0)   
        p2 = c4d.Vector(width_halbe, height, 0)   
        p3 = c4d.Vector(-width_halbe, height, 0)   
        p4 = c4d.Vector(-width_halbe, 0,   0)   
          
        obj.SetAllPoints([p1,p2,p3,p4])   
  
  
        obj.SetPolygon(0, c4d.CPolygon(0, 1, 2, 3))   
        obj.Message(c4d.MSG_UPDATE)   
        doc.InsertObject(obj)   
          
        # Generate UV-Tag with data size   
        obj.MakeVariableTag(c4d.Tuvw,2 )   
        c4d.EventAdd()   
        UVWTag = obj.GetTag(c4d.Tuvw)   
  
        print "UVW-Tag",UVWTag   
        print "UVW-TagCount",UVWTag.GetDataCount()   
          
        print "i", i   
        UVWTag.SetSlow(i, p1, p2, p3, p4)   
          
        uvwdict = UVWTag.GetSlow(i)   
        print uvwdict["a"]   
        print uvwdict["b"]   
        print uvwdict["c"]   
        print uvwdict["d"]   
        obj.Message(c4d.MSG_UPDATE)   
  
if __name__=='__main__':   
    main()   
  

Best wish
Ronny

On 13/03/2015 at 11:18, xxxxxxxx wrote:

Hi Ronny,

yes, sorry data count was too high, a typo.This should work with no errors.

obj.MakeVariableTag(c4d.Tuvw,1 )

if you want your uvs fit into the canvas they should not have greater values than 1.
In your example you can test something like:

UVWTag.SetSlow(i, p1/1000, p2/1000, p3/1000, p4/1000)

Test it, you´ll see what I mean.

Hope this helps?
Best wishes
Martin

On 16/03/2015 at 01:22, xxxxxxxx wrote:

@moneytack:

Thanks a lot.
But It is verry interestion in witch order the points have to be used 🙂
And another advice:
The x,x,z values in the points shouldn't not be grater than 1 for my usage!

Ronald

On 18/03/2015 at 10:26, xxxxxxxx wrote:

Hi guys,

It looks like the issue has been resolved.  I'll tag the topic as solved, but leave it open in case any follow up posts need to be made.

Joey Gaspe
SDK Support Engineer

On 19/03/2015 at 03:30, xxxxxxxx wrote:

Yes, the problem is solved!
Thanks for your help.

Ronald