Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk 3ds® Max® / MaxScript / matrix3 from file ?
  RSS 2.0 ATOM  

matrix3 from file ?
Rate this thread
 
42165
 
Permlink of this thread  
avatar
  • nirsul
  • Posted: 19 April 2010 03:35 AM
  • Location: Holon
  • Total Posts: 274
  • Joined: 30 August 2006 07:02 PM

Hello

I am creating a small script that needs to read matrix3 values from a file but I cannot convert them back to matric format as they save to file as string.

They appear as “(matrix3[.........])"”

(the double quote is from the listener)

any idea?

Nir



Replies: 0
avatar
  • thedour
  • Posted: 19 April 2010 03:48 AM

I know everyone says “never use the execute command” but in this case it really does the trick for you.

matrix3String "(matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0])" --This is essentially how you have read it in from the file
"(matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0])" --Listener Output

execute matrix3String
(matrix3 [1
,0,0] [0,1,0] [0,0,1] [0,0,0]) --Listener Output

Hope that gets you what you need!



thedour.net
Render 3D @ ScriptSpot.com

Replies: 1
/userdata/avatar/rqzmznq2a_nirsullam100x100.jpg

will try thanks

Nir

Author: nirsul

Replied: 19 April 2010 03:51 AM  
avatar
  • Location: West Midlands, England, UK
  • Total Posts: 14445
  • Joined: 06 August 2007 11:06 PM
  • Permlink of this post

Execute? A simple readValue should work.



Max 4.2 through 2013.
XP-64 (SP2)
NVidia 9800GTX-512 (Driver 266.58).
Core 2 Quad Q6600 2.4GHz, 8Gb Ram, DX9.0c.

Attachment Attachment
Replies: 1
/userdata/avatar/k9ti0d4th_33dffc1.jpg

never used readValue actually.... nice

Author: thedour

Replied: 19 April 2010 04:26 AM  
avatar
  • nirsul
  • Posted: 19 April 2010 04:22 AM

Thanks

I manged to do it with an embedded execute like this:

(execute (execute viewval))

where viewval = “"(matrix3 [0.707107,0.353553,-0.612372] [-0.707107,0.353553,-0.612372] [0,0.866025,0.5] [-73.7862,38.0014,-166.667])"”



Replies: 0
avatar
  • Anubis
  • Posted: 20 April 2010 12:50 PM

Maybe I’ve got the problem… I guess (watching this double quote) so your matrix3 data is formated as string to external file (as in the third example - “text3.txt") and you read it back from the file using readLine(), right?

myVar Matrix3 1 --> (matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0])

file1 
createFile "C:\\test1.txt"
format "%\n" myVar to:file1
close file1

file2 
createFile "C:\\test2.txt"
print myVar to:file2
close file2

file3 
createFile "C:\\test3.txt"
print (myVar as string) to:file3
close file3

openFile "C:\\test3.txt" mode:"r+"
getVar readLine f --> ""(matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0])""
close f

If this is the case you can solve it using readValue() as Steve suggest, like this --

openFile "C:\\test3.txt" mode:"r+"
getVar readValue ((readValue f) as stringStream)
close f


Max 9 through 2009, XP-Pro x64 SP2
ASUS EAH3450 Series (Driver 8.470).
Core 2 Duo E8400 3GHz, 4Gb Ram, DX9.0c.

Attachment Attachment
Replies: 0