Jump to content

Recommended Posts

Posted

Hello again everyone.

 

I'm struggling withi coming up with a way to create an array based on the number entered into a textbox. The maximum array is 6 columns and 3 rows. For example: If 7 is entered into the text box, I would like the result to be 3 columns with the last column containing only 1 object on the 1 row. What is the fastest and simplist way to accomplish this?

 

As always , any help is greatly appreciated !

 

Here is my code:

 


Sub ThreeRowArray()

On Error GoTo errorhandler

   blockname = "objButton"
   insertionPnt(0) = -89.5915: insertionPnt(1) = 0: insertionPnt(2) = 0
   Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, blockname, 1#, -1#, 1#, 0)

   '-------------------------------------

   Dim aEntity As AcadEntity

    Set aEntity = blockRefObj

   'Define the rectangular array
   Dim NumberofLevels, NumberofRows, numberOfColumns As Double
   Dim DistanceBtwnLvls, DistanceBtwnRows, DistanceBtwnColumns As Double
   Dim buttonCount As Integer

   NumberofLevels = 1     'Enter a value for the amount of Levels in the array '
   NumberofRows = 3          '3 'Enter a Value for the amount of Rows
   'numberOfColumns = 7          'Enter a Value for the amount of Columns
   DistanceBtwnLvls = -50       'Enter a Value for the distance between Levels
   DistanceBtwnRows = 86       'Enter a Value for the distance between Rows
   DistanceBtwnColumns = -40  'Enter a Value for the distance between Columns

   ' Create the array of objects
   Dim retObj As Variant

   retObj = aEntity.ArrayRectangular(NumberofRows, numberOfColumns, NumberofLevels, DistanceBtwnRows, DistanceBtwnColumns, DistanceBtwnLvls)
   'Array is created

ThisDrawing.Regen acAllViewports

ThisDrawing.Application.ZoomExtents
Exit Sub
errorhandler:

End Sub

Posted

I've been looking at redim. I am really green at VBA.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...