+ Reply to Thread
Page 1 of 4 1 2 3 ... LastLast
Results 1 to 10 of 31
  1. #1
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Jun 2012
    Posts
    100

    Default Need a lisp to prepare a table

    Registered forum members do not see this ad.

    I have a list giving chainages and respective coordinates of a road alignment. I need to prepare a table with four columns for the Chainage, X value, Y Value and Remark. I used to convert these with 'rtos' and put them on columns but has seen some other elegant wayn this forum. But that table does not give the colunms I need. Can someone give a clue?. The list is given below:

    Code:
    (setq l '((0.0 (-108.124 81.3947 0.0)) (20.0 (-88.6807 86.0816 0.0)) (40.0 
    (-69.2377 
    90.7684 0.0)) (60.0 (-49.7946 95.4553 0.0)) (80.0 (-30.3515 
    100.142 0.0)) 
    (100.0 (-10.9085 104.829 0.0)) (120.0 (8.53462 109.516 0.0)) 
    (140.0 (27.9777 
    114.203 0.0)) (160.0 (47.4208 118.89 0.0)) (180.0 (66.8638 
    123.577 0.0)) (200.0 
    (86.3069 128.264 0.0)) (220.0 (105.75 132.951 0.0)) 
    (240.0 (125.193 137.637 
    0.0)) (260.0 (144.636 142.324 0.0)) (280.0 (164.079 
    147.011 0.0)) (300.0 
    (183.522 151.698 0.0)) (320.0 (202.965 156.385 0.0)) 
    (340.0 (222.408 161.072 
    0.0)) (360.0 (241.851 165.759 0.0)) (380.0 (261.295 
    170.446 0.0)) (400.0 
    (280.738 175.133 0.0)) (420.0 (300.181 179.82 0.0)) 
    (440.0 (319.624 184.506 
    0.0)) (460.0 (339.067 189.193 0.0)) (480.0 (358.51 
    193.88 0.0)) (500.0 (377.953 
    198.567 0.0)) (520.0 (397.396 203.254 0.0)) 
    (540.0 (416.839 207.941 0.0)) 
    (560.0 (436.282 212.628 0.0)) (580.0 (455.725 
    217.315 0.0)) (600.0 (475.168 
    222.002 0.0)) (620.0 (494.611 226.688 0.0)) 
    (640.0 (514.054 231.375 0.0)) 
    (660.0 (533.498 236.062 0.0)) (680.0 (552.941 
    240.749 0.0)) (700.0 (572.384 
    245.436 0.0)) (720.0 (591.827 250.123 0.0)) 
    (740.0 (611.27 254.81 0.0)) (760.0 
    (630.713 259.497 0.0)) (780.0 (650.156 
    264.184 0.0)) (800.0 (669.599 268.871 
    0.0)) (820.0 (689.042 273.557 0.0)) 
    (840.0 (708.485 278.244 0.0)) (860.0 
    (727.928 282.931 0.0)) (880.0 (747.371 
    287.618 0.0)) (900.0 (766.814 292.305 
    0.0)) (920.0 (786.257 296.992 0.0)) 
    (940.0 (805.701 301.679 0.0)) (960.0 
    (825.144 306.366 0.0)) (980.0 (844.587 
    311.053 0.0)) (990.275 (854.575 313.46 
    0.0)) (1000.0 (864.029 315.743 0.0)) 
    (1020.0 (883.45 320.518 0.0)) (1040.0 
    (902.809 325.543 0.0)) (1060.0 
    (922.054 330.982 0.0)) (1080.0 (941.127 336.999 
    0.0)) (1086.27 (947.062 
    339.035 0.0)) (1100.0 (959.986 343.655)) (1120.0 (978.7 
    350.715)) (1140.0 
    (997.263 358.162)) (1160.0 (1015.67 365.993)) (1180.0 
    (1033.91 374.203)) 
    (1200.0 (1051.97 382.79)) (1220.0 (1069.85 391.75)) (1240.0 
    (1087.54 
    401.079)) (1260.0 (1105.04 410.772)) (1280.0 (1122.33 420.827)) 
    (1300.0 
    (1139.41 431.238)) (1320.0 (1156.27 442.001)) (1340.0 (1172.9 453.111)) 
    
    (1360.0 (1189.29 464.563)) (1380.0 (1205.45 476.354)) (1400.0 (1221.36 
    
    488.477)) (1420.0 (1237.01 500.927)) (1440.0 (1252.4 513.699)) (1460.0 
    (1267.53 
    526.788)) (1480.0 (1282.38 540.188)) (1500.0 (1296.95 553.893)) 
    (1502.84 
    (1298.99 555.867)) (1520.0 (1311.02 567.884 0.0)) (1540.0 (1324.72 
    582.453 
    0.0)) (1560.0 (1338.05 597.367 0.0)) (1580.0 (1351.12 612.502 0.0)) 
    (1598.84 
    (1363.33 626.861 0.0))))
    Thanking in advance.
    Aloy

  2. #2
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    2,991

    Default

    Please check the advices from this tutorial.
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  3. #3
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Jun 2012
    Posts
    100

    Default

    Thaks Mircea,
    This appears to be one way. I need to study a bit on Vlisp and then modify the program appropriately.
    Regards,
    Aloy

  4. #4
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,618

    Default

    Aloy .

    This sub-function would help you to reform the list to appended list to become much easier to set the value after converting it to a string to a table .

    Good luck .

    Code:
    (defun AppendList (l / i n lst)
      (setq i -1)
      (repeat (length l)
        (setq lst (cons (list (car (setq n (nth (setq i (1+ i)) l)))
                              (car (cadr n))
                              (cadr (cadr n))
                              (caddr (cadr n))
                        )
                        lst
                  )
        )
      )
      lst
    )
    - When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

  5. #5
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,708

    Default

    Or simply:

    Code:
    (mapcar '(lambda ( x ) (cons (car x) (cadr x))) l)
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  6. #6
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,618

    Default

    Quote Originally Posted by Lee Mac View Post
    Or simply:

    Code:
    (mapcar '(lambda ( x ) (cons (car x) (cadr x))) l)
    Certainly .
    - When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

  7. #7
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Jun 2012
    Posts
    100

    Default

    LeeMac,
    Yes, the lambda fuction did the trick. I was able to make use of the existing routine for polyline coordinates without reinventing the wheel and without drawing the polyline. I could use my list, l. given above. However as you will observe there is a Z coordinate aslo at some places and the function coverted that also where ever Z exist and put it in the fourth colunm. That also shows that the polyline table can be extended to many more columns.
    Is there a way of shutting off the Z value when generating the list l ?.
    Thank you for the help.
    Aloy

  8. #8
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Jun 2012
    Posts
    100

    Default

    Tharwat,
    The function gave an error message. May be it needs a bit of modification to prepare the sub liist.
    Regards,
    Aloy

  9. #9
    Senior Member
    Using
    AutoCAD 2010
    Join Date
    Jun 2012
    Posts
    100

    Default

    Mircea,
    I could not make use of the tutorial as the polylines are closed ones and the solution looks a bit more comlex than in the case of open polyline given above.
    Regards,
    Aloy

  10. #10
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,618

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by aloy View Post
    May be it needs a bit of modification to prepare the sub liist.
    No. it does not need anything , except to have them in order just add (reverse lst) at the last lst in the sub-function .

    What was the error message that you have received ?
    - When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

Similar Threads

  1. Help to prepare lisp programme
    By sayhi_sanjay1 in forum AutoLISP, Visual LISP & DCL
    Replies: 11
    Last Post: 18th Jul 2012, 12:55 pm
  2. routine to prepare drawings for issue
    By designerstuart in forum The CUI, Hatches, Linetypes, Scripts & Macros
    Replies: 3
    Last Post: 13th Jan 2012, 12:39 pm
  3. role of osnap commands to prepare a drawing?
    By hhhh in forum AutoCAD Beginners' Area
    Replies: 8
    Last Post: 7th Nov 2008, 03:01 am
  4. Create a TABLE using lisp
    By CAD Panacea in forum AutoCAD RSS Feeds
    Replies: 1
    Last Post: 22nd Aug 2007, 06:43 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