handyandy
03-04-2007, 11:10 AM
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.
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
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
~'J'~
handyandy
03-11-2007, 11:59 AM
thanks for your help fatty i have adapted your code and it works a treat once again thanks very much
Glad if this helps
Cheers :)
~'J'~
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.