Hi, Matt!
I wrote simple testing topo operator and have same problem as Andrew.
Cluster properties not updated. Testing UV operator create new edge as
split tool. I tested this operator on simple plane with 4 vertices. This
code is not universal and does not generate the algorithms, but shows the
general principle, which I was guided.
The problem occurs when I try set UV array and I have not found a solution how
to solve it:

        #update new uv positions
        #!!!uv not updated, since cluster properies not updated
        output.Elements.Array = positionUV

If topology not changed (increase or decrease vertices) or change only UV
(operator for UV modify), it works well.

In attach my plugin.
Thanks!
import win32com.client
from win32com.client import constants

null = None
false = 0
true = 1
app = Application
log = app.LogMessage

def XSILoadPlugin( in_reg ):
	in_reg.Author = "Gescort"
	in_reg.Name = "UVOperatorPlugin"
	in_reg.Major = 1
	in_reg.Minor = 0

	in_reg.RegisterOperator("UVOperator")
	in_reg.RegisterCommand("ApplyUVOperator","ApplyUVOperator")
	return true

def XSIUnloadPlugin( in_reg ):
	strPluginName = in_reg.Name
	Application.LogMessage(str(strPluginName) + str(" has been unloaded."),constants.siVerbose)
	return true

def ApplyUVOperator_Init( in_ctxt ):
	oCmd = in_ctxt.Source
	oCmd.Description = "Create an instance of UVOperator operator"
	oCmd.SetFlag(constants.siNoLogging,false)
	return true

def ApplyUVOperator_Execute(  ):

	Application.LogMessage("ApplyUVOperator_Execute called",constants.siVerbose)
	newOp = XSIFactory.CreateObject("UVOperator")
    
	select = app.Selection[0]
	newOp.AddOutputPort(select.ActivePrimitive)
	newOp.AddInputPort(select.ActivePrimitive)
	cls = select.ActivePrimitive.Geometry.Clusters
	uv = None
	for cl in cls:
		if str(cl.Type) == 'sample':
			props = cl.Properties
			for prop in props:
				if str(prop.Type) == 'uvspace':
					uv = prop
	if uv != None:
		newOp.AddInputPort(uv)
		newOp.AddOutputPort(uv)
	newOp.Connect()
	return newOp

def UVOperator_Define( in_ctxt ):
	oCustomOperator = in_ctxt.Source
	oCustomOperator.AlwaysEvaluate = false
	oCustomOperator.Debug = 0
	return true

def UVOperator_Init( in_ctxt ):
	Application.LogMessage("UVOperator_Init called",constants.siVerboseMsg)
	return true

def UVOperator_Term( in_ctxt ):
	Application.LogMessage("UVOperator_Term called",constants.siVerboseMsg)
	return true

def UVOperator_Update( in_ctxt ):
	Application.LogMessage("UVOperator_Update called",constants.siVerboseMsg)
    #get inputs
	input0 = in_ctxt.GetInputValue(0)
	input1 = in_ctxt.GetInputValue(1)
    #get topo data
	data = input0.Geometry.Get2()
    #convert data to list
	ndata = [[list(data[0][0]), list(data[0][1]), list(data[0][2])], list(data[1])]
	#build custom geometry
	#as example add 2 points (split edges)
    #here should be custom algorithme
	#first point
	ndata[0][0].append(-2.52)
	ndata[0][1].append(0.0)
	ndata[0][2].append(4.0)
	#second point
	ndata[0][0].append(1.5)
	ndata[0][1].append(0.0)
	ndata[0][2].append(-4.0)
	#modify polygon build data
	#here should be custom algorithme
	ndata[1] = [4, 0, 1, 4, 5, 4, 3, 2, 5, 4]
	#get position UV
	positionUV = input1.Elements.Array
	positionUV = [list(positionUV[0]), list(positionUV[1]), list(positionUV[2])]
	#add new sample positions, as example u = 0.0, v = 0.0, w = 0.0
	#here should be custom algorithme
	positionUV[0].append(0.0)
	positionUV[0].append(0.0)
	positionUV[0].append(0.0)
	positionUV[0].append(0.0)
	positionUV[1].append(0.0)
	positionUV[1].append(0.0)
	positionUV[1].append(0.0)
	positionUV[1].append(0.0)
	positionUV[2].append(0.0)
	positionUV[2].append(0.0)
	positionUV[2].append(0.0)
	positionUV[2].append(0.0)
	#output data
	output = in_ctxt.OutputTarget
	if str(output.Type) == 'polymsh':
		#update new geometry
		output.Geometry.Set(ndata[0], ndata[1])
	elif str(output.Type) == 'uvspace':
		#update new uv positions
		#!!!uv not updated, since cluster properies not updated
		output.Elements.Array = positionUV
	return true
------
Softimage Mailing List.
To unsubscribe, send a mail to softimage-requ...@listproc.autodesk.com with 
"unsubscribe" in the subject, and reply to confirm.

Reply via email to