+ Reply to Thread
Page 1 of 4 1 2 3 ... LastLast
Results 1 to 10 of 34
  1. #1
    Senior Member
    Using
    Map 3D 2007
    Join Date
    May 2011
    Location
    autocad
    Posts
    134

    Default Sort Elevations with colors

    Registered forum members do not see this ad.

    Hi,

    How can i sort elevations in different colors for every metres while importing in autocad as block attribute from csv files.

    eg. 500,200,23.1
    200,300,23.5
    400,700,24.2
    350,240,25.3

    In the above eg. my blocks when importing should have sorted (23.1,23.5 in as color 1) (24.2 in as color)...and so on.

    Any help would be highly appreciated.
    Regards

  2. #2
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,000

    Default

    Something like this?
    Code:
    (setvar "CECOLOR" (itoa (- (fix theElevation) 22)))
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  3. #3
    Senior Member
    Using
    Map 3D 2007
    Join Date
    May 2011
    Location
    autocad
    Posts
    134

    Default

    thanks MSasu
    I will do the same and let you know...

  4. #4
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,000

    Default

    The above example will give you successive colors; if need to use from a list of preferred colors, then may try:
    Code:
    (setq colorElevations '("1" "23" "45" "67" "89"))
    (setvar "CECOLOR" (nth (- (fix theElevation) 23) colorElevations))
    For sure, both examples consider 23.0 as reference elevation.

    Also, may want to add a validation to don't exceed 255 as color index.
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  5. #5
    Senior Member
    Using
    Map 3D 2007
    Join Date
    May 2011
    Location
    autocad
    Posts
    134

    Default

    thanks again

  6. #6
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,000

    Default

    You're welcome!
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  7. #7
    Senior Member
    Using
    Map 3D 2007
    Join Date
    May 2011
    Location
    autocad
    Posts
    134

    Default

    Hi Mircea,
    Need help again to fit your code in the routine i have...

  8. #8
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,000

    Default

    Quote Originally Posted by aaryan View Post
    Need help again to fit your code in the routine i have...
    Then, you should post here the said code - please see the code posting guide.
    May be useful to mark with a different color the changes that you already did.
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  9. #9
    Senior Member
    Using
    Map 3D 2007
    Join Date
    May 2011
    Location
    autocad
    Posts
    134

    Default

    thanks below is the code...

    Code:
    (defun c:Bathy (/ tpath fd info Soundings Bs Bsc BSL Pdata data ipt ba tpt x y xs ys)
    (vl-load-com)
    (defun *error*  (msg)
          (if msg
                (princ (strcat "\nError! " msg)))
          (princ)
          )
    ;//pBe
      (defun _roundTruncated  (a)
          (setq b (fix a)
                c (* (abs (- a b)) 10))
         (if (= c 0)
           (setq d 0)
                (setq d (fix (+ c (/ c (abs c) 2.0))))))
    (defun _HiLow  (lev lev2 lst)
          (list
                (apply lev (mapcar 'car lst))
                (apply lev2 (mapcar 'cadr lst))
                ))     
          ;//
    (defun colorelv (lev3 lst)
    (list (apply lev3 (mapcar 'caddr lst))))
    
    (defun _errormsg ( lst / x )
    (if (setq x (vl-some '(lambda ( x ) (if (null (eval (car x))) (cadr x))) lst))
    (alert x)
    )
    )
     
    (setvar "cmdecho" 0)
          (graphscr)
    (if (and
     (setq Pdata nil tpath (getfiled "Select XYZ File" "*.*" "txt" 4))
            (setq fsz (> (vl-file-size tpath) 0))
     (setq Soundings (getfiled "Select Sounding Block" "*.*" "dwg" 4))
            (progn
                  (setq Bs (Getreal "\nScale factor for Bathymetry Block <1>:"))
           (if (= Bs Nil) (setq Bsc 1) (setq Bsc Bs)))
    )
     (progn
           (setq fd   (open tpath "r"))
           (setq Bsl (rtos Bsc 2 3))
           (while  (setq  info (read-line fd))
                   (setq Pdata
                              (cons (read (strcat "(" (vl-string-translate
                                                        ","  " " info)
                                                  ")"))
                                    Pdata))
                   )
          (close fd)
                    (command "_.zoom" "w" (_HiLow 'min 'min Pdata)(_HiLow 'max 'max Pdata))
            (foreach data Pdata
       (setq ipt (list (car data) (cadr data))
             bat (atof (rtos (caddr data) 2 4))
             tpt data)
       (if (< bat 0)
             (progn
                   (setq ba (* -1 bat)
                         x  (fix ba)
                         y  (_roundTruncated bat))
                   (if (= y 10)
                         (progn
                               (setq x (+ x 1)
                                     y 0))
                         (progn
                               (setq x x
                                     y y)))
                   (setq xs (strcat "%%U" (itoa x))
                         ys (itoa y))
                                  )
             (progn
                   (setq x (fix bat)
                         y (_roundTruncated bat))
                   (if (= y 10)
                         (progn
                               (setq x (+ x 1)
                                     y 0))
                         (progn
                               (setq x x
                                     y y)))
                   (setq xs (itoa x)
                         ys (itoa y))
                                 ))
     (command "insert" Soundings "_scale" Bsl "_non" ipt 0 xs ys)
                   )
      ;(command "zoom" "e")
      (command "regen")
                  )
        (_errormsg
     '(
        (tpath "Failed to select Data File")
        (fsz "Bathy file is empty")
        (Soundings "Failed to select Block")
      )
    )
        )
    (*error* nil)
        (princ)
      )
    For making this routine workable Mr.pBe helped me a lot.
    If require i will insert the block drawing too..
    Regards
    Aaryan

  10. #10
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,000

    Default

    Registered forum members do not see this ad.

    Presuming that Pdata variable store a list of 3D points and the entities inside your block have their color set as ByBlock, then adjust your code:
    Code:
    (if (> (setq theColor (- (fix (caddr data)) 22)) 255) (setq theColor 1))
    (command "_insert" Soundings "_scale" Bsl "_non" ipt 0 xs ys
             "_CHPROP" (entlast) "" "_C" theColor "")
    If there are elevations bigger than 277, then their color will be always red; may need to refine a little the alocation procedure.
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

Similar Threads

  1. Using GETFILED
    By JPlanera in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 12th Dec 2011, 08:24 pm
  2. Replies: 2
    Last Post: 8th Dec 2011, 06:58 am
  3. Getfiled
    By dcpanchal_2005 in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 2nd Jun 2009, 02:20 pm
  4. Trying to Store the last folder used using Getfiled
    By Kablamtron in forum AutoLISP, Visual LISP & DCL
    Replies: 10
    Last Post: 20th Jan 2009, 03:45 pm
  5. filter in getfiled
    By jocad in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 1st Nov 2007, 11:34 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