Notifications
Clear all

[Closed] Problem with collect in max9

Hi All,

I have few lines of code that work absolutly fine in max8 but fails in max 9,

 -- This first line works in max9 and max8 
GUIDE_RIG_OBJ_ARRAY = for o in objects where getuserprop o "GUIDE_ID" == 123 collect o
 print GUIDE_RIG_OBJ_ARRAY.count
-- This 2nd line works in max8 but fails in max9
LeftSide = for o in GUIDE_RIG_OBJ_ARRAY where getuserprop o "SYSTEM_SIDE" == "L" collect o
print LeftSide.count

The problem is the 2nd line collects nothing in max9, but collects objects properly in max8! With the same scene and code!!
Has there been a change in how maxscript works from 8 to 9? Or is this a Bug? Whats happening?

I have attached a simple scene that works with the small script above for anyone who has time to check the code.Its a Max8 scene so it can be checked in version 8 and 9.

Thanks for reading

Dan

12 Replies

This looks like a bug to me. For some reason, Max 9 is returning the user property as a long integer value of value 0L (zero) rather than the string “L” returned by Max 8. It shouldn’t affect what you’re doing, but Autodesk did introduce the new Integer64 value type in Max 9…looks like a new bug might have been created along the way.


--Max 8 Listener
getuserprop $ "SYSTEM_SIDE"
"L"
classOf (getuserprop $ "SYSTEM_SIDE")
String
 
--Max 9 Listener
getuserprop $ "SYSTEM_SIDE"
0L
classOf (getuserprop $ "SYSTEM_SIDE")
Integer64

I was able to get the results you want by changing the User Property string to “Left” and then testing for that. Its an easy workaround to suggest, but it might not be easy for you to implement…hopefully you’re not dealing with legacy content filled with “L” strings.

2 Replies
(@davestewart)
Joined: 11 months ago

Posts: 0

I don’t think so. It’s just allowing you to store Integer64 values as User Properties.


 n = 64L
 setUserProp $ "my64Int" n
 x = pow (getUserProp $ "my64Int")  2
-- 4096.0

EDIT: works the same with time values as well:

str = "f"
setUserProp $ "myTimeValue" str
getUserProp $ "myTimeValue"
-- 0f
(@johnswafford)
Joined: 11 months ago

Posts: 0

Dave, I disagree…I’d still call this a bug or at least a bad decision at Autodesk.

When an Integer64 value of 0L (zero) is set to a user property, the string saved is “0L”. When getUserProp is used, it properly returns the Integer64 value of 0L.

However, the user property value of “L” is not a valid Integer64 conversion and it is used so by so many character riggers that a change like this is guaranteed to be needlessly disruptive.

In my opinion, this particular behavior offers no benefits and plenty of potential problems…

Hi Dan,
I love conundrums like this, so I had a crack:

for obj in objects do
 	(
 	local prop = getuserprop obj "SYSTEM_SIDE"
 	format "% : %
" prop (classof prop)
 	)
 

Reveals:

R : String
 R : String
 R : String
 0L : Integer64
 0L : Integer64
 0L : Integer64

The help topic “64 Bit Values – Double, Integer64, IntegerPtr” sheds some light:

Three new Number classes have been added to MAXScript in 3ds Max 9: Double, Integer64 and IntegerPtr
bit.hexAsInt will output a Integer64 in the input string contains an “L”, a IntegerPtr if it contains a “P”.

So if you type: bit.IntAsHex (0 as integer64) you get “0L”

So it looks like max is treating the lone “L” as an Integer64. I guess this is similar as to when you get screwy results adding 1f & 10t (tiem values) or such like.

If you change the “L” to “Left” or such like it should sort things out

Thanks Guys for the speedy response! Its part of quite a large script I have been writing for over a year, and I thought max9 was about to flush all my toil down the bog. I`m glad it can be resolved, I would never have worked out what was happening on my own.

Thanks again

Dan

Hi John,

Well my definition of a bug is something that is broken, and I wouldn’t say this is broken, more just the way it is. I just tested it in max6 (with some time values, eg 25f), and got the same result

What I’m driving at is it’s not a “new bug”, it must be just how the maxscript interpreter works (but I wouldn’t know, I’m just a scripter, not a computer scientist).

But I get your point about there not being a digit in front of the “L” or the “f” making it screwy.

Actually, I think this is new…in Max 8 getUserProp() would return “L” as the string “L”, while Max 9 returned it as the Integer64 value 0L. The behavior with time values that you’re describing has been consistent, but this change in Max 9 is something that wouldn’t bite a scripter until they upgraded to Max 9. Subsequently, a lot of legacy rigging scripts are likely to have unnecessary problems.

You’re right though…if this behavior had been consistent through the versions, I wouldn’t call it a problem either.

 PEN

Well Im glad that you sorted this out for me as I use “L” for left in all my rigs. It would be nice if get user prop just returned the string if there is no number before it in all instances. 3D in general is all about work arounds isn’t it.

4 Replies
(@bobo)
Joined: 11 months ago

Posts: 0

I would consider this a bug, because reading a value from a stringstream does NOT convert the L into a long integer:


s = "L" as stringstream
-->StringStream:"L"
readValue s
-->undefined
 

b = box()
-->$Box:Box03 @ [0.000000,0.000000,0.000000]
setUserProp b "TheValue" "L"
-->OK
getUserProp b "TheValue" 
-->0L

Will log it as a bug, let’s see what will happen…

(@alpineman)
Joined: 11 months ago

Posts: 0

I wouldn’t log the first part as a bug, did you mean to say?

s = "0L" as stringstream
 StringStream:"0L"
 h = readvalue s
 0L
 classof h
 Integer64
(@bobo)
Joined: 11 months ago

Posts: 0

No, the first part was a PROOF that the second part should NOT happen. It was to illustrate the inconsistency, as both do more or less the same, but the second gives an unexpected result.

It also does this with some other values like P,t,m,s…
I logged the bug with some code that shows all bad cases.

(@alpineman)
Joined: 11 months ago

Posts: 0

Ah, the internet… Proves that it is impossible to read someones mind.