+ Reply to Thread
Results 1 to 2 of 2

My loop to output a script file for AutoCad needs assistance

  1. #1
    Registered User
    Join Date
    05-21-2015
    Location
    Brooklyn Center, MN
    MS-Off Ver
    2010
    Posts
    2

    My loop to output a script file for AutoCad needs assistance

    Greetings,


    I am trying to create this loop based on B.O.M. information. Columns A through D show an example of the B.O.M. info that I need to use to create a script to run some commands in AutoCAD. Unfortunately my loop is a failure.

    In the attached PNG, the loop part should output starting at E11. It does start there but doesn't work correctly as you can see.
    I have put in what the loop is supposed to look like starting at H11 but I haven't been able to make it do that.
    All the extra MSGBOX popups are for trying to see what is going on and will be removed later.

    I would appreciate any help on the subject,

    EDIT-EDIT

    Maybe I can't do attachments yet. Here is an attempt to describe what should be there.
    The first 4 columns in the excel file contain the imported B.O.M. that looks like this

    EDIT-EDIT
    Well the attachment did appear but I will leave the extra stuff in here anyway. What is shown starting at E11 should look like what I typed in at H11.

    1 partno1 description1 qty1
    2 partno2 description2 qty2
    3 partno3 description3 qty3
    4 partno4 description4 qty4
    5 partno5 description5 qty5
    6 partno6 description6 qty6
    7 partno7 description7 qty7
    8 partno8 description8 qty8
    9 partno9 description9 qty9
    10 partno10 description10 qty10

    When I run the macro it looks like this starting at e11:
    -insert
    -insert
    -insert
    -insert
    -insert
    -insert
    -insert
    -insert
    -insert
    -insert
    BDESCRIP=K:/Cadr13/customer/blocks/drawing_setup/BDESCRIP
    S
    1
    0,-12.25
    0

    It should look like this:

    0
    -insert
    BDESCRIP=K:/Cadr13/customer/blocks/drawing_setup/BDESCRIP
    S
    1
    0,-10.25
    0
    -insert
    BDESCRIP=K:/Cadr13/customer/blocks/drawing_setup/BDESCRIP
    S
    1
    0,-10.5
    0
    -insert
    BDESCRIP=K:/Cadr13/customer/blocks/drawing_setup/BDESCRIP
    S
    1
    0,-10.75
    0
    -insert
    BDESCRIP=K:/Cadr13/customer/blocks/drawing_setup/BDESCRIP
    S
    1
    0,-11.00
    0
    -insert
    BDESCRIP=K:/Cadr13/customer/blocks/drawing_setup/BDESCRIP
    S
    1
    0,-11.25
    0
    etc. etc. (repeats 10 times in this example)

    Thanks,
    Doug


    Sub DSI_BDESCRIP()
    Dim b4blankcol As Integer
    Dim itemx As String
    Dim part_nox As String
    Dim descriptionx As String
    Dim qtyx As String
    Dim index1 As Integer
    Dim IPY As Double
    Dim CP1Y As Single
    Dim CP2Y As Single
    Dim rino As Integer
    Dim rpno As Integer
    Dim rdno As Integer
    Dim rqno As Integer

    'Added the section below so that drawing numbers like 99114E001 wouldn't display
    ' as 9.91E+05, also added the part that Autofits the text

    Columns("A:G").Select
    Selection.NumberFormat = "@"

    IPY = -10
    CP2Y = -10.25

    b4blankcol = Range("A1").End(xlDown).Row
    MsgBox "Used Cells up to first blank = " & b4blankcol

    Cells(1, 5).Value = "tilemode"
    Cells(2, 5).Value = "1"
    Cells(3, 5).Value = "limits"
    Cells(4, 5).Value = "off"
    Cells(5, 5).Value = "-insert"
    Cells(6, 5).Value = "BTTLE=K:/Cadr13/customer/blocks/drawing_setup/BTTLE"
    Cells(7, 5).Value = "s"
    Cells(8, 5).Value = "1"
    Cells(9, 5).Value = "0,-9.5"
    Cells(10, 5).Value = "0"
    Cells(11, 5).Value = "Zoom"
    Cells(12, 5).Value = "extents"

    index1 = b4blankcol

    Do While b4blankcol >= 1
    Cells((index1 + 1), 5) = "-insert"
    Cells((index1 + 2), 5) = "BDESCRIP=K:/Cadr13/customer/blocks/drawing_setup/BDESCRIP"
    Cells((index1 + 3), 5) = "S"
    Cells((index1 + 4), 5) = "1"
    Cells((index1 + 5), 5) = "0," & IPY
    Cells((index1 + 6), 5) = "0"
    index1 = (index1 + 1)
    b4blankcol = (b4blankcol - 1)
    IPY = (IPY - 0.25)
    Loop

    MsgBox "index-1 at the end? " & index1
    MsgBox "b4 blankcol at the end " & b4blankcol

    End Sub
    Attached Images Attached Images
    Last edited by 480vmotor; 05-21-2015 at 03:06 PM.

  2. #2
    Registered User
    Join Date
    05-21-2015
    Location
    Brooklyn Center, MN
    MS-Off Ver
    2010
    Posts
    2

    Re: My loop to output a script file for AutoCad needs assistance

    I just found my error:

    Do While b4blankcol >= 1
    Cells((index1 + 1), 5) = "-insert"
    Cells((index1 + 2), 5) = "BDESCRIP=K:/Cadr13/customer/blocks/drawing_setup/BDESCRIP"
    Cells((index1 + 3), 5) = "S"
    Cells((index1 + 4), 5) = "1"
    Cells((index1 + 5), 5) = "0," & IPY
    Cells((index1 + 6), 5) = "0"
    index1 = (index1 + 6)
    b4blankcol = (b4blankcol - 1)
    IPY = (IPY - 0.25)
    Loop

    Had to change the 1 to a 6

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Loop through rows with VBA and select an excel output file with selectable dates
    By craigsmack in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-09-2014, 05:52 PM
  2. VBA script to compare latest two files and get output to another file
    By arkrish in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-27-2013, 01:17 PM
  3. Launch AutoCAD Script
    By Vinod Trivedi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-11-2012, 06:01 AM
  4. Excel Macro for launching script file to AutoCAD
    By Vinod Trivedi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-05-2012, 05:15 AM
  5. [SOLVED] edit an autocad r14 <embed> object to open in autocad 2000
    By Derek in forum Excel General
    Replies: 0
    Last Post: 01-20-2005, 06:06 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1