Poll: 2

+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 17
  1. #1
    Senior Member
    Using
    AutoCAD 2006
    Join Date
    Oct 2007
    Posts
    113

    AutoCAD road x-section lisp problem

    Registered forum members do not see this ad.

    Sir,

    Happy New Year sir,

    I have a two Lisp program for draw road cross-section and longitudinal section. But this lisp is worked for only limited offsets (Table –I). But I need more offsets as per different site location of offsets, Existing Road Top and Existing FRL level (Table –II). I have no idea to modify this Lisp to number of offsets, so please modify and send email.


    ************************************************** ****
    xs.lisp
    (defun cs ()
    (mapcar 'setvar '("cmdecho" "osmode" "filedia" "cmddia") '(0 0 0 0))
    (COMMAND "LUPREC" 3)
    (setq zz 0)
    (setq ff (vl-directory-files "D:/road_csarea_rs" "*.csv"))
    (while (< zz (length ff))
    (setq fx (nth zz ff))
    (setq scrpath (strcat "D:/road_csarea_rs/" fx) )
    (if (null scrpath) (progn (princ "\n NO SCRIPT-File Selected.") (exit) ))
    (initget 1)
    (setq chain 0)
    (setq fpath (vl-filename-directory scrpath) )
    (command "-style" "standard" "ARIAL" 0 1 "" "" "" "")
    (setq opfile (open scrpath "r") )
    (setq rdline (read-line opfile) )
    (while rdline
    (setq xval (atof (txtlist rdline 1))
    yval (atof (txtlist rdline 2))
    zval (atof (txtlist rdline 3))
    )
    (setq n 1
    chlist (list xval)
    gllist (list yval)
    fllist (list zval)
    agllist (list (list xval yval))
    afllist (list (list xval zval))
    )
    (while (and (<= n 10) (setq rdline (read-line opfile) ) )
    (setq ch (list (atof (txtlist rdline 1))) )
    (setq gl (list (atof (txtlist rdline 2))) )
    (setq fl (list (atof (txtlist rdline 3))) )
    (setq q1 (atof (txtlist rdline 1)))
    (setq q2 (atof (txtlist rdline 2)))
    (setq q3 (atof (txtlist rdline 3)))
    (setq g1 (list q1 q2))
    (setq t1 (list q1 q3))
    (setq chlist (append chlist ch ))
    (setq gllist (append gllist gl ) )
    (setq fllist (append fllist fl) )
    (setq agllist (append agllist (list g1) ) )
    (setq afllist (append afllist (list t1) ) )
    (setq afllistr (reverse afllist))
    (setq flistf (append agllist afllistr))
    (drawreg flistf)
    (setq area-pcc (cal-area) )
    (setq n (1+ n) )
    );end while-2
    (setq datum1 (fix(car(vl-sort gllist '<))))
    (setq datum (- (min datum1) 3))
    (setq maxd1 (fix(car(vl-sort fllist '>))))
    (setq maxd (max maxd1))
    (setq inspt (list chain datum) )
    (command "insert" (strcat "*" fpath "/temg_rs.dwg") inspt "" "")
    (command "zoom" "e")
    );end while
    (setq dt (ssget "x" '((8 . "datum"))))
    (setq datext (strcat "DATUM" " " ":" " " (RTOS datum) " " "M"))
    (COMMAND "CHANGE" DT "" "" "" "" "" "" datext)
    (setq ss datum)
    (setq a 1)
    (setq ss1 (+ datum 20))
    (while (< ss maxd)
    (setq txtp (list chain ss1))
    (setq txt (rtos (+ datum a)))
    (command "text" txtp "2" "0" txt)
    (command "change" (entlast) "" "P" "la" "datumch" "")
    (setq ss1 (+ ss1 20))
    (setq a (+ a 1))
    (setq ss (+ ss 1))
    );end while
    (setq dt (ssget "x" '((8 . "datumch"))))
    (setq txtp2 (list (- chain 10) (cadr txtp)))
    (command "move" dt "" txtp txtp2 "")
    (placetxt)
    (DRAWLINE)
    (setq fle1 (- (strlen fx) 4))
    (setq fin1 (substr fx 1 fle1))
    (setq cs1 (ssget "x" '((0 . "text")(8 . "cs"))))
    (setq cst (strcat "CROSS SECTION" "@" fin1 "Km"))
    (COMMAND "CHANGE" cs1 "" "" "" "" "" "" cst)
    (CLOSE opfile)
    (setq fle (- (strlen scrpath) 4))
    (setq fin (substr scrpath 1 fle))
    (setq fnm (strcat fin ".dwg"))
    (command "-wblock" fnm "" "0,0" "all" "" "n")
    (COMMAND "LUPREC" 3)
    (setq ptlist nil)
    (setq ptlistf nil)
    (setq ptlist1 nil)
    (setq ptlist2 nil)
    (setq ptlist3 nil)
    (setq ptlist4 nil)
    (setq zz (+ zz 1))
    )
    (mapcar 'setvar '("cmdecho" "osmode" "filedia" "cmddia") '(1 1 1 1))
    )

    (defun placetxt()
    (setq m 0)
    (repeat (length chlist)
    (setq m1 (* (nth m chlist) 20) )
    (setq cc (nth m chlist) )
    (setq gl1 (nth m gllist) )
    (setq fl1 (nth m fllist) )
    (setq instxt0 (list m1 (- datum 47) ))
    (setq instxt1 (list m1 (- datum 30) ))
    (setq instxt2 (list m1 (- datum 13) ))
    (setq xval (rtos cc))
    (setq gl1 (rtos gl1))
    (setq fl1 (rtos fl1))
    (command "text" "j" "MC" instxt0 2 90 xval)
    (command "change" (entlast) "" "p" "c" "9" "")
    (command "text" "j" "MC" instxt1 2 90 gl1)
    (command "change" (entlast) "" "p" "c" "6" "")
    (command "text" "j" "MC" instxt2 2 90 fl1)
    (command "change" (entlast) "" "p" "c" "3" "")
    (setq m (+ m 1) )
    );end repeat
    (SETQ dTTEXT (SSGET "X" '((8 . "datumch"))))
    (SETQ de 0)
    (WHILE (< de (SSLENGTH dTTEXT))
    (SETQ ENAMd (SSNAME dTTEXT de))
    (SETQ TXT2 (fix(ATOF(CDR(ASSOC 1 (ENTGET ENAMd))))))
    (command "luprec" 0)
    (SETQ TT2 (strcat (RTOS TXT2) " " "---"))
    (COMMAND "CHANGE" ENAMd "" "" "" "" "" "" TT2)
    (SETQ de (+ de 1))
    )
    )
    (DEFUN DRAWLINE()
    (setq c 0)
    (setq x1s 0)
    (while (< c (LENGTH gllist))
    (setq ent (nth c gllist))
    (setq entf (nth c fllist))
    (setq y1b datum)
    (setq y2b (+ (* (- ent datum) 20) y1b))
    (setq y2bf (+ (* (- entf datum) 20) y1b))
    (setq top (list x1s y2b))
    (setq topf (list x1s y2bf))
    (setq bot (list x1s y1b))
    (command "line" bot top "")
    (setq c (+ c 1))
    (if (< c (length chlist))
    (progn
    (setq x1s (* (nth c chlist) 20) )
    )
    (progn
    (setq x1s (* (nth (- c 1) chlist) 20) )
    (setq area (strcat "AREA = " (rtos area-pcc 2 3) "Sq.M"))
    (command "text" "j" "tl" top 5 0 area)
    (command "change" (entlast) "" "p" "c" "9" "")
    )
    )
    (setq ptlist (append ptlist (list top)) )
    (setq ptlistf (append ptlistf (list topf)) )
    )
    (command "pline")
    (foreach no ptlist (command no))
    (command "")
    (command "change" (entlast) "" "p" "c" "1" "")
    (command "pline")
    (foreach no ptlistf (command no))
    (command "")
    (command "change" (entlast) "" "p" "c" "3" "")
    (SETQ GTEXT (NTH 0 PTLIST))
    )
    (defun txtlist (txt n)
    (setq count 1 space 1 result "")
    (while (and (<= count (strlen txt)) (<= space n))
    (setq charchk (substr txt count 1) )
    (cond ((= charchk ",") (setq space (+ space 1) ) )
    ((= space n) (setq result (strcat result charchk) ) )
    );end cond
    (setq count (+ count 1) )
    );end while
    result
    );end defun
    (defun drawreg ( ptlist )
    (command "layer" "m" "AREA" "")
    (command "pline")
    (foreach pt ptlist (command pt) )
    (command "c")
    (command "region" (entlast) "")
    (setq enam-rg (entlast) )
    );end defun
    (defun cal-area ()
    (setq regset (ssget "x" '((0 . "REGION") (8 . "AREA"))) )
    (if regset (progn
    (command "area" "obj" (entlast))
    (setq getarea (getvar "area") )
    (command "erase" regset "")
    );end progn
    (setq getarea 0.000)
    );end if
    getarea
    );end defun

    ******************************************
    Thanking you

    Yours truly,
    Madhava Rao

  2. #2
    Senior Member bsamc2000's Avatar
    Computer Details
    bsamc2000's Computer Details
    Operating System:
    Windows 7
    Computer:
    HP Z400
    CPU:
    Intel Xeon 2.66GHz
    Graphics:
    NVIDIA GeForce 9500 GT
    Monitor:
    E228WFP (2x)
    Using
    AutoCAD 2011
    Join Date
    Mar 2007
    Location
    Columbus, Ohio
    Posts
    120

    AutoCAD

    It appears that there is a set csv file located in directory labeled "D:/road_csarea_rs/" that the lisp file reads from. You should be able to modify them directly.

    Brian

  3. #3
    Forum Newbie
    Computer Details
    murtazachd's Computer Details
    Operating System:
    Windows 7
    Using
    AutoCAD 2007
    Join Date
    Jun 2009
    Location
    Holly Makkah
    Posts
    6

    Default Xs.lisp

    hi
    please tell me about temg_rs.dwg

    ************************************************** ****
    xs.lisp
    (defun cs ()
    (mapcar 'setvar '("cmdecho" "osmode" "filedia" "cmddia") '(0 0 0 0))
    (COMMAND "LUPREC" 3)
    (setq zz 0)
    (setq ff (vl-directory-files "D:/road_csarea_rs" "*.csv"))
    (while (< zz (length ff))
    (setq fx (nth zz ff))
    (setq scrpath (strcat "D:/road_csarea_rs/" fx) )
    (if (null scrpath) (progn (princ "\n NO SCRIPT-File Selected.") (exit) ))
    (initget 1)
    (setq chain 0)
    (setq fpath (vl-filename-directory scrpath) )
    (command "-style" "standard" "ARIAL" 0 1 "" "" "" "")
    (setq opfile (open scrpath "r") )
    (setq rdline (read-line opfile) )
    (while rdline
    (setq xval (atof (txtlist rdline 1))
    yval (atof (txtlist rdline 2))
    zval (atof (txtlist rdline 3))
    )
    (setq n 1
    chlist (list xval)
    gllist (list yval)
    fllist (list zval)
    agllist (list (list xval yval))
    afllist (list (list xval zval))
    )
    (while (and (<= n 10) (setq rdline (read-line opfile) ) )
    (setq ch (list (atof (txtlist rdline 1))) )
    (setq gl (list (atof (txtlist rdline 2))) )
    (setq fl (list (atof (txtlist rdline 3))) )
    (setq q1 (atof (txtlist rdline 1)))
    (setq q2 (atof (txtlist rdline 2)))
    (setq q3 (atof (txtlist rdline 3)))
    (setq g1 (list q1 q2))
    (setq t1 (list q1 q3))
    (setq chlist (append chlist ch ))
    (setq gllist (append gllist gl ) )
    (setq fllist (append fllist fl) )
    (setq agllist (append agllist (list g1) ) )
    (setq afllist (append afllist (list t1) ) )
    (setq afllistr (reverse afllist))
    (setq flistf (append agllist afllistr))
    (drawreg flistf)
    (setq area-pcc (cal-area) )
    (setq n (1+ n) )
    );end while-2
    (setq datum1 (fix(car(vl-sort gllist '<))))
    (setq datum (- (min datum1) 3))
    (setq maxd1 (fix(car(vl-sort fllist '>))))
    (setq maxd (max maxd1))
    (setq inspt (list chain datum) )
    (command "insert" (strcat "*" fpath "/temg_rs.dwg") inspt "" "")
    (command "zoom" "e")
    );end while
    (setq dt (ssget "x" '((8 . "datum"))))
    (setq datext (strcat "DATUM" " " ":" " " (RTOS datum) " " "M"))
    (COMMAND "CHANGE" DT "" "" "" "" "" "" datext)
    (setq ss datum)
    (setq a 1)
    (setq ss1 (+ datum 20))
    (while (< ss maxd)
    (setq txtp (list chain ss1))
    (setq txt (rtos (+ datum a)))
    (command "text" txtp "2" "0" txt)
    (command "change" (entlast) "" "P" "la" "datumch" "")
    (setq ss1 (+ ss1 20))
    (setq a (+ a 1))
    (setq ss (+ ss 1))
    );end while
    (setq dt (ssget "x" '((8 . "datumch"))))
    (setq txtp2 (list (- chain 10) (cadr txtp)))
    (command "move" dt "" txtp txtp2 "")
    (placetxt)
    (DRAWLINE)
    (setq fle1 (- (strlen fx) 4))
    (setq fin1 (substr fx 1 fle1))
    (setq cs1 (ssget "x" '((0 . "text")(8 . "cs"))))
    (setq cst (strcat "CROSS SECTION" "@" fin1 "Km"))
    (COMMAND "CHANGE" cs1 "" "" "" "" "" "" cst)
    (CLOSE opfile)
    (setq fle (- (strlen scrpath) 4))
    (setq fin (substr scrpath 1 fle))
    (setq fnm (strcat fin ".dwg"))
    (command "-wblock" fnm "" "0,0" "all" "" "n")
    (COMMAND "LUPREC" 3)
    (setq ptlist nil)
    (setq ptlistf nil)
    (setq ptlist1 nil)
    (setq ptlist2 nil)
    (setq ptlist3 nil)
    (setq ptlist4 nil)
    (setq zz (+ zz 1))
    )
    (mapcar 'setvar '("cmdecho" "osmode" "filedia" "cmddia") '(1 1 1 1))
    )

    (defun placetxt()
    (setq m 0)
    (repeat (length chlist)
    (setq m1 (* (nth m chlist) 20) )
    (setq cc (nth m chlist) )
    (setq gl1 (nth m gllist) )
    (setq fl1 (nth m fllist) )
    (setq instxt0 (list m1 (- datum 47) ))
    (setq instxt1 (list m1 (- datum 30) ))
    (setq instxt2 (list m1 (- datum 13) ))
    (setq xval (rtos cc))
    (setq gl1 (rtos gl1))
    (setq fl1 (rtos fl1))
    (command "text" "j" "MC" instxt0 2 90 xval)
    (command "change" (entlast) "" "p" "c" "9" "")
    (command "text" "j" "MC" instxt1 2 90 gl1)
    (command "change" (entlast) "" "p" "c" "6" "")
    (command "text" "j" "MC" instxt2 2 90 fl1)
    (command "change" (entlast) "" "p" "c" "3" "")
    (setq m (+ m 1) )
    );end repeat
    (SETQ dTTEXT (SSGET "X" '((8 . "datumch"))))
    (SETQ de 0)
    (WHILE (< de (SSLENGTH dTTEXT))
    (SETQ ENAMd (SSNAME dTTEXT de))
    (SETQ TXT2 (fix(ATOF(CDR(ASSOC 1 (ENTGET ENAMd))))))
    (command "luprec" 0)
    (SETQ TT2 (strcat (RTOS TXT2) " " "---"))
    (COMMAND "CHANGE" ENAMd "" "" "" "" "" "" TT2)
    (SETQ de (+ de 1))
    )
    )
    (DEFUN DRAWLINE()
    (setq c 0)
    (setq x1s 0)
    (while (< c (LENGTH gllist))
    (setq ent (nth c gllist))
    (setq entf (nth c fllist))
    (setq y1b datum)
    (setq y2b (+ (* (- ent datum) 20) y1b))
    (setq y2bf (+ (* (- entf datum) 20) y1b))
    (setq top (list x1s y2b))
    (setq topf (list x1s y2bf))
    (setq bot (list x1s y1b))
    (command "line" bot top "")
    (setq c (+ c 1))
    (if (< c (length chlist))
    (progn
    (setq x1s (* (nth c chlist) 20) )
    )
    (progn
    (setq x1s (* (nth (- c 1) chlist) 20) )
    (setq area (strcat "AREA = " (rtos area-pcc 2 3) "Sq.M"))
    (command "text" "j" "tl" top 5 0 area)
    (command "change" (entlast) "" "p" "c" "9" "")
    )
    )
    (setq ptlist (append ptlist (list top)) )
    (setq ptlistf (append ptlistf (list topf)) )
    )
    (command "pline")
    (foreach no ptlist (command no))
    (command "")
    (command "change" (entlast) "" "p" "c" "1" "")
    (command "pline")
    (foreach no ptlistf (command no))
    (command "")
    (command "change" (entlast) "" "p" "c" "3" "")
    (SETQ GTEXT (NTH 0 PTLIST))
    )
    (defun txtlist (txt n)
    (setq count 1 space 1 result "")
    (while (and (<= count (strlen txt)) (<= space n))
    (setq charchk (substr txt count 1) )
    (cond ((= charchk ",") (setq space (+ space 1) ) )
    ((= space n) (setq result (strcat result charchk) ) )
    );end cond
    (setq count (+ count 1) )
    );end while
    result
    );end defun
    (defun drawreg ( ptlist )
    (command "layer" "m" "AREA" "")
    (command "pline")
    (foreach pt ptlist (command pt) )
    (command "c")
    (command "region" (entlast) "")
    (setq enam-rg (entlast) )
    );end defun
    (defun cal-area ()
    (setq regset (ssget "x" '((0 . "REGION") (8 . "AREA"))) )
    (if regset (progn
    (command "area" "obj" (entlast))
    (setq getarea (getvar "area") )
    (command "erase" regset "")
    );end progn
    (setq getarea 0.000)
    );end if
    getarea
    );end defun

    ******************************************
    Thanking you

    Yours truly,
    Madhava Rao[/quote]

  4. #4
    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,718

    Default

    i'm not sure I understand your question and how it is related to this thread? Maybe I'm missing something?
    Lee Mac Programming

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

    Just another Swamper

  5. #5
    Senior Member bsamc2000's Avatar
    Computer Details
    bsamc2000's Computer Details
    Operating System:
    Windows 7
    Computer:
    HP Z400
    CPU:
    Intel Xeon 2.66GHz
    Graphics:
    NVIDIA GeForce 9500 GT
    Monitor:
    E228WFP (2x)
    Using
    AutoCAD 2011
    Join Date
    Mar 2007
    Location
    Columbus, Ohio
    Posts
    120

    Default

    Can you post the csv files from the folder "D:/road_csarea_rs/"?
    It looks like this is where the information is contained. With out it we can not help you.

  6. #6
    Forum Newbie
    Using
    AutoCAD 2007
    Join Date
    Jul 2009
    Posts
    3

    Default

    hi,madavaravo..............
    please send to me lisp program for road x section........i am working as a draughtsman it will help for my job...............my ID:shakappil@gmail.com

  7. #7
    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 4000, 2GB 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 2013
    Join Date
    Nov 2005
    Location
    Norwalk, CT USofA
    Posts
    33,058

    Default

    shakappil:

    It is not a good idea to post your email address in a public forum.

    You do realize the original post was made over 19 months ago don't you? It also looks like there was some confusion regarding a csv file that was never fully answered.

    I doubt you'll get a reply.
    "I have only come here seeking knowledge. Things they wouldn't teach me of in college." The Police

    Eat brains...gain more knowledge!

  8. #8
    Forum Newbie
    Using
    AutoCAD 2007
    Join Date
    Jul 2009
    Posts
    3

    Default lisp

    i need a lisp for make road longitudinal profile...............if you have lisp please send to me...image is in below it will help you what is i am asking..........
    Attached Images

  9. #9
    Forum Deity
    Using
    AutoCAD 2002
    Join Date
    Sep 2006
    Location
    East Sussex, U.K.
    Posts
    2,965

    Default

    Well ReMark, don't just sit there!! Get on with it.

    shakappil, that is a very complicated Lisp that you expect for free, and not really something that would be handed out. It would need customisation for you, and who else would want it? Why not try to find out how your example drawing was produced, and maybe you have to buy some software

  10. #10
    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 4000, 2GB 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 2013
    Join Date
    Nov 2005
    Location
    Norwalk, CT USofA
    Posts
    33,058

    Default

    Registered forum members do not see this ad.

    I see. No, I do not have such a lisp. If there is one available you might have to do an Internet search along the lines of "autolisp"+"longitudinal profile" and see if you get any hits. Maybe one of the Lisp gurus here might know of such a routine.

    In the future, please refrain from double posting, OK? It just causes confusion. And it is usually not a good idea to add your question to the end of a thread started by someone else.
    "I have only come here seeking knowledge. Things they wouldn't teach me of in college." The Police

    Eat brains...gain more knowledge!

Similar Threads

  1. Any problem with this lisp?
    By Micah in forum AutoLISP, Visual LISP & DCL
    Replies: 17
    Last Post: 17th Apr 2008, 02:46 pm
  2. Cross-section plotting question (road design)
    By EBeach in forum AutoCAD General
    Replies: 8
    Last Post: 26th Oct 2007, 10:06 pm
  3. problem, trying to running a list of lisp from within a lisp
    By twind2000 in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 20th Aug 2007, 04:27 pm
  4. lisp routine problem
    By rab in forum AutoLISP, Visual LISP & DCL
    Replies: 10
    Last Post: 30th Jan 2006, 10:24 am
  5. funny problem about command "section" in a script
    By phymilton in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 18th Jan 2006, 03:36 am

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