Consulting

Page 1 of 2 1 2 LastLast
Results 1 to 20 of 24

Thread: Macro to plot in AutoCad Lite 2004

  1. #1
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location

    Macro to plot in AutoCad Lite 2004

    I'm trying to assist a colleague with an AutoCad project, but I know nothing about coding for this application, or even if it can be done with this version.

    I have a number of tables of degrees and distances from a pipeline survey and I would hope that with a simple macro, I could get AutoCad to import the data and draw these lines. Ideally, I would like to place a cross or other marker at the end of each line, but this is not critical. The data is in Excel, but can be exported to a text file etc. if this is simpler to handle.

    Regards
    MD
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  2. #2
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Hi MD,

    This cannot be done in AutoCad Lite. I could write a script to run, draw lines setup dwg etc, write dxf, however you want. The main problem is AutoCad Lite will not take Autolisp, VBA, ARX or anything else. Anyway this can be done, just not the obvious way.

    Unless you specify differently the degrees is the direction of travel and the dist is the length of travel. THe start point will be 0,0 unless specified otherwise, a cross with a circle will be inserted at each intersection(point).

  3. #3
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Question Malcolm,
    Does each row represent a line that is attached to the line represented by the row above it?

    Hope you can understand what I'm getting at. I don't think they would all start at the same point of origin?

    Also is measurement in meters, miles, etc. or does the unit matter?

    I think Tommy and I were posting here at the same time....
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  4. #4
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Hey Tommy,

    Glad you showed up.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  5. #5
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    MD, If you don't mind will you check this out and see if this is what is required? It works in Acad. You will need to open acad lite and and run the script in "C:\acad" called "PlotCords.scr"

    Let me know

  6. #6
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Steve,
    Distance is in metres. This is a survey along a pipeline and the positions are Flag points. I eventually need a line connecting these points and a position of the Bases used in the survey. The drawn lines are not required and will be deleted from the final presentation. Our AutoCad Technician is quite proficient, but it just seemed unnecessary to type in all the data, hence the request.
    Tommy,
    I can't try this at home, but will give it a go tomorrow.
    Thanks
    Malcolm
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  7. #7
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Quote Originally Posted by mdmackillop
    Hi Steve,
    Distance is in metres. This is a survey along a pipeline and the positions are Flag points. I eventually need a line connecting these points and a position of the Bases used in the survey. The drawn lines are not required and will be deleted from the final presentation. Our AutoCad Technician is quite proficient, but it just seemed unnecessary to type in all the data, hence the request.
    Tommy,
    I can't try this at home, but will give it a go tomorrow.
    Thanks
    Malcolm
    Your right about it being unnecessary to type in all the data and Tommy's solution looks top notch Malcolm. I'm anxious to hear how it works out for you.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  8. #8
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Malcolm if you can tell me exactly what is required from this data I can adjust as required. If this is in Autocad instead of Autocad Lite let me know, the script will run either way, a few steps could be eliminated if it was actually Autocad. Not to mention more automation.

  9. #9
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Tommy,
    Very close to ideal. I've adjusted the code a little as the co-ordinates
    were all measured from one location. I think your calculation moved from one point to the next.
    I've also added the facility to create the script name based on the ActiveCell value, and to create the file from the data at that location.

    Further refinements if possible:
    1. Draw a line between points if they are described as a Flag. This represents the pipeline location. (I've tried an "If" function which is partly successful). The other points are survey bases, which should be shown as isolated points.
    2. Add a label next to each point as shown. (Please note the labels indicated have been added for demo purposes, and may not be correctly placed.) Any labels landing on the line will be moved manually for the final presentation.

    This is going to save a great deal of tedious data entry. Thanks for your help.

    Regards
    Malcolm
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  10. #10
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Quote Originally Posted by mdmackillop
    I think your calculation moved from one point to the next.
    Further refinements if possible:
    1. Draw a line between points if they are described as a Flag. This represents the pipeline location. (I've tried an "If" function which is partly successful). The other points are survey bases, which should be shown as isolated points.
    2. Add a label next to each point as shown. (Please note the labels indicated have been added for demo purposes, and may not be correctly placed.) Any labels landing on the line will be moved manually for the final presentation.

    This is going to save a great deal of tedious data entry. Thanks for your help.

    Regards
    Malcolm
    This is all real doable. I will work seriously on it tonight. Is there a file that needs to be read or is the information in an excel file? btw I changed the circles and lines to a POINT set at 5% screen resolution. I can adjust the text NP and draw the lines NP. Just to make sure all points are relative to 0,0 right? (or the input in cell)

  11. #11
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Tommy,
    Yes, all the points are relative to 0,0 (this is the theodilite position).
    I don't understand NP, but I'm sure its OK
    I'll be adding this all into the workbook with the data and copying the relevant blocks of data into one worksheet, from here I can run the code to create the script files.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  12. #12
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    NP = No Problem
    Do I need to check for a range of cells? or is a 1000 lines of data going to be ok?

  13. #13
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location

    50 rows will suffice. There are a lot of small sections and I can adjust this if things change in the future.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  14. #14
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Here Ya go. If there is trouble with the text set the text size to 3.
    The text is there, the lines are drawn just for flags, and the points are there some tweaking can be done to speed up the editing process, so let me know what you need

  15. #15
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Tommy,
    This looks vey promising. Our surveyor used to draw his results in two weeks and wore out three sets of spectacles doing this. I reckon a couple of hours now!
    Regards
    Malcolm
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  16. #16
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    LOL I'd find a reason to stay at the computer too, dragging that stripped stick around the swamp attracts the wrong kinda critters around here. Lots of teeth, a really big grin, all this is attached to those eyeballs that were floating just a little ways over there. Yeah I think I would find a way to work on the computer longer.

    If I need to create and put certain items on different layers let me know. If this works like it is supposed to, changing layers/colors/linetypes will be easy.

  17. #17
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Tommy,
    This is now working well. After I found that I had forgotten to change cell references for the Polar line, it all fell into place. I'll speak to our ACAD technician on Monday re any use for layers.
    Thanks again
    Malcolm
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  18. #18
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Tommy,
    A strange problem here!
    The script appears fine, checked against calculated data, but some points are being superimposed on each other. The attached drawing is based on the data listed at AB1 on the spreadsheet. Any ideas? (The scr files are written to C:\ACAD)
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  19. #19
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Malcolm,
    I have to change the version from 2004 to 2000, I would like a corrected copy also (if this is not already done). I am just letting you know I am working on it , but it may take a while.

  20. #20
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Tommy,
    I've saved one that happened to come out correctly on my PC here, along with a copy of the overlap alongside. Also, a copy of Halbeath Farm, drawn on my home PC, but shows similar overlap errors!
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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