Author Topic: detecting the height of the highest brick in a load/on a server  (Read 1791 times)

title is pretty explanatory. is there a way to detect the height of the highest brick on the server/in a load
« Last Edit: July 31, 2013, 10:51:40 PM by ultimamax »

You can probably make some kind of package of fxDTSBrick::onLoadPlant checking the Z positions of each brick, but you'll have to figure out how to determine when a load is begun and ended. I'm sure there are functions for that, but I'm not sure what they are.

To figure this out for a load, open up a bls in notepad and read through it.

A line for a brick looks something like.. 64x64 Base" -64 84 0.1 0 1 50  0 0 1 1 1

So.. make a new file object, loop through the file until you come across a line that starts with Linecount, After that, check that strPos(%line, "\"") >= 0, if this is true, getWord(getSubStr(%line, (%pos=strPos(%line,"\"")+1),strLen(%line)-%pos), 3) to get the height of the brick.

In a server, loop through mainBrickGroup to get the individual brick groups. Loop through the individual brick groups and check for the highest brick with isPlanted == true.

To figure this out for a load, open up a bls in notepad and read through it.

A line for a brick looks something like.. 64x64 Base" -64 84 0.1 0 1 50  0 0 1 1 1

So.. make a new file object, loop through the file until you come across a line that starts with Linecount, After that, check that strPos(%line, "\"") >= 0, if this is true, getWord(getSubStr(%line, (%pos=strPos(%line,"\"")+1),strLen(%line)-%pos), 3) to get the height of the brick.

In a server, loop through mainBrickGroup to get the individual brick groups. Loop through the individual brick groups and check for the highest brick with isPlanted == true.

I'm not familiar with brickGroups.. the load file one sounds easy though. Can you explain brickgroups/give a reference

I'm not familiar with brickGroups.. the load file one sounds easy though. Can you explain brickgroups/give a reference

Yeah, sure. Brick groups are instances of SimGroups, so the main functions you'll need are getCount() and getObject(idx).

You can loop through all bricks in a server by doing this:
Code: [Select]
for(%cidx = 0; %cidx < mainBrickGroup.getCount(); %cidx++) {
    %bGroup = mainBrickGroup.getObject(%cidx);
    for(%bidx = 0; %bidx < %bGroup.getCount(); %bidx++) {
        %brick = %bGroup.getObject(%bidx);
    }
}

Though, I should mention that since the conditional statement is checked every loop, it would be faster to do this:
Code: [Select]
%mbgCount = mainBrickGroup.getCount();
for(%cidx = 0; %cidx < %mbgCount; %cidx++) {
    %bGroup = mainBrickGroup.getObject(%cidx);
    %bGroupCount = %bGroup.getCount();
    for(%bidx = 0; %bidx < %bGroupCount; %bidx++) {
        %brick = %bGroup.getObject(%bidx);
    }
}

I understand now. Thanks.