Consulting

Results 1 to 4 of 4

Thread: Put an array into a block

  1. #1

    Put an array into a block

    i have created a macro for Autocad 2005 using VBA. It uses a rectangular array of 3d boxes and want the array to be put into a block i have created.
    would this be possible and if so how can this be done.

  2. #2
    VBAX Regular fixo's Avatar
    Joined
    Jul 2006
    Location
    Sankt-Petersburg
    Posts
    99
    Location
    Quote Originally Posted by handyandy
    i have created a macro for Autocad 2005 using VBA. It uses a rectangular array of 3d boxes and want the array to be put into a block i have created.
    would this be possible and if so how can this be done.
    Here is slightly edited example from Help
    Give this shot
    Hth

    [vba]
    Option Explicit
    Sub ArrayRectangularToBlock()
    ' This example creates a box and then performs
    ' a rectangular array on that box.

    ' Create the box
    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
    Set boxobj = ThisDrawing.ModelSpace.AddBox(center, wid, wid, wid)
    ThisDrawing.Application.ZoomAll
    MsgBox "Perform the rectangular array of the box.", , "ArrayRectangular Example"

    ' Define the rectangular array
    Dim numberOfRows As Long
    Dim numberOfColumns As Long
    Dim numberOfLevels As Long
    Dim distanceBwtnRows As Double
    Dim distanceBwtnColumns As Double
    Dim distanceBwtnLevels As Double
    numberOfRows = 5
    numberOfColumns = 5
    numberOfLevels = 2
    distanceBwtnRows = 1
    distanceBwtnColumns = 1
    distanceBwtnLevels = 1

    ' Create the array of objects
    Dim retObj As Variant
    retObj = boxobj.ArrayRectangular(numberOfRows, numberOfColumns, numberOfLevels, distanceBwtnRows, distanceBwtnColumns, distanceBwtnLevels)

    ' add block definition
    Dim blkdef As AcadBlock
    Set blkdef = ThisDrawing.Blocks.Add(center, "YourBlockName")

    ' populate block with array
    ThisDrawing.CopyObjects retObj, blkdef
    ZoomAll
    MsgBox "Block from rectangular array created.", , "Create Block Example"

    End Sub
    [/vba]

    ~'J'~

  3. #3
    thanks for your help fatty i have adapted your code and it works a treat once again thanks very much

  4. #4
    VBAX Regular fixo's Avatar
    Joined
    Jul 2006
    Location
    Sankt-Petersburg
    Posts
    99
    Location
    Glad if this helps
    Cheers

    ~'J'~

Posting Permissions

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