PDA

View Full Version : create array macro at degree angle

handyandy
03-19-2007, 01:40 PM
i can create an array of boxes on the x & y axis with vba using columns or rows
but i can't create an array at a variable angle of degree's on the x & y plane
can anyone help

Handyandy

Tommy
03-19-2007, 02:16 PM
Butchering Fatty's butchering of the help files :)
the angleToFill is in radians

retObj = boxobj.ArrayPolar(noOfObjects, angleToFill, basePnt)

The below function accepts degrees and returns radians (Degrees to Radians).

Public Const pi = 3.14159265358979 'I set pi to this level cause I need the accuracy.

Public Function DtoR(iThisAngle as Double) as Double
DtoR = (iThisAngle / 180) * pi
End Function

HTH

handyandy
03-20-2007, 10:36 AM
if i use the polar array it gives me circles i am trying to create a flight of stairs with boxes at specific straight angles, i dont know how to array at an angle other than 0,90,180,270

Tommy
03-20-2007, 11:50 AM
Stairs, elevations or fabrication details? Steel or wood?

I would suggest that you devise a sub that inserts blocks along a line(nosing line). This way the dimensions will add up. The added slope does not always equal the overall slope especially with stairs/ higher slopes. Are going to do "ships" ladders?

EDIT: added code and note below

This will draw an array of boxes at a 45 degree angle, I copied Fatty's posted code and modified it. There is a way to do this with calculations, let me know if you need them also.

Option Explicit
Sub ArrayRectangularToBlock()
Dim mI As Integer
Dim boxobj As Acad3DSolid
Dim center(0 To 2) As Double
Dim wid As Double
center(0) = 2#: center(1) = 2#: center(2) = 0#
wid = 0.5
For mI = 1 To 20

Set boxobj = ThisDrawing.ModelSpace.AddBox(center, wid, wid, wid)
center(0) = 2# * mI: center(1) = 2# * mI: center(2) = 0#
Next

ThisDrawing.Application.ZoomAll
End Sub

handyandy
04-04-2007, 09:34 AM
hi tommy thank you for your code i'm trying to tweek it, i am having difficulty trying to get your last piece of code to work changing the 0 center position from dead center of box to bottom left corner of box, keeping an equal distance from center(0) and center(1). can you help handyandy

Tommy
04-04-2007, 01:21 PM
Hi handyandy,
You would need to adjust the center point to compensate. The below code adjusts the center to locat the first step at 0,7.5. the next one is at 12,15 .......
This set of steps is on a 7 1/2:12 bevel
Sub Stringer()
Dim mI As Integer
Dim boxobj As Acad3DSolid
Dim center(0 To 2) As Double
Dim wid As Double, hit As Double
'tread is 12 wide and 1.5 high and 36 long
' the center point is at the middle
center(0) = 6.5: center(1) = 6.75: center(2) = 0#
wid = 1.5
hit = 13
For mI = 1 To 20
Set boxobj = ThisDrawing.ModelSpace.AddBox(center, hit, wid, 36)
'next step up is offset by 1 in the x direction
'(a standard for stairs, yours may vary)
center(0) = 6.5 + 12 * mI: center(1) = 6.75 + 7.5 * mI: center(2) = 0#
Next
ThisDrawing.Application.ZoomAll
End Sub

HTH

Tommy
04-04-2007, 04:35 PM
I just couldn't leave it alone. :doh:

This updated version will ask for a point, draw 10 steps at a 7.5:12 bevel where 10 is the slope or distance on the angle for each step. The thickness, Length of tread, width, and number of treads are optional which means you don't have to enter those items unless you want to change them. The GetInfo sub just shows a usage senerio.

Sub GetInfo()
Dim mPts
mPts = ThisDrawing.Utility.GetPoint(, "Pick Starting point of tread:")
Stringer CDbl(mPts(0)), CDbl(mPts(1)), Atn(7.5 / 12), 10
End Sub

Sub Stringer(iX As Double, iY As Double, iAngle As Double, iDist As Double, _
Optional iThick = 1.5, Optional iLength = 36, Optional iWide = 12, Optional iQty = 10)
Dim mI As Integer
Dim boxobj As Acad3DSolid
Dim center(0 To 2) As Double
Dim mPts
center(0) = iX + iWide / 2: center(1) = iY - iThick / 2: center(2) = 0#
For mI = 1 To iQty
Set boxobj = ThisDrawing.ModelSpace.AddBox(center, iWide, iThick, iLength)
mPts = ThisDrawing.Utility.PolarPoint(center, iAngle, iDist)
center(0) = mPts(0): center(1) = mPts(1): center(2) = mPts(2)
Next
ThisDrawing.Application.ZoomAll
End Sub

fixo
04-07-2007, 12:29 PM
Nice one, again

I like it

I 've learned something new for me

Thanks, Tommy

Regards,

Oleg

lucas
04-07-2007, 12:33 PM
Tommy strikes again.....I yoinked it too..

fixo
04-07-2007, 01:05 PM
Lucas and Tommy and all

Beautefull Easter for all

God blessed us all I hope

~'J'~

lucas
04-07-2007, 01:25 PM
~'J'~,
Sentiment returned......too bad the rest of the world isn't as cooperative as folks at this forum..

fixo
04-07-2007, 02:23 PM
~'J'~,
Sentiment returned......too bad the rest of the world isn't as cooperative as folks at this forum..
Lucas,
I so agreed with you
In any case at all us the unique way to try to become
more tolerant concerning others...
All of us such different, but all of us programmers, it are
the special nation
My opinion, certainly...

Sincerely,

Oleg

Tommy
04-07-2007, 04:05 PM
Well when we dream we can always dream big and do everything we can to make it so!!:beerchug:

Working together makes it work.:clap:

Tommy
04-07-2007, 04:07 PM
Opps By the way I took it to drawing the stringer also, at least to the first landing, changed it to enable it to draw different type of treads.......
LOL see what happens.

handyandy
04-08-2007, 01:56 PM
hi tommy i got it to work perfectly thank you very much, i have also used the same code to produce timber stud walls at various angles, a thousand thanks from a newbie, and have a lovely easter break.

handyandy

handyandy
05-09-2007, 11:13 AM
hi tommy
i am having difficulty geting my code to rotate a box bottom left corner at an angle, move it x and y coordinates and copy same box at equal spacings along aline at the same angle.

can you help :dunno