Need a very very simple script... but I got a headache reading the online manual.....

Hi! I hope someone here can give me a hand, I need a very simple scrip, but I don't know anything about MAX scripting, and rarely use it, I'm sure is not that complicated...

I need to get a TXT file with the name of selected objects and XYZ position of them.

the format need to be like this, the 4th value "uncertainty" just have to be fixed to zero, but needs to be there.

if anyone can give me a hand, I will sure mention your name on my class, this is for a FPTrack class I'm working on, hhere I need to extract these values to feed them as survey info for the tracking points.

# Name SurveyX SurveyY SurveyZ Uncertainty
"Tracker0001" 0 0 0 0
"Tracker0002" -7.45 0 0 0
"Tracker0003" -14.9 0 0 0
"Tracker0004" -7.45 -9.9 0 0
"Tracker0005" 0 -19.8 0 0
"Tracker0006" -7.45 -19.8 0 0
"Tracker0007" -14.9 -19.8 0 0

Thanks a lot!!!

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
fajar's picture

@brot : I tried that code

@brot : I tried that code tag, many times befire I posted it, but when I preview or save it didnt do anything , just simple plain text appear, so I just post it that way.

try this

MyLog = "c:\\ObjectPos.txt" -- you can edit this .....
ini_file = createFile MyLog
ToMyLog = openFile MyLog mode:"at"
 
for a in selection do
(
if selection.count !=0 then 
 (
 iProp = ("Object Name = " + a.name) +" ("+ ("pos X = " + a.pos.x as string + ", ") +("pos Y = " + a.pos.y as string + ", ") +("pos Z = " + a.pos.z as string)+" )"
 format "%\n" iProp to:ToMyLog
 )
else (messageBox "Nothing selected !\n Please select something" title:"3ds Max")
)

)

looks like it work with  apalah ....weird !!!!) +(

br0t's picture

hooray :D

hooray :D

Never get low & slow & out of ideas

victorwol's picture

it sort of works... weird

it sort of works... weird thing is does not write the content to the TXT file until I actually close and quit MAX... it does not write it exactly in the way I need it, but it is a good start!!!! I'll see if I can customize it :-)

br0t's picture

I think you have to close the

I think you have to close the file at the end

close ToMyLog

to force it to write on disk.

@fajar: still waiting for the day to come when you start using the [ code ] tag :D
http://www.scriptspot.com/forums/scriptspot-how-to/how-to-post-code-snip...

@victor: you can drag&drop a script to execute it or use Maxscript->Run script.
If it is defined as a macroscript

macroscript blabla 
category:"myGreatScripts"
(
   ...
)

then you can go to "customize user interface" and either add it as a button, hotkey, menu item or quad menu item.

Never get low & slow & out of ideas

victorwol's picture

Actually the error was

Actually the error was because I added a line at the top to define it as a button,

macroScript SpeedSheet category:"HowTo"

to have it on the same menu was the other one I was testing, loading it without that like gives no error, but it does not seems to be doing anything, do I have to assign it to a menu? or should work just by dragging it into MAX?

Thanks

victorwol's picture

Thanks! I'm sure you know A

Thanks! I'm sure you know A LOT more than me...

I'm getting a little error when I try to load it

Syntax error: at name, expected ( in line: Mylog =

Any ideas?

Thanks

fajar's picture

Try this my friend, im noob

Try this my friend, im noob in this ...so anoher master can add it....

MyLog = "c:\\ObjectPos.txt" -- you can edit this .....
ini_file = createFile MyLog
ToMyLog = openFile MyLog mode:"at"

for a in selection do
(
if selection.count !=0 then
(
iProp = ("Object Name = " + a.name) +" ("+ ("pos X = " + a.pos.x as string + ", ") +("pos Y = " + a.pos.y as string + ", ") +("pos Z = " + a.pos.z as string)+" )"
format "%\n" iProp to:ToMyLog
)
else (messageBox "Nothing selected !\n Please select something" title:"3ds Max")
)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.