Odd problem in MaxScript

So I’m trying to set this point3 value into MaxScript after importing it from a text file, however I get this error:

This basically tells me “unable to convert a point3 into a point3” can anyone help please?

Here’s my code snippet. I highlighted the offending part in red.

Thanks guys!

	while eof in_file == false do
(
	textline = readline in_file
	tokens = filterString textline ";"

	print tokens[1]
	print tokens[2]
	print tokens[3]
	print tokens[4]
	
	exoName[i] = tokens[1] as string
	--exoPosition[i] = tokens[2] as point3
	--exoRotation[i] = tokens[3] as quat
	--exoScale[i] = tokens[4] as point3
	
	
	currNode = getNodeByName exoName[i]
	
	if currNode != undefined do
	(
		move currNode tokens[2] as point3
		rotate currNode (tokens[3] as quat)
		scale currNode (tokens[4] as point3)
	)		
	i = i+1 
)

It’s because “[-3.49,69,666]” is a string and there’s no automatic conversion to a point3

try:

local pointThree = execute token[2]

I’d be nervous of using execute. It has some unpleasant scope side effects.

If your text file is well formed, the following should get you on your way.


-- Untested --
while eof in_file == false do
(
    exoName[i] = readValue in_file
    exoPosition[i] = readValue in_file
    exoRotation[i] = readValue in_file
    exoScale[i] = readValue in_file

    currNode = getNodeByName exoName[i]

    if currNode != undefined do
    (
        move currNode exoPosition[i]
        rotate currNode exoRotation[i]
        scale currNode exoScale[i] 
    )
    i = i+1
)

Cheers,

Drea

Execute is not necessarily bad, but it’s not always the right tool, especially on really large loops. And it always executes in global scope, so sometimes it’s just not wise to use. But for what you’re doing now, I’d probably go with execute, because of it’s simplicity.
I have a tool to store pose values in strings and simply use execute too, no slowdowns I can notice…

But readvalue does feel more “real” :wink:

-Johan

I’ve been using this to convert point3 strings to point3 values:

fn zmStringToPoint3 v =
(
	local pa = filterString v "[],"
	point3 (pa[1] as float) (pa[2] as float) (pa[3] as float)
)

I’m saving point3’s out “as strings” to xml files instead of breaking them down into components. Seems to work fine for me.


rich

edit: yay, first post!

Farmer Brown had been screwing one of his pigs for 5 years, when all of a sudden [b]ugg boots[/b] was hit by pangs of conscience.[b]AIR JORDANS[/b] bothered him so much that [b]gucci shoes[/b] decided that he just had to tell his priest about [b]bet365[/b] in confession.The priest was shocked and could only say to Farmer Brown, “Well, was the pig a male or a female?”“A female, of course,” shouted Farmer Brown!. “What do you think [b]nike shox[/b] am…some sort of queer?”

有的孕妇在怀孕前就患有[b]糖尿病[/b]病,有的孕妇是怀孕后才出现糖尿病的,但不管是哪种情况,对母亲和胎儿都有很大的危害。糖尿病最主要的症状是喝水多、吃饭多、尿尿多。孕妇如果确诊患有糖尿病,要积极上医院治疗。要通过调整饮食,使孕妇血糖达到正常,孕妇无饥饿感,营养供给能满足孕妇和胎儿的需要最为理想。 饮食调整要注意下列几点: 1、饮食量要控制。患糖尿病的孕妇一般食欲都好,进食量较正常的孕妇多,[b]糖尿病医院[/b]这时一定要控制饮食量。主要是限制米、面、薯类食物,每日在250克左右。不要进食含糖高的食物,含糖高的食物进食过多可导致血糖过高,加重糖尿病的病症或产生“大胎儿”。一般每日每公斤体重约需的热量为30-35干卡。最好让医院的营养师根据您个人的情况制定适合于您的食谱。 2、蛋白质的供给要充足。患糖尿病的孕妇要控制饮食量,但是蛋白质的进食量不能少,[b]糖尿病药品[/b]要与妊娠期相同的正常孕妇的每日蛋白质进食量基本相同或略高一些。特别要多吃一些豆制品,增加植物蛋白质。 3、脂肪供给要适量。由于主食碳水化合物类食物供给减少,脂肪进食要适量增加[b]糖尿病治疗[/b],以维持每天的供热量。并可适量进食一些干果,增加供给脂肪。 4、补充维生素和矿物质。多吃一些蔬菜补充维生素,经常吃一些含铁和含钙高的食物,如牛奶、鱼、虾皮、动物肝以补充矿物质。 5、适当限制食盐的摄入。应让[b]糖尿病[/b]孕妇多吃清谈的饮食