Results 1 to 2 of 2

Thread: can someone help me figure this out

  1. #1
    100 Club
    Join Date
    2005-06
    Location
    Idaho, USA
    Posts
    184
    Login to Give a bone
    0

    Default can someone help me figure this out

    My pregnant brain just doesn't want to understand lisp these days.
    I have a new employee using this and i can't figure out what this routine is actually doing.

    Code:
    (defun item (n e)
        (cdr (assoc n e))
      )
      (defun mend-error (s)
        (if (\= s "Function cancelled")
      	(princ s)
        )
        (if ename1
      	(redraw ename1 4)
        )
        (command ".UNDO" "END")
        (setvar "CMDECHO" 1)
        (princ)
      )
      (defun selent (typ ord /)
        (setq en nil)
        (if (= ord 0)
      	(setq ord "")
        )
        (if (= ord 1)
      	(setq ord "first ")
        )
        (if (= ord 2)
      	(setq ord "second ")
        )
        (while (null en)
      	(if	(setq en (entsel (strcat "\nSelect " ord typ ": ")))
      	  (progn
      	(setq ename (car en))
      	(setq edata (entget ename))
      	(if (/= (cdr (assoc 0 edata)) (strcase typ))
      	  (progn
      		(prompt "\nEntity is a ")
      		(princ (cdr (assoc 0 edata)))
      		(setq en nil)
      	  )
      	  (redraw ename 3)
      	)
      	  )
      	)
        )
      )
      (defun mend1 (/	ans ok es1 ename1 int1 int2 ent1 es2 ename2 ent2 plist
      		  qlist)
        (setq ans nil)
        (if (not selent)
      	(load "selent")
        )
        (selent "LINE" 1)
        (setq	ent1   edata
      	ename1 ename
        )
        (selent "LINE" 2)
        (setq	ent2   edata
      	ename2 ename
        )
        (setq	int1 (inters (cdr (assoc 10 ent1))
      			 (cdr (assoc 10 ent2))
      			 (cdr (assoc 10 ent1))
      			 (cdr (assoc 11 ent2))
      			 nil
      		 )
        )
        (setq	int2 (inters (cdr (assoc 11 ent1))
      			 (cdr (assoc 10 ent2))
      			 (cdr (assoc 11 ent1))
      			 (cdr (assoc 11 ent2))
      			 nil
      		 )
        )
        (if (or int1 int2)
      	(progn
      	  (initget "Yes No")
      	  (setq
      	ans (getkword
      		  "\nSegments are not on same line - join anyway? <N>: "
      		)
      	  )
      	  (if (= ans nil)
      	(setq ans "No")
      	  )
      	)
        )
        (if (/= ans "No")
      	(progn
      	  (setq plist (mapcar '(lambda (p1 p2)
      				 (list (distance (item p1 ent1)
     		 			 (item p2 ent2)
      				   )
      				   p1
      				   p2
      				 )
      			   )
      			  '(10 10 11 11)
      			  '(10 11 10 11)
      		  )
      		qlist (item (apply 'max (mapcar 'car plist)) plist)
      		ent1  (subst (cons (- 21 (car qlist)) (item (cadr qlist) ent2))
      			 (assoc (- 21 (car qlist)) ent1)
      			 ent1
      		  )
      	  )
      	  (entdel ename2)
      	  (entmod ent1)
      	)
      	(progn
      	  (if ename1
      	(redraw ename1 4)
      	  )
      	  (if ename2
      	(redraw ename2 4)
      	  )
      	)
        )
      )
      (defun c:mend (/ olderror *error* ce)
        (prompt "\nCommand: MEND ")
        (setq	ce	 (getvar "CMDECHO")
      	olderror *error*
      	*error*	 mend-error
        )
        (setvar "CMDECHO" 0)
        (command ".UNDO" "begin")
        (mend1)
        (command "UNDO" "END")
        (setvar "CMDECHO" 1)
        (print)
        (print)
      )
    [ Moderator Action = ON ] What are [ CODE ] tags... [ Moderator Action = OFF ]
    Last edited by Mike.Perry; 2005-11-21 at 11:47 PM. Reason: [CODE] tags added.

  2. #2
    All AUGI, all the time
    Join Date
    2015-12
    Location
    Central Oregon
    Posts
    591
    Login to Give a bone
    0

    Default Re: can someone help me figure this out

    It appears to be a function that "mends" 2 lines into 1, first checking that both lines are parallel.

    Jeff

Similar Threads

  1. I cannot figure this out
    By Mark Northrup in forum Revit MEP - General
    Replies: 2
    Last Post: 2011-05-02, 08:55 PM
  2. I know this can be done but can't figure out how
    By camilla.mott in forum AutoCAD General
    Replies: 6
    Last Post: 2008-09-25, 05:24 AM
  3. think this is easy but cant figure it out
    By ntnik in forum Revit Architecture - General
    Replies: 1
    Last Post: 2008-06-27, 05:40 PM
  4. Set Figure Label Styles in the Figure Prefix Database
    By civil3d.wishlist1941 in forum Civil 3D Wish List
    Replies: 0
    Last Post: 2008-01-09, 09:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •