Results 1 to 3 of 3

Thread: Block Insert Array (Loop within a Loop)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    100 Club wpeacock's Avatar
    Join Date
    2015-09
    Location
    Bunbury, West Australia
    Posts
    161
    Login to Give a bone
    0

    Question Block Insert Array (Loop within a Loop)

    I'm trying to achieve a 3D Array using a loop within a loop with the insert block method without much success.

    The code below produces just one column, which appears to be just working for the "i" loop.
    Any ideas as to how to get the "j" loop working?

    Regards

    Wayne

    Code:
    Private Sub CommandButton1_Click()
    
    Dim ObjRef As AcadBlockReference
    Dim Pnts(0 To 2) As Double
    Dim PathName As String
    PathName = "C:\Temp\Myblock.dwg"
    
    For i = 0 To 1000 Step 300
        For j = 0 To 800 Step 200
            Pnts(1) = j: Pnts(1) = 0: Pnts(2) = i:
            Set ObjRef = ThisDrawing.ModelSpace.InsertBlock(Pnts, PathName, 1, 1, 1, 0)
            ObjRef.Update
        Next j
    Next i
    
    End Sub

  2. #2
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: Block Insert Array (Loop within a Loop)

    Quote Originally Posted by wpeacock
    Code:
    Private Sub CommandButton1_Click()
    
    Dim ObjRef As AcadBlockReference
    Dim Pnts(0 To 2) As Double
    Dim PathName As String
    PathName = "C:\Temp\Myblock.dwg"
    
    For i = 0 To 1000 Step 300
        For j = 0 To 800 Step 200
            Pnts(0) = j: Pnts(1) = 0: Pnts(2) = i:
            Set ObjRef = ThisDrawing.ModelSpace.InsertBlock(Pnts, PathName, 1, 1, 1, 0)
            ObjRef.Update
        Next j
    Next i
    
    End Sub
    Sometimes it just takes a fresh pair of eyes.

  3. #3
    100 Club wpeacock's Avatar
    Join Date
    2015-09
    Location
    Bunbury, West Australia
    Posts
    161
    Login to Give a bone
    0

    Default Re: Block Insert Array (Loop within a Loop)

    Quote Originally Posted by RobertB
    Sometimes it just takes a fresh pair of eyes.

    Dohh!
    Or Maybe more beer????

    Thanks again Richard

Similar Threads

  1. Help with Code loop
    By lblakely391485 in forum AutoLISP
    Replies: 7
    Last Post: 2014-04-09, 03:34 PM
  2. End of while loop...
    By marko_ribar in forum AutoLISP
    Replies: 11
    Last Post: 2010-10-20, 07:55 PM
  3. how do i loop this?
    By mgonzales.224492 in forum AutoLISP
    Replies: 2
    Last Post: 2009-07-31, 06:41 PM
  4. Using "-insert" with attributes in a loop
    By jmcshane in forum AutoLISP
    Replies: 17
    Last Post: 2008-07-03, 09:51 PM

Posting Permissions

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