anchor.diff:  
     (princ)
   
  -  ; v0.0 - 2017.01.25 - Function full restructuration
  +  ; v0.1 - 2017.01.25 - Function full restructuration
     ; v0.0 - 2016.08.08 - First issue
     ; Author: David Torralba
  -  ; Last revision: 2017.01.25
  +  ; Last revision: 2016.08.08
   )
   (defun DT:PK( VL_ent_name pt )
     (vlax-curve-getDistAtPoint VL_ent_name (vlax-curve-getClosestPointTo VL_ent_name pt))
   )
  -(defun DT:SelectManholes( cntl
  -                        /
  -                        ss
  -                        man_db man_entry man_ch_list
  -                        sorted_man_db sorted_man_ch_list
  -                        pt ch id il1 il2 il3 il4 vis_sta
  -                        )
  -  ; Returns a sorted list (by chaiange) with the selected manhole data
  +(defun DT:GetManholeDatabaseForLongSection ( centrelineEnt_name
  +                                        /
  +                                        ss
  +                                        manholeDatabase manholeData manholeChainage manholeChainageList
  +                                        manholeDatabaseSorted manholeChainageListSorted
  +                                      )
  +  ; Returns a sorted list (by chainage) with the selected manhole data
     ;
     ; INPUT - Ask user to select manholes
     (setq
       ss (ssget '((0 . "INSERT")))
  -    man_db nil
  +    manholeDatabase nil
     )
     (foreach a (ssnamex ss)
       (if (= 'ename (type (cadr a)))
         (progn
  -        ; Check if is a Manhole Block
  -        (if (= "W-Manhole" (substr (LM:effectivename (vlax-ename->vla-object (cadr a))) 2 9))
  +        (if (setq manholeData (DT:GetManholeDataForLongSection (cadr a)) )
             (progn
               (setq
  -              man_entry (list
  -                          (DT:PK (vlax-ename->vla-object cntl) (cdr (assoc 10 (entget (cadr a)))))        ; Get manhole chainage
  -                          (LM:vl-getattributevalue (vlax-ename->vla-object (cadr a)) "ID")                ; Extract Manhole Block "ID" attribute
  -                          (LM:vl-getattributevalue (vlax-ename->vla-object (cadr a)) "IL1")               ; Extract Manhole Block "IL1" attribute
  -                          (LM:vl-getattributevalue (vlax-ename->vla-object (cadr a)) "IL2")               ; Extract Manhole Block "IL2" attribute
  -                          (LM:vl-getattributevalue (vlax-ename->vla-object (cadr a)) "IL3")               ; Extract Manhole Block "IL3" attribute
  -                          (LM:vl-getattributevalue (vlax-ename->vla-object (cadr a)) "IL4")               ; Extract Manhole Block "IL4" attribute
  -                          (LM:getvisibilitystate (vlax-ename->vla-object (cadr a)))                       ; Extract Manhole Block "visibility state"
  -                          (cdr (assoc "Manhole size" (LM:getdynprops (vlax-ename->vla-object (cadr a))))) ; Extract Manhole Block "Manhole size"
  -                        )
  -
  -              man_db (append man_db (list man_entry))
  -              man_ch (LM:rtos (car man_entry) 2 5)
  -            );END setq
  -            ;(princ "\nman_db = ")(princ man_db)
  -            ; Manhole Block Chainage            = (nth 0 man_data)
  -            ; Manhole Block "ID" attribute      = (nth 1 man_data)
  -            ; Manhole Block "IL1" attribute     = (nth 2 man_data)
  -            ; Manhole Block "IL2" attribute     = (nth 3 man_data)
  -            ; Manhole Block "IL3" attribute     = (nth 4 man_data)
  -            ; Manhole Block "IL4" attribute     = (nth 5 man_data)
  -            ; Manhole Block "visibility state"  = (nth 6 man_data)   para tener el tamano de la arqueta (DN1200, etc.)
  -            ; Manhole Block "manhole size"      = (nth 7 man_data)
  -
  +              manholeDatabase (append manholeDatabase (list manholeData))
  +              manholeChainage (LM:rtos (car manholeData) 2 5)
  +            )
               ; OPERATION - Add zeros till have minimum 5 digits before dot "." to be able to sort them as strings later
               (cond
  -              ((= 1 (vl-string-search "." man_ch)) (setq man_ch (strcat "0000" man_ch)) )
  -              ((= 2 (vl-string-search "." man_ch)) (setq man_ch (strcat "000"  man_ch)) )
  -              ((= 3 (vl-string-search "." man_ch)) (setq man_ch (strcat "00"   man_ch)) )
  -              ((= 4 (vl-string-search "." man_ch)) (setq man_ch (strcat "0"    man_ch)) )
  +              ((= 1 (vl-string-search "." manholeChainage)) (setq manholeChainage (strcat "0000" manholeChainage)) )
  +              ((= 2 (vl-string-search "." manholeChainage)) (setq manholeChainage (strcat "000"  manholeChainage)) )
  +              ((= 3 (vl-string-search "." manholeChainage)) (setq manholeChainage (strcat "00"   manholeChainage)) )
  +              ((= 4 (vl-string-search "." manholeChainage)) (setq manholeChainage (strcat "0"    manholeChainage)) )
               );END cond
   
               ; OPERATION - Create list of chainages as strings
  -            (setq man_ch_list (append man_ch_list (list man_ch )) )
  +            (setq manholeChainageList (append manholeChainageList (list manholeChainage )) )
             );END progn
           );END if
         );END progn
  
positive.code:   );END while
  
    ; OPERATION - Check if polyline looks like a centreline
    (if (/= "e-centreline" (cdr (assoc 8 (entget cntl))))
      (progn
        (initget "Yes No")
        (setq ans (getkword "\nSelected object is not on layer \"e-centreline\".\nAre you sure you want to use this object as centreline? <Yes/No>: [No]"))
        (if (not ans) (setq ans "No"))
        (if (= ans "Yes")
          (setq global_variable_manhole_db (DT:SelectManholes cntl))
        );END if
      );END progn
      (progn
        (setq global_variable_manhole_db (DT:SelectManholes cntl))
      )
    );END if
    ;(princ)
  )
  (defun DT:DrawExtractedManholes ( globalVariableManholesData startPoint datum verticalExageration layFoul layStorm )
    (if global_variable_manhole_db
      (progn
        (foreach manholeData global_variable_manhole_db
          (DT:DrawManhole manholeData startPoint datum verticalExageration layFoul layStorm )
        );END foreach
      );END progn
      (progn (princ "\nERROR @ DT:DrawExtractedManholes > global_variable_manhole_db = nil")(princ))
    );END if
  )
  (defun DT:DrawInvertLevelMark ( c )
    (entmakex (list (cons 0 "CIRCLE")(cons 8 "0")(cons 10 c)(cons 40 0.3)))
  )
  (defun DT:DrawStormInvertLevelBoxLine ( pBase lay )
    (entmakex (list
      (cons 0 "LINE")
      (cons 8 lay)
      (cons 10 (polar pBase (* 1.5 pi) 42) )
      (cons 11 (polar pBase (* 1.5 pi) 48))))
  )
  (defun DT:DrawFoulInvertLevelBoxLine ( pBase lay )
    (entmakex (list
      (cons 0 "LINE")
      (cons 8 lay)
      (cons 10 (polar pBase (* 1.5 pi) 48) )
      (cons 11 (polar pBase (* 1.5 pi) 54))))
  )
  (defun DT:InverLevelText (pt lay str)
    (entmakex (list
      (cons 0 "TEXT")
      (if (tblsearch "style" "ROMANS") (cons 7 "ROMANS"))
      (cons 8 lay)
      (cons 10 (polar pt (* 1.5 pi) 2.2))
      (cons 11 pt) ; needed for text justification
      (cons 40 0.84 )
      (cons 1  str)
      (cons 62 7) ; white color
      (cons 50 (* 0.5 pi))
      (cons 71 0) ; needed for text justification
      (cons 72 0) ; needed for text justification
    ))
  )
  (defun DT:WriteInvertLevels ( p0 lay IL1 IL2 IL3 IL4 / p0 )
    (if (< 0 (atof IL1)) (DT:InverLevelText (polar p0 pi 0.4) lay IL1) )
    (if (< 0 (atof IL2)) (DT:InverLevelText (polar p0 0 1.25) lay IL2) )
    (if (< 0 (atof IL3)) (DT:InverLevelText (polar p0 0 2.50) lay IL3) )
    (if (< 0 (atof IL4)) (DT:InverLevelText (polar p0 0 3.75) lay IL4) )
  )
  (defun DT:DrawVerticalAxis ( p1 p2 lay )
    (entmakex (list
      (cons 0 "LINE")
      (cons 8 lay)
      (cons 10 p1)
      (cons 11 p2)
      (if (tblsearch "LTYPE" "CENTER") (cons 6 "CENTER"))  ; Line type CENTER, if possible
      (cons 48 0.06) ; Line type scale
      (cons 62 7) ; white color
    ))
  )
  (defun DT:WriteVerticalAxisLabel (pt lay manholeName)
    (entmakex (list
      (cons 0 "TEXT")
      (if (tblsearch "style" "ROMANS") (cons 7 "ROMANS"))
      (cons 8 lay)
      (cons 10 (polar pt (* 1.5 pi) 2.2))
      (cons 11 pt) ; needed for text justification
      (cons 40 1.260 )
      (cons 1 manholeName)
      (cons 62 2) ; yellow color
      (cons 50 (* 0.5 pi))
      (cons 71 0) ; needed for text justification
      (cons 72 0) ; needed for text justification
      (cons 73 2) ; needed for text justification
      ))
  )
  (defun DT:MarkInvertLevel ( pBase ILs datum verticalExageration)
    (foreach a ILs
      (if (> a 0)
        (DT:DrawInvertLevelMark (polar pBase (* 0.5 pi) (* (- a datum) verticalExageration)) )
      );END if
    );END foreach
  )
  (defun DT:GetILFromManholeData ( manholeData )
    ; Return a list with ILs from manholeData in real format
  
negative.code: (defun c:1() (DT:ExtractManholeChainages))
  (defun c:2 ( / old_error old_sysvars ent_name startPoint datum verticalExageration)
    ; SAVE SETTINGS
    (save_environment (list "osmode" "attdia" "attreq"))
  