Create a cubic shell with VBA

tuli1954

New Member
Joined
Apr 26, 2018
Messages
13
Hello,

Say I have a cube withe side d.
I would like to generate a 3D cubic SHELL of the above mentioned cube with the side size of (2*n+1)*d.
Looking for a code that generates the coordinates of the centers of these cubes.
A simple 3 level loop (like the pseudo code below) will generate a full structure.
I am interested only in the outer shell.
VBA Code:
for ix=-n to n
for iy=-n to n
for iz=-n to n
x0=ix*d
y0=iy*d
z0=iz*d
create cube(x0,y0,z0,d)
next iz
next iy
next ix


Any ideas?

Thank you
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
just figure it out
a cube has 6 faces. freeze on coordinate and loop the other two. do that for x=+/-Max(x),y=+/-Max(y) and z=+/-Maz(z)
 
Upvote 0

Forum statistics

Threads
1,214,951
Messages
6,122,446
Members
449,083
Latest member
Ava19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top