Community
Dynamic Blocks Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

array of tiles

2 REPLIES 2
Reply
Message 1 of 3
geoffrey_delcourt
232 Views, 2 Replies

array of tiles

Hi

 

I got 5 tiles of 500x500 units lined up next to eachother. From left to right: tile 1 is always 500x500, tile 2 can have a variable size but is maximum 500 units, tile 3 is always 500x500, tile 4 has the same properties as tile 2, and tile 5 is always 500x500. When I increase the distance that needs to be covered with tiles, tile 2 and 4 should adjust accordingly and tile 3 should be duplicated.

For example: If I want a distance of 5700 to be covered with tiles, the line up from left to right should be 500x500 - 500x350 - 8 tiles of 500x500 - 500x350 - 500x500

 

How can I achieve this?

2 REPLIES 2
Message 2 of 3

Here's how you can achieve the desired tile arrangement with variable tile sizes and duplication based on the total distance to be covered:

1. Define Variables:

total_distance = 5700  # Replace with your desired distance
fixed_tile_width = 500
max_variable_width = 500

# Initialize variables to store tile layout
num_fixed_tiles = 2  # Number of fixed-size tiles (1 and 5)
variable_tile_width = 0  # Width of each variable tile (2 and 4)
num_variable_tiles = 0  # Number of variable tiles

2. Calculate Available Space:

available_space = total_distance - (num_fixed_tiles * fixed_tile_width)

3. Determine Variable Tile Width:

# Check if available space is enough for even distribution of variable tiles
if available_space >= 2 * max_variable_width:
  variable_tile_width = max_variable_width
else:
  # If not enough space, allocate remaining space equally to variable tiles
  variable_tile_width = available_space // 2

4. Calculate Number of Variable Tiles:

num_variable_tiles = available_space // variable_tile_width

5. Calculate Number of Duplicated Tiles (Tile 3):

num_duplicate_tiles = (available_space + fixed_tile_width) // fixed_tile_width - 1

6. Print/Display the Tile Layout:

print("Tile Layout:")
print(f"{num_fixed_tiles} tiles of {fixed_tile_width}x{fixed_tile_width}")
print(f"{num_variable_tiles} tiles of {variable_tile_width}x{fixed_tile_width}")
print(f"{num_duplicate_tiles} tiles of {fixed_tile_width}x{fixed_tile_width} (duplicated)")

Explanation:

  1. We define variables for the total distance, fixed tile size, maximum variable tile size, and initialize variables to store the tile layout information.
  2. We calculate the available space remaining after accounting for the fixed tiles.
  3. We determine the width of the variable tiles (either the maximum allowed or an equal distribution of the remaining space).
  4. We calculate the number of variable tiles that can fit within the available space using the determined width.
  5. We calculate the number of times tile 3 (fixed size) needs to be duplicated to fill the remaining space.

Example Output (for total_distance = 5700):

Tile Layout:
2 tiles of 500x500
2 tiles of 350x500
8 tiles of 500x500
1 tile of 500x500 (duplicated)

Adapting the Code:

  • You can modify the code to incorporate it into your specific programming language or environment.
  • The logic can be adapted for different tile sizes or constraints by adjusting the relevant variables and calculations.
Alex Librelon
Projetista Master - Youtube | Blog | Linkedin

- Marque a resposta que resolveu o seu problema como solução, isso ajuda os outros usuários em suas buscas;
- Clique em "Curtir" caso a resposta tenha ajudado;
Message 3 of 3

What do your "tiles" look like? If they are simple rectangles, you can try the attached block.

Jürgen Palme
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


AutoCAD Beta