PDA

View Full Version : For Loop Help


murry
04-04-2008, 01:54 PM
I'm trying to write a script which will log when files are added to a scene and when they are deleted. I've got it to log when new files are added to the scene, and in which version of the file they were added. If an object is deleted from the scene i want this object to remain in the log file. This might be easier to explain with an example...


4, Object Name, 1, 2, 3, 4, 5, 6, 7,
1, Box01, 12, 12, 12, 12, 12, 12, 12, ;
2, Box02, 12, 12, 12, 12, 12, 12, 12, ;
3, Box03, 12, 12, 12, 12, 12, 12, 12, ;
4, Box04, , , , , , 12, 12, ;

The first number is the total number of objects in the scene, below this is the object ID, then its the object name, followed by the number of faces for each version. In this example Box04 was not added until version 6 of the scene.

The code im using to generate this is as follows:

for o in geometry do
(
theMesh = snapshotasMesh o
try
(
skiptonextline in_file
a = readvalue in_file
b = readdelimitedstring in_file ";"
c = theMesh.numfaces as string
if a == o.inode.handle then
(
append b c
append b ", ;"
format "%, %\n" a b to:output_file
)
else
(
format "%*, %\n" a b to:output_file
)
)


Where in_file is the original log file and output_file is the new version of the log file.
The problem i have is if the object ID read from the log file does not match the object id in the scene it should print the original line of text and then check that same object id in the scene against the next object ID in the log file.

So is it possible to prevent the for loop from progressing to the next item in the scene until something is true?

Hopefully someone will understand what im trying to achieve :)
Thanks

Mr-BlueSummers
04-07-2008, 01:43 AM
Sounds like a job for "while" functionality.

CGTalk Moderation
04-07-2008, 01:43 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.