Notifications
Clear all

[Closed] Split String

Hello.

I am trying to migrate some information from Maya to Max and then split the string and make each part of the string its own attribute.

In Maya I created an Attribute called UDP3DSMAX and passed some information like this:

UDP3DSMAX = NodeName = pCube1$$PivotLocalSpace = [0.0, 0.0, 0.0]$$MayaUUID = 4F715655-46F3-FFF9-7A65-C5A3115553D

Then in Max I would like to split each part separated with “$$” into its own Property to be used as Metadata.
When I perform I get the correct list:

tokens = FilterString myString “$$”

This returns:

NodeName = pCube1
$$PivotLocalSpace = [0.0, 0.0, 0.0]
$$MayaUUID = 4F715655-46F3-FFF9-7A65-C5A3115553DE

Then I would like to split the ” = ” into its own parts to store them as Property like:

for t in tokens do (
subTokens = FilterString t ” = “
setUserProp myObj subTokens[1] subtokens[2] )

Unfortunately this results in cutting the YZ part of the Pivot Transform.:

NodeName = pCube1
$$PivotLocalSpace = [0.0,
$$MayaUUID = 4F715655-46F3-FFF9-7A65-C5A3115553DE

Does any one could give me a hint on how to fix this?
Thanks

2 Replies

just strip all the spaces first


print (for t in FilterString (substituteString str " " "") "$$" collect FilterString t "=")

#(“NodeName”, “pCube1”)
#(“PivotLocalSpace”, “[0.0,0.0,0.0]”)
#(“MayaUUID”, “4F715655-46F3-FFF9-7A65-C5A3115553D”)

Another way could be:

(
	str = "UDP3DSMAX = NodeName = pCube1$$PivotLocalSpace = [0.0, 0.0, 0.0]$$MayaUUID = 4F715655-46F3-FFF9-7A65-C5A3115553D"
	
	tokens = filterstring str "$$="
	
	NodeName        = trimleft tokens[3]
	PivotLocalSpace = trimleft tokens[5]
	MayaUUID        = trimleft tokens[7]
)