+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Senior Member gS7's Avatar
    Computer Details
    gS7's Computer Details
    Operating System:
    Windows Xp sp3
    RAM:
    4 GB
    Monitor:
    Viewsonic
    Discipline
    Surveying
    gS7's Discipline Details
    Occupation
    Drafts man / Surveyor
    Discipline
    Surveying
    Using
    AutoCAD 2009
    Join Date
    May 2012
    Location
    Udupi,INDIA
    Posts
    238

    Question Confusion with lambda function

    Registered forum members do not see this ad.

    Hi Guys

    How to Create Line for coordinates from list using lambda function
    Please need help for solve this

    Code:
    (defun c:test(/ lst )
          (setq lst '((1515.32 999.613 0.0) (2314.23 1081.97 0.0) (1690.57 752.536 0.0)
    		  (2458.55 829.747 0.0) (1685.41 474.574 0.0) (2716.26 443.689 0.0))
          )
          (mapcar (function (lambda (x y)
    			      (command "line" x y "") ????
    			))
    	      lst
          )
    )
    Ganesh Shetty

  2. #2
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    941

    Default

    Code:
    (mapcar 
      '(lambda (x y) (entmakex (list (cons 0 "LINE") (cons 10 x) (cons 11 y))))
      lst
      (append (cdr lst) (list (last lst)))
    )
    Or:
    Code:
    (mapcar 
      '(lambda (x) (entmakex (list (cons 0 "LINE") (cons 10 (car x)) (cons 11 (cadr x)))))
      (mapcar 'list lst (append (cdr lst) (list (last lst))))
    )

    EDIT: Or if you use LM's entmake functions, then you could just
    Code:
    (defun LWPoly (lst cls) ; LM
      (entmakex 
        (append 
          (list 
            (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") 
            (cons 100 "AcDbPolyline") (cons 90 (length lst)) (cons 70 cls)
          )
          (mapcar (function (lambda (p) (cons 10 p))) lst)
        )
      )
    )
    do this:
    Code:
    (LWPoly lst 0)

  3. #3
    Senior Member gS7's Avatar
    Computer Details
    gS7's Computer Details
    Operating System:
    Windows Xp sp3
    RAM:
    4 GB
    Monitor:
    Viewsonic
    Discipline
    Surveying
    gS7's Discipline Details
    Occupation
    Drafts man / Surveyor
    Discipline
    Surveying
    Using
    AutoCAD 2009
    Join Date
    May 2012
    Location
    Udupi,INDIA
    Posts
    238

    Default

    Grrr

    That was awesome and i don't want to create only 3 Line Entity's for example '(1 1) '(2 2) '(3 3) Please waiting for your reply

    example.jpg
    Ganesh Shetty

  4. #4
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    941

    Default

    Quote Originally Posted by gS7 View Post
    Grrr

    That was awesome and i don't want to create only 3 Line Entity's for example '(1 1) '(2 2) '(3 3) Please waiting for your reply
    If you want to create lines from a point list, you have to group the items so each one consists of 2 points (a line is defined of 2 points) :
    Instead of such list
    Code:
    '(1 1) '(2 2) '(3 3)
    you'll have to use:
    Code:
    (list
      '((1 1) (2 2)) ; line #1
      '((2 2) (3 3)) ; line #2
      '((3 3) (1 1)) ; line #3 (if you want to close the shape)
    )

  5. #5
    Senior Member gS7's Avatar
    Computer Details
    gS7's Computer Details
    Operating System:
    Windows Xp sp3
    RAM:
    4 GB
    Monitor:
    Viewsonic
    Discipline
    Surveying
    gS7's Discipline Details
    Occupation
    Drafts man / Surveyor
    Discipline
    Surveying
    Using
    AutoCAD 2009
    Join Date
    May 2012
    Location
    Udupi,INDIA
    Posts
    238

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by Grrr View Post
    If you want to create lines from a point list, you have to group the items so each one consists of 2 points (a line is defined of 2 points) :
    Instead of such list
    Code:
    '(1 1) '(2 2) '(3 3)
    you'll have to use:
    Code:
    (list
      '((1 1) (2 2)) ; line #1
      '((2 2) (3 3)) ; line #2
      '((3 3) (1 1)) ; line #3 (if you want to close the shape)
    )

    Grrr thank you It is helped me lot
    Ganesh Shetty

Similar Threads

  1. Call a function in mapcar lambda function
    By Shakto in forum AutoLISP, Visual LISP & DCL
    Replies: 11
    Last Post: 25th Oct 2014, 05:07 am
  2. trying to lambda-ize a function into another
    By Jef! in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 20th Mar 2014, 04:59 pm
  3. lambda , function , mapcar , apply , foreach : explained
    By samifox in forum AutoLISP, Visual LISP & DCL
    Replies: 22
    Last Post: 9th Sep 2013, 09:56 pm
  4. lambda function
    By giskumar in forum AutoLISP, Visual LISP & DCL
    Replies: 22
    Last Post: 20th Apr 2011, 01:33 pm
  5. Function (Lambda...??
    By chulse in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 13th May 2010, 05:34 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