WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rate Thread Display Modes
Old 02-20-2009, 07:50 AM
durf durf is offline
Join Date: Feb 2009
Posts: 61
2D or 3D array help?


I want to create an array in a 3D enviroment. I have a wrl file that I want to be positioned on a flat surface multiple times. Will call the wrl file "blocks".

I would imagine that I would need some for loop to construct this but I am a little unaware of how python does this. I am use to Java and C++ creations of 2D arrays so I would imagine that the 3D array would have an x, y and z for positioning.

I want to construct these blocks 40 x 30 side by side on the same plane. I do not want to overlap them either. Could I please get some examples on how to construct this. Or is there a user friendly website that I could be pointed to. I am new to python so my knowledge base is limited to how python works.

Thanks Much
Reply With Quote
Old 02-20-2009, 10:57 AM
farshizzo farshizzo is offline
WorldViz Team Member
Join Date: Mar 2003
Posts: 2,849
Here is an example script that shows how to create a 2D array of objects and position them in a grid structure. Let me know if anything is unclear.
import viz

#Width, height of grid
GRID_SIZE = [10,5]

#Spacing between grid items

#2D array of blocks
blocks = []

#Iterate over x-axis
for x in range(GRID_SIZE[0]):
	column = []
	#Iterate over y-axis
	for y in range(GRID_SIZE[1]):

		#Create block (copy file from cache)
		b = viz.add('white_ball.wrl',cache=viz.CACHE_COPY)
		#Position block in grid
		#Add block to current column

#Set color of block (3,1) to red

#Add environment
import vizshape

#Setup camera navigation
import vizcam
cam = vizcam.PivotNavigate(center=(0,0,0))
Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pick porblem with arrays shivanangel Vizard 3 08-27-2007 10:10 AM
Avatars in an array and link/unlink betancourtb82 Vizard 7 09-05-2006 04:06 PM
Multidimensional Arrays betancourtb82 Vizard 12 05-04-2006 02:13 PM
Copy objects in an array to another array Johannes Vizard 3 04-29-2005 02:37 PM
spinto cade_mccall Vizard 3 09-09-2004 04:37 PM

All times are GMT -7. The time now is 04:41 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC