VBA to generate and draw vertical and horizontal lines following some rules

adelkam

Board Regular
Joined
Feb 14, 2012
Messages
65
Hello Experts,

I have ground & ceiling geometrical data given in X, Y coordinates, which I plotted in thick brown in the chart below.
I want to add and plot vertical and horizontal lines (constituting building blocks) in between ground and ceiling; following some rules as follows:

# Vertical Lines
Shall be established every 4 feet apart. The lines' length is an even number with 2 feet increment (i.e. length is 2,4,6, or 8 etc.) as height permits at that location.
The vertical lines should NOT intersect with the ceiling. Each has to stop at least 2 feet before it hits the ceiling.

# Horizontal lines
Shall also be established every 4 feet apart. The lines' length has to be an even number with 4 feet increment (i.e. 4, 8, or 12, …to whatever it takes)
The lines should not intersect with the ceiling's side slopes, at least 5 feet needs to be before hitting sideways

The lines should end up creating a proper outline of building blocks (rectangles/squares) in an organized format.

I manually tried to create some lines (with formulas) for illustration purpose (attached) but I appreciate if I can accomplish this perfectly with VBA.

It would be also fantastic at the end to provide the final number of utilized blocks and the surface area, but this is optional, plotting is more important!

I also posted this in another forum about 36 hours ago with no luck as I write:

Thanks for your help!


1618099508695.png




04092021.xlsx
QRSTUVWXYZAAABACADAEAF
1VBA to generate & plot thisVBA to generate & plot this
2FLOORCEILINGVL. Lines (every 4 feet)Formulas used to create the vertical linesHL Lines (every 4 feet)
3XYXYXYTop Ceiling Elev at this locationCalculated Line end elevRemaining heightXY
4020.014.00.02.014.0012.002.0006
54002103.726.00.012.04006
6310.026.0
7400.016.04.02.014.4612.002.46010
84.012.040010
9
108.02.014.9312.002.93814
118.012.040014
12
1312.02.015.3912.003.394018
1412.012.037618
15
167622
1716.02.015.8512.003.8534022
1816.012.0
19
20
2120.02.016.3112.004.31
2220.012.0
23
24
2524.02.016.7812.004.78
2624.012.0
27
28
2928.02.017.2412.005.24
3028.012.0
31
32
3332.02.017.7012.005.70
3432.012.0
35
36
3736.02.018.1716.002.17
3836.016.0
39
40
4140.02.018.6316.002.63
4240.016.0
Sheet1
Cell Formulas
RangeFormula
X4X4=R4
Z4,Z41,Z37,Z33,Z29,Z25,Z21,Z17,Z13,Z10,Z7Z4=FORECAST(W4,OFFSET(KnownY,MATCH(W4,KnownX,1)-1,0,2),OFFSET(KnownX,MATCH(W4,KnownX,1)-1,0,2))
AA4AA4=IF(OR((FLOOR(Z4,4)=Z4),(Z4-FLOOR(Z4,4))<=1.5),FLOOR(Z4-3,2),FLOOR(Z4,4))
AB4,AB41,AB37,AB33,AB29,AB25,AB21,AB17,AB13,AB10,AB7AB4=Z4-AA4
AD4:AD5AD4=Q4
AE4:AE5AE4=R4+4
W5,W42,W38,W34,W30,W26,W22,W18,W14,W11,W8W5=W4
X5,X42,X38,X34,X30,X26,X22,X18,X14,X11,X8X5=AA4
W7,W41,W37,W33,W29,W25,W21,W17,W13,W10W7=W4+4
AA7,AA21,AA17,AA13,AA10AA7=IF(OR((FLOOR(Z7,4)=Z7),(Z7-FLOOR(Z7,4))<=1.5),FLOOR(Z7-3,4),FLOOR(Z7,4))
AD10,AD16,AD13AD10=CEILING(FORECAST(AE10,OFFSET(KnownX,MATCH(AE10,KnownY,1)-1,0,2),OFFSET(KnownY,MATCH(AE10,KnownY,1)-1,0,2))+5,4)
AD14,AD17AD14=FLOOR(FORECAST(AE14,OFFSET(KnownX,MATCH(AE14,KnownY,1)+1,0,2),OFFSET(KnownY,MATCH(AE14,KnownY,1)+1,0,2))-5,4)
AA25,AA41,AA37,AA33,AA29AA25=IF(OR((FLOOR(Z25,4)=Z25),(Z25-FLOOR(Z25,4))<=2),FLOOR(Z25-3,4),FLOOR(Z25,4))
Named Ranges
NameRefers ToCells
KnownX=Sheet1!$T$4:$T$7Z41, Z25, Z37, Z21, Z33, Z17, Z29, Z13, Z10, Z7, Z4, AD16:AD17, AD10, AD13:AD14
KnownY=Sheet1!$U$4:$U$7Z41, Z25, Z37, Z21, Z33, Z17, Z29, Z13, Z10, Z7, Z4, AD16:AD17, AD10, AD13:AD14
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
hi i wrote quoting program i use for constructing stainless steel pipe racking for heavy industry. it uses the drawing class written by andy pope. the drawing class is downloadable for free. (creds and thanks to AJP). here is a preview:
Capture.JPG


 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,851
Messages
6,121,931
Members
449,056
Latest member
denissimo

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