×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Are you an
Engineering professional?
Join Eng-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

#### Jobs

 Excel writes tower.scr which then draws a 3D tower in Acad by tigrek faq555-104 Posted: 26 Aug 01 'Make Excel write Acad Script Files which draw things.'Very elegant where math outweighs graphics.'Trick dicovered by me in year 2000, unless before that ...'The Tower application is due to inspiration from Bindas of this forum.'www.homescript.comDim dx, dy, dz, w, h, z, TopX, TopY, ThisX, ThisY, i, j, k, P1, P2, Width, slope1'Dim hBars(), dBars() As DoubleSub Acad3Dtower()'Open a new excel Workbook, Alt+F11 for VBA Editor, Insert new module, paste this code there'save the file - this path defines where the script file will go.'Run command from Tools/Extras ->Macros->runMacro'Coordinates of 12 horizontal bars at each level will be written into script file Tower1.scr'From AcadMenu->Tools->RunScript pick this file and watch the tower draw'use acad commands _3dcorbit etc to see the 3Dtower (only horizontal bars - for demo)'with command _id  pick a point to see the coordinates on command line.'Next weekend I may add the contour and diagonal bars of the tower too - no time now, sorry folks!'Data in metersdx = Array(1.75, 1.75, 8.23)dy = Array(1.75, 1.75, 8.23)dz = Array(0#, -6#, -60#)'horizontalBarshBars = _Array(0#, -2#, -4#, -6#, -9#, -12#, -16#, -20#, -25#, -30#, -35#, -40#, -45#, -50#, -55#, -60#)'diagonalBarsdBars = _Array(0#, -1#, -3#, -5#, -7.5, -10.5, -14#, -18#, -22.5, -27.5, -32.5, -37.5, -42.5, -47.5, -52.5, -57.5)'Top Frame Coordinates - assuming top center of tower be (0,0,0)'4 Corners and 4 midpoints, from upperRight, Clockwisew = dx(0): h = dy(0): z = dz(0)TopX = Array(w / 2, w / 2, w / 2, 0, -w / 2, -w / 2, -w / 2, 0)TopY = Array(h / 2, 0, -h / 2, -h / 2, -h / 2, 0, h / 2, h / 2)For i = 0 To 7: Debug.Print "Level "; z; "Point "; i; TopX(i); ","; TopY(i); ","; z: Next i'Open a scriptFileMyScriptFile = ActiveWorkbook.Path & "\" & "Tower1.scr"Open MyScriptFile For Output As #1Close #1Open MyScriptFile For Append As #1'HorizontalBarsFor i = 1 To UBound(hBars)z = hBars(i)slope1 = slope(z)w = w + slope1 * 2 * (z - (hBars(i - 1)))h = h + slope1 * 2 * (z - (hBars(i - 1)))'4 Corners and 4 midpoints at this levelThisX = Array(w / 2, w / 2, w / 2, 0, -w / 2, -w / 2, -w / 2, 0)ThisY = Array(h / 2, 0, -h / 2, -h / 2, -h / 2, 0, h / 2, h / 2)Debug.Print hBars(i); " m. slope at level "; i; slope(hBars(i)); "width "; wfromTo 0, 2fromTo 0, 4fromTo 0, 6fromTo 1, 3fromTo 1, 7fromTo 2, 4fromTo 2, 6fromTo 3, 1fromTo 3, 5fromTo 3, 6fromTo 4, 6fromTo 5, 7Next iClose #1End SubSub fromTo(P1, P2)Debug.Print "... Horiz Bar "; (ThisX(P1) & "," & ThisY(P1) & "," & z); " To " _    ; (ThisX(P2) & "," & ThisY(P2) & "," & z)'Append to script fileMyString = "_Line " & (ThisX(P1) & "," & ThisY(P1) & "," & z) & " " & (ThisX(P2) & "," & ThisY(P2) & "," & z) & " "Print #1, MyStringEnd SubFunction slope(elev)j = 0Do While dz(j) > elevj = j + 1LoopIf j = 0 Or (dy(j) - dy(j - 1)) = 0 Thenslope = 0Elseslope = ((dy(j) - dy(j - 1)) / 2) / (dz(j) - dz(j - 1))End IfEnd Function Back to Autodesk: AutoCAD FAQ Index Back to Autodesk: AutoCAD Forum

Close Box

# Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!