Consulting

Results 1 to 16 of 16

Thread: create array macro at degree angle

  1. #1

    create array macro at degree angle

    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

  2. #2
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Butchering Fatty's butchering of the help files
    the angleToFill is in radians
    [VBA]
    retObj = boxobj.ArrayPolar(noOfObjects, angleToFill, basePnt)
    [/VBA]
    The below function accepts degrees and returns radians (Degrees to Radians).

    [VBA]
    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
    [/VBA]
    HTH

  3. #3

    rectangular array at any angle

    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

  4. #4
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    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.

    [vba]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
    [/vba]

  5. #5
    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

  6. #6
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    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
    [VBA]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
    [/VBA]

    HTH

  7. #7
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    I just couldn't leave it alone.

    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.

    [VBA]
    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


    [/VBA]

  8. #8
    VBAX Regular fixo's Avatar
    Joined
    Jul 2006
    Location
    Sankt-Petersburg
    Posts
    99
    Location

    Smile

    Nice one, again

    I like it

    I 've learned something new for me

    Thanks, Tommy

    Regards,

    Oleg

  9. #9
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Tommy strikes again.....I yoinked it too..
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  10. #10
    VBAX Regular fixo's Avatar
    Joined
    Jul 2006
    Location
    Sankt-Petersburg
    Posts
    99
    Location
    Lucas and Tommy and all

    Beautefull Easter for all

    God blessed us all I hope

    ~'J'~

  11. #11
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    ~'J'~,
    Sentiment returned......too bad the rest of the world isn't as cooperative as folks at this forum..
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  12. #12
    VBAX Regular fixo's Avatar
    Joined
    Jul 2006
    Location
    Sankt-Petersburg
    Posts
    99
    Location
    Quote Originally Posted by lucas
    ~'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

  13. #13
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Well when we dream we can always dream big and do everything we can to make it so!!

    Working together makes it work.

  14. #14
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    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.

  15. #15
    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

  16. #16
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •