+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14
  1. #1
    Junior Member
    Using
    AutoCAD 2014
    Join Date
    Sep 2015
    Posts
    15

    Default Custom AutoLISP command

    Registered forum members do not see this ad.

    Hi all

    I really do not have much experience with AutoLISP but I would like to write a script that allows me to:

    1. Create a new DWG
    2. Draw a line from a set of existing coordinates from a .txt file
    3. Save this drawing in a specified location
    4. Close the drawing
    5. Rinse and repeat until all of the .txt files have been drawn.

    Basically this will be used for hundreds of .txt files containing coordinates to draw the cross-sections of a tunnel.

    Is this something that can be done? As after hours of research I have only managed to be able to draw one cross-section using a batch file but haven't been able to close the drawing or save it.

    Thanks in advance for any help

  2. #2
    Quantum Mechanic ReMark's Avatar
    Computer Details
    ReMark's Computer Details
    Operating System:
    Windows 7 Pro 64-bit
    Computer:
    Thinkmate
    Motherboard:
    Intel DX58SO2 LGA1366 X58
    CPU:
    Intel i7-960 Quad-core 3.20GHz 8MB cache
    RAM:
    12GB (3x4GB) PC3-106000 DDR3
    Graphics:
    nVidia Quadro K4200, 4GB GDDR5
    Primary Storage:
    150GB Velocipraptor 10,000 rpm
    Secondary Storage:
    none
    Monitor:
    Dell P24LLH - 24" wide screen LCD
    Discipline
    See details...
    ReMark's Discipline Details
    Occupation
    CAD Draftsman/Designer...chemical manufacturing.
    Discipline
    See details below.
    Details
    I work for a specialty chemical manufacturer. I do a little bit of everything from P&IDs to civil to architectural and structural.
    Using
    AutoCAD 2018
    Join Date
    Nov 2005
    Location
    Norwalk, CT USofA
    Posts
    46,380

    Default

    A script is not exactly the same as a lisp routine.

    Lee Mac, one of the many talented lisp gurus here at CADTutor, describes it thusly, "...a Script is merely a list of AutoCAD commands to be executed one after the other, as if the user were typing them at the command-line."
    "I have only come here seeking knowledge. Things they wouldn't teach me of in college." The Police

    Eat brains...gain more knowledge!

    I'm now a full member of the Society for the Promotion of Mediocrity in CAD. Standards? We don't need no stinkin' standards! Take whatever advice I offer and do the opposite.

  3. #3
    Super Moderator rkmcswain's Avatar
    Computer Details
    rkmcswain's Computer Details
    Operating System:
    Windows 7 Pro x64
    Computer:
    HP ZBook 17
    CPU:
    i7-4810MQ @ 2.80 GHZ
    RAM:
    16GB
    Graphics:
    Nvidia Quadro K4100M
    Primary Storage:
    256GB SSD
    Secondary Storage:
    1TB SATA
    Monitor:
    (2) HP 23"
    Discipline
    Civil
    rkmcswain's Discipline Details
    Discipline
    Civil
    Details
    CAD Manager
    Using
    Civil 3D 2017
    Join Date
    Sep 2005
    Location
    Houston
    Posts
    4,445

    Default

    What does the text file look like?

    Something like this?
    Code:
    ; X,Y coords
    5214.6582,6581.1247
    5218.4741,6501.2362
    ;etc.
    R.K. McSwain
    CAD Panacea | twitter

  4. #4
    Junior Member
    Using
    AutoCAD 2014
    Join Date
    Sep 2015
    Posts
    15

    Default

    Yes, each text file looks like this
    Code:
    ; X,Y,Z Coords
    +00.0000 +00.0000 006
    +01.4350 -00.0710 007
    +03.5190 -00.1610 006
    +04.9540 -00.2420 007
    -02.3650 -00.0690 000
    -02.3660 +00.1150 000
    -02.3620 +00.3250 000
    -02.3660 +00.5990 000
    -02.3660 +00.8010 000
    -02.3660 +01.0550 000
    -02.3630 +01.2530 000
    -02.3560 +01.4540 000
    -02.3450 +01.6590 000
    -02.3370 +01.8920 000
    -02.3380 +02.1860 000
    -02.3500 +02.5580 000
    -02.3600 +02.9840 000
    -02.3600 +03.2070 000
    -02.3660 +03.3890 000
    -02.3670 +03.5710 000
    -02.3640 +03.7150 000
    -02.3600 +03.8580 000
    -02.3490 +04.1770 000
    -02.3390 +04.3990 000
    -02.3360 +04.5490 000
    -02.3320 +04.6980 000
    -02.3260 +04.8380 000
    -02.3140 +04.9780 000
    -02.2970 +05.0880 000
    -02.2760 +05.1970 000
    -02.2520 +05.3060 000
    -02.2220 +05.4340 000
    -02.1870 +05.5610 000
    -02.1550 +05.6660 000
    -02.1180 +05.7700 000
    -02.0870 +05.8400 000
    -02.0520 +05.9090 000
    -02.0160 +05.9770 000
    -01.9460 +06.0930 000
    -01.8700 +06.2050 000
    -01.7950 +06.3180 000
    -01.7060 +06.4740 000
    -01.6610 +06.5520 000
    -01.6120 +06.6280 000
    -01.5540 +06.6970 000
    -01.4960 +06.7510 000
    -01.4350 +06.8010 000
    -01.3730 +06.8500 000
    -01.3100 +06.8980 000
    -01.2460 +06.9440 002
    +05.5030 +07.0060 000
    +05.5740 +06.9730 000
    +05.6430 +06.9350 000
    +05.7090 +06.8920 000
    +05.7710 +06.8440 000
    +05.8300 +06.7920 000
    +05.8820 +06.7370 000
    +05.9290 +06.6770 000
    +05.9730 +06.6160 000
    +06.0190 +06.5560 000
    +06.0610 +06.5020 000
    +06.1040 +06.4480 000
    +06.1660 +06.3810 000
    +06.2320 +06.3170 000
    +06.2660 +06.2870 000
    +06.2990 +06.2570 000
    +06.3460 +06.2020 000
    +06.3870 +06.1430 000
    +06.4230 +06.0800 000
    +06.4540 +06.0140 000
    +06.4820 +05.9480 000
    +06.5120 +05.8590 000
    +06.5350 +05.7670 000
    +06.5590 +05.6760 000
    +06.5910 +05.5820 000
    +06.6230 +05.4880 000
    +06.6520 +05.3930 000
    +06.6760 +05.2850 000
    +06.6950 +05.1760 000
    +06.7100 +05.0660 000
    +06.7240 +04.9140 000
    +06.7300 +04.7620 000
    +06.7340 +04.6090 000
    +06.7420 +04.4570 000
    +06.7490 +04.3850 000
    +06.7570 +04.3140 000
    +06.7610 +04.2420 000
    +06.7540 +04.1450 000
    +06.7410 +04.0490 000
    +06.7330 +03.9530 000
    +06.7380 +03.8450 000
    +06.7510 +03.7380 000
    +06.7640 +03.6310 000
    +06.7750 +03.5490 000
    +06.7870 +03.4670 000
    +06.7920 +03.3840 000
    +06.7840 +03.3000 000
    +06.7700 +03.2160 000
    +06.7610 +03.1320 000
    +06.7640 +03.0570 000
    +06.7710 +02.9820 000
    +06.7760 +02.9070 000
    +06.7760 +02.7970 000
    +06.7740 +02.6880 000
    +06.7660 +02.4910 000
    +06.7650 +02.4060 000
    +06.7700 +02.2840 000
    +06.7760 +02.1620 000
    +06.7750 +02.0690 000
    +06.7740 +01.9750 000
    +06.7820 +01.8580 000
    +06.7940 +01.7400 000
    +06.8010 +01.6230 000
    +06.7990 +01.5080 000
    +06.7940 +01.3940 000
    +06.7900 +01.2860 000
    +06.7850 +01.1500 000
    +06.7770 +01.0140 000
    +06.7650 +00.9090 000
    +06.7540 +00.8030 000
    +06.7530 +00.7300 000
    +06.7530 +00.6560 000
    +06.7530 +00.5550 000
    +06.7560 +00.4550 000
    +06.7630 +00.3820 000
    +06.7710 +00.3100 000
    +06.7770 +00.1790 000
    +06.7760 +00.0480 000
    +06.7790 -00.3290 000
    +06.7450 -00.5510 000
    +06.7380 -00.7000 002

  5. #5
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,751

    Default

    The script could look something like this

    Code:
    open mytemplatefilefortunnels 
    (setq filename "c:\mytunnel\tunnel1.txt)
    (load "tunnelmaker")
    open mytemplatefile for tunnels
    (setq filename "c:\mytunnel\tunnel2.txt")
    (load "tunnelmaker")
    open mytemplatefile for tunnels
    (setq filename "c:\mytunnel\tunnel2.txt")
    (load "tunnelmaker")
    Going in the direction that Rkmcswain may be heading open a blank template, the lisp program opens the data file creates tunnel and at end saves and closes the file. This may be easier rather than converting the txt file to a script but that could be done also.
    A man who never made mistakes never made anything

  6. #6
    Junior Member
    Using
    AutoCAD 2014
    Join Date
    Sep 2015
    Posts
    15

    Default

    That's almost perfect thanks BIGAL, but how do I get the LISP to automatically load the next txt file?
    Basically there are lots of txt files that all contain coordinates. Its not just the one txt file named "tunnelmaker" that I need to draw.
    So for example there are 3 txt files named "tunnelmaker 1" "tunnelmaker 2" "tunnelmaker 3" containing coordinates0.
    Is there a way of writing the LISP to firstly open the txt files in order, and each time, save the newly created tunnel cross-section without having to write the save name in the script beforehand?

    I'd like this because after the LISP is written, I can hand it over to other people for them to plot their tunnel cross-sections without the need for them to edit the AutoLISP file.

    Thanks.

  7. #7
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,751

    Default

    iNside the tunnel maker.lsp is variable fname this is the name of the txt file. Tunnel1.txt to be read.

    Yes you do need a read text file lisp and draw lines can you post a dwg and a txt file so if like me I can find some time will do for you.

    The first step would be to create the script from a onscreen method to pick files.

    Yes left a step unanswered inside the tunnel lisp is a save dwg and close.

    A script runs next line once a lisp is completed so open template again and repeat.
    Last edited by BIGAL; 5th Oct 2015 at 03:03 am. Reason: Autoceoorect on a Ipad is a pain
    A man who never made mistakes never made anything

  8. #8
    Junior Member
    Using
    AutoCAD 2014
    Join Date
    Sep 2015
    Posts
    15

    Default

    Yeah sure any help you can give would be greatly appreciated
    175475BK.txt
    template.dwg

  9. #9
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,751

    Default

    I got this from your data it took a few seconds to do just used notepad to remove + and changed space to "," changed 006 & 007 etc to 000.

    Removed all notes from start of file added LINE as 1st line Ctrl A Ctrl C then pasted to Autocad command line. Just not sure if this is correct.

    ScreenShot004.jpg
    A man who never made mistakes never made anything

  10. #10
    Junior Member
    Using
    AutoCAD 2014
    Join Date
    Sep 2015
    Posts
    15

    Default

    Registered forum members do not see this ad.

    That's exactly how it is supposed to look. I just need a way of automating it for lots of drawings.

    Thanks,

Similar Threads

  1. AutoLisp Error Handling - Command in Custom Error Causes Error
    By RonnieMoore in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 8th Nov 2013, 05:28 pm
  2. Tutorial: Create a custom command for AutoCAD using AutoLISP
    By AutoCAD Tips Blog in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 16th Jul 2012, 08:50 pm
  3. Custom Command in Command line
    By goonkt in forum The CUI, Hatches, Linetypes, Scripts & Macros
    Replies: 4
    Last Post: 6th Jul 2012, 06:37 pm
  4. Replies: 6
    Last Post: 15th Nov 2011, 02:27 pm
  5. Autolisp for custom blocks.
    By cadsultant in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 8th Apr 2005, 08:24 am

Tags for this Thread

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