+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 23
  1. #1
    Full Member yajis_narif's Avatar
    Using
    AutoCAD 2011
    Join Date
    Apr 2011
    Posts
    45

    Unhappy distance between points in lines ?

    Registered forum members do not see this ad.

    hii
    i have a drawing with 4 lines of points (each line of points with the same Y) . i have the coordinate of the points of each line in a list and all the lists in a list .
    so now i want to calculate the disatnce between points of each list knowing that the number of points in lines may change and may not be equal as follows :
    . . . . .
    . . . . .
    . . . .
    . . .


    so i've created a lisp that can measure the distance but the only problem is that i can calculate the distance only if the lines have the same number of points.
    plzz help me ans again sorry my english is bad

  2. #2
    Senior Member Ahankhah's Avatar
    Computer Details
    Ahankhah's Computer Details
    Operating System:
    Windows 8.2
    Using
    Revit 2015
    Join Date
    Jun 2010
    Location
    Tehran, Iran
    Posts
    472

    Default

    Could you post your code?
    Mehrdad Ahankhah مهرداد آهن خواه
    www.IranCAD.com

  3. #3
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows 8.1
    Discipline
    Landscape
    Using
    AutoCAD 2015
    Join Date
    Apr 2010
    Posts
    2,995

    Default

    Quote Originally Posted by yajis_narif View Post
    hii
    iso i've created a lisp .....
    where is it?

  4. #4
    Full Member yajis_narif's Avatar
    Using
    AutoCAD 2011
    Join Date
    Apr 2011
    Posts
    45

    Default

    Code:
    (defun LM:GroupByFoo ( lst foo )
      (if lst
        (cons
          (cons (car lst)
            (vl-remove-if-not '(lambda ( x ) (foo (cadr lst) x)) (cdr lst))
          )
          (LM:GroupByFoo (vl-remove-if '(lambda ( x ) (foo (car lst) x)) (cdr lst)) foo)
        )
      )
    )
    
    (defun c: test (all /)     
    (setq lall(length all))
     (setq f -1)
     (setq sorty (list))
            (while ( < (setq f (1+ f)) lall)
     (setq allc (vl-sort                                   
        (LM:GroupByFoo (nth f all)
         (lambda ( a b ) (equal (cadr a) (cadr b)))
        )
      '(lambda ( a b ) (< (cadar a) (cadar b)))
      )
    )
    (setq sorty (append sorty (list allc)))  
    )
    (setq ls (length sorty))
    (setq lallc(length allc))
    
    (setq n -1)
    (setq sortall(list))
    (while ( <(setq n (1+ n)) ls)
    (setq m -1)
    (setq sortx (list))
    (while ( < (setq m (1+ m)) lallc)
    
    (setq xx0 (vl-sort (nth m (nth n sorty))
    (function (lambda (e1 e2)
    ( < (car e1) (car e2)) ) ) ))
    (setq sortx (append sortx (list xx0)))            
    )
    (setq sortall(append sortall (list sortx)))          
    )  
    (setq Ldie(length sortall))
    (setq di1 (nth 0 sortall))
    (setq l1 (length (nth 0 sortall)))
    (setq ty -1)
    (setq lleny (list))
    (while (< (setq ty (1+ ty)) l1)
    
    (setq lleny (append lleny (list (length (nth ty di1)))))    
    )
    (princ lleny)
    
    (setq diste (list))
    (setq dislist (list))
    
    (setq t -1)
    (while ( <(setq t (1+ t)) l1)                                    
    (setq r -1)
    (setq q 0)
    (setq diste (list))         
    (while (and (< (setq r(1+ r)) 4)( < (setq q (+ 1 q)) 4))   
    
    (setq di (distance (nth r (nth t (nth 0 sortall))) (nth q (nth t (nth 0 sortall)))))
    (setq diste (append diste ( list di)))
    
    )
    (setq dislist(append dislist (list diste)))  
                           
    )
    thanks

  5. #5
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,563

    Default

    The 'GroupByFoo' looks incorrect, check the one I supplied here.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

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

  6. #6
    Senior Member Ahankhah's Avatar
    Computer Details
    Ahankhah's Computer Details
    Operating System:
    Windows 8.2
    Using
    Revit 2015
    Join Date
    Jun 2010
    Location
    Tehran, Iran
    Posts
    472

    Default

    1- In your code one closing paranthesis is needed at the very end of file.
    2- It is forbidden in AutoLISP to assign a name to a function or variable with spaces, so c: test is wrong.
    3- A command defined by AutoLISP can not have any arguement, your command: test has: (defun c: test (all /) ...

    I am checking the code.
    Mehrdad Ahankhah مهرداد آهن خواه
    www.IranCAD.com

  7. #7
    Full Member yajis_narif's Avatar
    Using
    AutoCAD 2011
    Join Date
    Apr 2011
    Posts
    45

    Default

    i just gives you a part of the code and sorry for the c: it's a mistake my bad
    thank you

  8. #8
    Luminous Being BlackBox's Avatar
    Computer Details
    BlackBox's Computer Details
    Operating System:
    Windows 8.1 Professional, Server 2012 R2 Datacenter
    Computer:
    Dell Precision T3600
    CPU:
    Hex-Core Intel Xeon 3.2Ghz
    RAM:
    32GB
    Graphics:
    3GB NVIDIA Quadro K4000
    Primary Storage:
    2 x 240GB Samsung EVO SSD (RAID 0)
    Secondary Storage:
    1TB Western Digital VelociRaptor 10K RPM
    Monitor:
    Dual 24" Dell Ultrasharp Widescreen Monitors
    Discipline
    Civil
    BlackBox's Discipline Details
    Occupation
    Senior Civil Designer
    Discipline
    Civil
    Details
    Public/Private Land Development, Transportation, and Utilities.
    Using
    Civil 3D 2016
    Join Date
    Nov 2009
    Posts
    5,282

    Default

    Quote Originally Posted by Ahankhah View Post
    3- A command defined by AutoLISP can not have any arguement, your command: test has: (defun c: test (all /) ...
    I believe what Ahankah is trying to say, is that in order to supply an argument to your function you might instead use:

    Code:
    (defun test (all / )
      ;; <-- Your code here
    Example syntax: (test all)
    "Potential has a shelf life." - Margaret Atwood
    AutoCAD, and Civil 3D Certified Professional | Autodesk Authorized Developer
    Sincpac C3D ~ Exchange Apps ~ Autoloader ~ AutoCAD Security

  9. #9
    Senior Member Ahankhah's Avatar
    Computer Details
    Ahankhah's Computer Details
    Operating System:
    Windows 8.2
    Using
    Revit 2015
    Join Date
    Jun 2010
    Location
    Tehran, Iran
    Posts
    472

    Default

    Renderman, you are right. English isn't my native language, I live in Iran, but you live Somewhere between Civil 3D and Maya, which means your language isn't Persian.
    Mehrdad Ahankhah مهرداد آهن خواه
    www.IranCAD.com

  10. #10
    Luminous Being BlackBox's Avatar
    Computer Details
    BlackBox's Computer Details
    Operating System:
    Windows 8.1 Professional, Server 2012 R2 Datacenter
    Computer:
    Dell Precision T3600
    CPU:
    Hex-Core Intel Xeon 3.2Ghz
    RAM:
    32GB
    Graphics:
    3GB NVIDIA Quadro K4000
    Primary Storage:
    2 x 240GB Samsung EVO SSD (RAID 0)
    Secondary Storage:
    1TB Western Digital VelociRaptor 10K RPM
    Monitor:
    Dual 24" Dell Ultrasharp Widescreen Monitors
    Discipline
    Civil
    BlackBox's Discipline Details
    Occupation
    Senior Civil Designer
    Discipline
    Civil
    Details
    Public/Private Land Development, Transportation, and Utilities.
    Using
    Civil 3D 2016
    Join Date
    Nov 2009
    Posts
    5,282

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by Ahankhah View Post
    Renderman, you are right. English isn't my native language, I live in Iran, but you live Somewhere between Civil 3D and Maya, which means your language isn't Persian.
    Ahankhah, I mean no offense to you, my friend.

    I simply tried to provide an example to your correct statement, as when I began programming LISP, I would not have understood fully. For me, sometimes 'seeing' an example helps me to understand.

    I assure you, your English is far superior to my Persian.
    "Potential has a shelf life." - Margaret Atwood
    AutoCAD, and Civil 3D Certified Professional | Autodesk Authorized Developer
    Sincpac C3D ~ Exchange Apps ~ Autoloader ~ AutoCAD Security

Similar Threads

  1. 2D distance between 3D points
    By Tyke in forum AutoCAD General
    Replies: 10
    Last Post: 1st Nov 2010, 05:42 pm
  2. Getting points locations at devided distance
    By Michaels in forum AutoLISP, Visual LISP & DCL
    Replies: 17
    Last Post: 20th Aug 2010, 01:26 am
  3. lines (bearing/distance)
    By cordgrass in forum AutoCAD Beginners' Area
    Replies: 11
    Last Post: 16th Jul 2009, 04:34 pm
  4. distance between points
    By salman in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 17th Jun 2009, 04:42 pm
  5. Distance between two lines
    By undoman in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 22nd Jun 2006, 06:58 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