Author Topic: Tabs and more Tabs  (Read 3438 times)

0 Members and 1 Guest are viewing this topic.

GDF

  • Water Moccasin
  • Posts: 2081
Tabs and more Tabs
« on: December 17, 2005, 09:56:46 AM »
I am using the following modified code by Mark S. Thomas to illustrate how I place "tabs" in columns. I have modified Mark's code to tab
columns based upon the strength of each layer value. The original routine was named exp-layer-info.lsp Thanks to Mark for sharing his routine.

I learned from Mark's example and just wanted to pass it on.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

GDF

  • Water Moccasin
  • Posts: 2081
Re: Tabs and more Tabs
« Reply #1 on: December 17, 2005, 10:04:45 AM »
Sorry, I forgot to mention that the routine inclosed takes a snap shot of the layer settings of the current drawing. The text file
it creates is placed in the drawing folder.

I enclosed an example.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

GDF

  • Water Moccasin
  • Posts: 2081
Re: Tabs and more Tabs
« Reply #2 on: December 17, 2005, 04:19:52 PM »
The enclosed example uses spaces in lieu of tabs.

I quess I'm looking for the best of both ways to tab or add spaces to line up columns.

The last example shows how I tab in list_box within a dcl tile.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Sdoman

  • Guest
Re: Tabs and more Tabs
« Reply #3 on: December 17, 2005, 09:29:16 PM »
Hi GDFowler,

It isn't clear whether you are asking a question or sharing code.  :)

If you are looking for a way to replace tabs with spaces, I posted a function named Detab in the "Repeat" thread (see link below).  If you want to replace spaces with tabs, I suppose you could reverse the logic.

http://www.theswamp.org/forum/index.php?topic=7963.msg101390#msg101390


GDF

  • Water Moccasin
  • Posts: 2081
Re: Tabs and more Tabs
« Reply #4 on: December 18, 2005, 03:25:23 PM »
Sorry, in my hast, I was not very clear. Now that I have taken the time...........I forgot the question.

Thanks for all of the examples....I quess that was what I was really after.

"The more I learn, the more I change my mind."

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Tabs and more Tabs
« Reply #5 on: December 18, 2005, 08:34:36 PM »
Gary,
Here is another approach using spaces.
I use this
  ;;  list of column widths
  (setq maxcol (list (+ maxname 3) 8 8 8 (+ maxltype 3) 10 8 8 0)
  to set the column widths then call a subroutine to pad out the data.
  Also did it with the header.
 
  Note that using ACAD2000 there is no description so I added code to deal with it.
 

Code: [Select]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;     This original Copyrighted routine has been modified...
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; AUTHOR of original code: exp-layer-info.lsp
;;; Copyright© 2004 Mark S. Thomas
;;; mark@theswamp.org

(defun mk-file-name (/ dwg_name)
  (setq dwg_name
         (vla-get-fullname (vla-get-activedocument (vlax-get-acad-object)))
  )
  (strcat (vl-filename-directory dwg_name)
          "\\"
          (vl-filename-base dwg_name)
          "-LyrList.txt"
  )
)

(defun pad (word len)
  (if (< len 1) ; no pad
    word
    (progn
      (setq spaces "")
      (repeat len (setq spaces (strcat spaces " ")))
      (strcat word (substr spaces (1+ (strlen word))))
    )
  )
)

(defun get-lw (num)
  (cond ((= num -3) (getenv "LWDEFAULT"))
        (t (itoa num))
  )
)

(defun true-false (sym)
  (cond ((= sym :vlax-true) "True")
        ((= sym :vlax-false) "False")
  )
)



(defun arch:layersnapshot (/ act_doc layer_obj fn fo layerlist tmp header lst
                           idx line maxcol maxltype maxname)
  (setq act_doc   (vla-get-activedocument (vlax-get-acad-object))
        layer_obj (vla-get-layers act_doc)
  )
  (setq fn (mk-file-name))
  (setq fo (open fn "w"))

  ;;  gather up layer info
  (vlax-for lay layer_obj
    (setq layerlist
           (cons
             (list (vla-get-name lay)
                   (true-false (vla-get-layeron lay))
                   (true-false (vla-get-freeze lay))
                   (true-false (vla-get-lock lay))
                   (vla-get-linetype lay)
                   (itoa (vla-get-color lay))
                   (get-lw (vla-get-lineweight lay))
                   (vla-get-plotstylename lay)
                   (if (vlax-property-available-p lay 'description)
                     (vla-get-description lay)
                   )
             )
             layerlist
           )
    )
  )

  ;;  sort on layer name
  (setq layerlist (vl-sort layerlist '(lambda (e1 e2) (< (car e1) (car e2)))))

  ;;  get max length of strings
  (setq maxname 0
        maxltype 0
  )
  (foreach itm layerlist
    (setq maxname  (max maxname (strlen (car itm)))
          maxltype (max maxltype (strlen (nth 4 itm)))
    )
  )

  ;;  list of column widths
  (setq maxcol (list (+ maxname 3) 8 8 8 (+ maxltype 3) 10 8 8 0))

  ;;  pad out the header
  (setq idx 0
        tmp ""
  )
  (foreach itm '("Layer Name" "On" "Frozen" "Locked" "Linetype" "Color" "LW"
                 "Plot" "Description"
                )
    (setq header (if header
                   (strcat header (pad itm (nth idx maxcol)))
                   (pad itm (nth idx maxcol))
                 )
          idx    (1+ idx)
    )
  )

  ;;  write the header
  (write-line header fo)
  (write-line (repeat (strlen header) (setq tmp (strcat "-" tmp))) fo)

  ;;  write eaCH LAYER line
  (foreach itm layerlist
    (setq line ""
          idx -1
    )
    (write-line
      (foreach str (vl-remove nil itm)
        (setq idx  (1+ idx)
              line (strcat line (pad str (nth idx maxcol)))

        )
      )
      fo
    )
  )

  (close fo)
  (princ)
)
(arch:layersnapshot)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(princ)

PS added sort.
« Last Edit: December 19, 2005, 11:38:40 AM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Tabs and more Tabs
« Reply #6 on: December 19, 2005, 09:57:07 AM »
Thank you Allen. Works great and I learned something new. I have always had trouble with spaces and tabs.
I added this also to the routine:

(startapp
      "notepad"
      (strcat (getvar "dwgprefix")(vl-filename-base (getvar "dwgname")) "-LyrList.txt")
)

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Sdoman

  • Guest
Re: Tabs and more Tabs
« Reply #7 on: December 19, 2005, 03:17:09 PM »

"The more I learn, the more I change my mind."


One of my favorite qoute is:
 
"The more I know, the more I don't know."
 
 

GDF

  • Water Moccasin
  • Posts: 2081
Re: Tabs and more Tabs
« Reply #8 on: December 19, 2005, 05:00:49 PM »
"I am not young enough to know everything."

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

whdjr

  • Guest
Re: Tabs and more Tabs
« Reply #9 on: December 19, 2005, 05:10:01 PM »
Wouldn't it be cool to learn things like they did in the Matrix?   :-)