Any idea guys?

 

 

 

 

From: [email protected] 
[mailto:[email protected]] On Behalf Of Szabolcs Matefy
Sent: Thursday, September 27, 2012 9:48 AM
To: [email protected]
Subject: RE: Python and xsi commands

 

Hi guys,

 

Sure I know the difference, they are of the same size, and the vbscript version 
runs perfectly. Moreover, if I use a sequence of two elements of the arrays are 
resulting the error message as well.

 

This is the code (make sure, you have a polypainted OBJ from ZBrush!!!!):

 

from sipyutils import si                                  # 
win32com.client.Dispatch('XSI.Application')

from sipyutils import siut                              # 
win32com.client.Dispatch('XSI.Utils')

from sipyutils import siui                              # 
win32com.client.Dispatch('XSI.UIToolkit')

from sipyutils import simath       # win32com.client.Dispatch('XSI.Math')

from sipyutils import log                               # LogMessage

from sipyutils import disp                             # 
win32com.client.Dispatch

from sipyutils import C                                  # 
win32com.client.constants

 

fso = XSIFactory.CreateObject('Scripting.FileSystemObject')

FB = XSIUIToolkit.FileBrowser

FB.Filter = 'OBJ Files (*.obj)|*.obj||'

FB.ShowOpen()

if FB.FilePathName <> '':

                filename = FB.FilePathName

                Application.Logmessage(filename)

                iobjects = Application.ObjImport(filename, 0, 0, True, True, 
False, True)

                listFile = fso.OpenTextFile(filename)

                OBJ = iobjects(0)

                geoOBJ = OBJ.Activeprimitive.Geometry

                nodesizes = 
OBJ.Activeprimitive.ICEAttributes('NbPolygonNodes').DataArray

                nodesize = nodesizes[0]

                a_nodes = [None] *nodesize     #vbObjectInitialize((nodesize,), 
Variant)

                a_VC = [None]*nodesize                             
#vbObjectInitialize((nodesize,), Variant)

                log(len(a_nodes))

                log(len(a_VC))

                l_vcs = Application.CreateVertexColorSupport("","PolyPaint",OBJ)

                cnt = 0

                while not listFile.AtEndOfStream:

                                fname = listFile.ReadLine()

                                if fname[0:5] == '#MRGB':

                                                for i in range(7, len(fname), 
8):

                                                                vRGB = fname[(i 
+ 2):(i + 8)] + '00'

                                                                t_rgb = 
long('0x' + vRGB,0)

                                                                o_vertex = 
geoOBJ.Vertices(cnt)

                                                                for node in 
o_vertex.Nodes:

                                                                                
idx = node.index

                                                                                
a_VC[idx] = t_rgb 

                                                                                
a_nodes[idx] = idx

                                                                cnt += 1

                                if fname=='# End of MRGB block':

                                                log('End of MRGB block, exiting 
while loop')

                                                break

                                                

                xx=Application.PaintVertexColors(OBJ.fullname, a_nodes, a_VC, 1)

                listFile.Close()

else:

                Application.logmessage('Cancelled')

 

From: [email protected] 
[mailto:[email protected]] On Behalf Of Eric Thivierge
Sent: Thursday, September 27, 2012 9:24 AM
To: [email protected]
Subject: Re: Python and xsi commands

 

Seeing your code may help. Keep in mind polynodes are NOT vertices (just 
clarifying). You'll need to get the proper polynodes indices via SDK methods.

Like Xavier said the two arrays need to be the same size.

--------------------------------------------
Eric Thivierge
http://www.ethivierge.com

On Thu, Sep 27, 2012 at 5:12 PM, Xavier Lapointe <[email protected]> 
wrote:

Are you sure a_nodes and a_VC are of the same size?





On Thu, Sep 27, 2012 at 5:09 PM, Szabolcs Matefy <[email protected]> wrote:

Hi,

 

I still have issues with this PaintVertexColors command

 

When I run my script, it gives an error:

 

# ERROR : 2006-PROP-PaintVertexColors - Unexpected failure.

# ERROR : Traceback (most recent call last):

#   File "<Script Block >", line 46, in <module>

#     Application.PaintVertexColors(OBJ.fullname, a_nodes, a_VC, 1)

#   File "<COMObject Application>", line 2, in PaintVertexColors

# COM Error: Out of present range. (0x-7ffdfff6) - [line 46]

 

 

Anyone with any idea?

 

From: [email protected] 
[mailto:[email protected]] On Behalf Of Szabolcs Matefy
Sent: Wednesday, September 26, 2012 1:43 PM
To: [email protected]
Subject: RE: Python and xsi commands

 

Thanks Eric, I'll try it!

 

From: [email protected] 
[mailto:[email protected]] On Behalf Of Eric Thivierge
Sent: Wednesday, September 26, 2012 12:17 PM
To: [email protected]
Subject: Re: Python and xsi commands

 

This code works for me. Make sure you have a CAV map on the object. I used a 
default polymesh sphere.  It's a generic code to set the colors for Polynodes 
0-99 to red (-16777216).

 

# Python

xsi = Application

log = xsi.LogMessage

collSel = xsi.Selection

 

xsi.PaintVertexColors(collSel(0), [x for x in range(100)], [-16777216 for x in 
range(100)], 1)

 

In general Python lists are interpreted as arrays where needed.


--------------------------------------------
Eric Thivierge
http://www.ethivierge.com

On Wed, Sep 26, 2012 at 6:44 PM, Szabolcs Matefy <[email protected]> wrote:

Hey guys,

 

 

Can I add python list as array? I mean that PaintVertexColors command waits for 
arrays, but can I feed list?

 

Anyway, it throws me an error:

 

# ERROR : Traceback (most recent call last):

#   File "<Script Block >", line 41, in <module>

#     Application.PaintVertexColors(OBJ.fullname, a_nodes, a_VC)

#   File "<COMObject Application>", line 2, in PaintVertexColors

# COM Error: Out of present range. (0x-7ffdfff6) - [line 41]

 

I made a script that reads ZBrush polypainted obj, and I wnt to make a python 
version to test which version is faster

 

 

Cheers

 

 

Szabolcs

___
This message contains confidential information and is intended only for the 
individual named. If you are not the named addressee you should not 
disseminate, distribute or copy this e-mail. Please notify the sender 
immediately by e-mail if you have received this e-mail by mistake and delete 
this e-mail from your system. E-mail transmission cannot be guaranteed to be 
secure or error-free as information could be intercepted, corrupted, lost, 
destroyed, arrive late or incomplete, or contain viruses. The sender therefore 
does not accept liability for any errors or omissions in the contents of this 
message, which arise as a result of e-mail transmission. If verification is 
required please request a hard-copy version. Crytek GmbH - 
http://www.crytek.com - Grüneburgweg 16-18, 60322 Frankfurt - HRB77322 
Amtsgericht Frankfurt a. Main- UST IdentNr.: DE20432461 - Geschaeftsfuehrer: 
Avni Yerli, Cevat Yerli, Faruk Yerli

 





-- 
Xavier

 

Reply via email to