See the top rated post in this thread. Click here

Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19

Thread: AutoLISP 101 - Comments and Headers - Discussion

  1. #11
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    0

    Default Re: AutoLISP 101 - Comments and Headers - Discussion

    Support functions which shouldn't technically get called elsewhere don't get mentioned at the top but still get the standard header at their location in the file.
    Since I use the same header for command line functions and libraries, I include the support functions at the top so they are easy to find and read by my header reading function.

    I should polish that routine up and share it so everyone can build libraries and search headers quickly for functions.

    I try to keep my libraries short so I can edit and debug them more easy.

    I then compile them individually, but combine them into a big toolbox after.

    P=
    AutomateCAD

  2. #12
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: AutoLISP 101 - Comments and Headers - Discussion

    Quote Originally Posted by peter View Post
    Since I use the same header for command line functions and libraries, I include the support functions at the top so they are easy to find and read by my header reading function.

    I should polish that routine up and share it so everyone can build libraries and search headers quickly for functions.
    Cool, and it would give us more reason to construct our headers just like your's.

  3. #13
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    561
    Login to Give a bone
    0

    Default Re: AutoLISP 101 - Comments and Headers - Discussion

    Just though I would throw this out there as a header

    Code:
    (defun readlines ()
    (setq new_line (read-line fo))
    (setq ans1 (strcat ans1 new_line))
    (setq new_line (read-line fo))
    (setq ans2 (strcat ans2 new_line))
    (setq new_line (read-line fo))
    (setq ans3 (strcat ans3 new_line))
    (setq new_line (read-line fo))
    (setq ans4 (strcat ans4 new_line))
    (setq new_line (read-line fo))
    (setq ans5 (strcat ans5 new_line))
    (setq new_line (read-line fo))
    (setq ans6 (strcat ans6 new_line))
    (setq new_line (read-line fo))
    (setq ans7 (strcat ans7 new_line))
    )
    
    ; change this later to a lst to save file opening
    (defun xfonts ()
      
     (setq fo (open "c:/alan/stuff/extra fonts A-Z.TXT" "r")) ; save the file below and change file path
      (while     (setq new_line (read-line fo))
        (princ new_line)
        (if (= new_line newchar)
        (readlines)
        )
     
      )
    (close fo)
    )
      
    (setq words (getstring "\nEnter title 6 characters long.."))
    
    (SETQ ANS1 ";"
          ANS2 ";"
          ANS3 ";"
          ANS4 ";"
          ANS5 ";"
          ANS6 ";"
          ANS7 ";"
          )
    (repeat 6
      (setq x 1)
      (setq newchar (substr words x 1))
      (xfonts)
      (setq x (+ x 1)) 
    )
    
    (COMMAND "TEXT" "0,0" "" ans1)
    (cOMMAND "_TEXT" "0,-2.5" "" ans2 )
    (cOMMAND "_TEXT" "0,-5.0" "" ans3)
    (cOMMAND "_TEXT" "0,-7.5" ""  ans4  )
    (cOMMAND "_TEXT" "0,-10.0" "" ans5 )
    (cOMMAND "_TEXT" "0,-12.0" "" ans6 )
    (cOMMAND "_TEXT" "0,-15.0" "" ans7 )
    
    (PRINC)
    Code:
    A
        ###   
       ## ##  
      ##   ## 
     ##     ##
     #########
     ##     ##
     ##     ##
    B
     ######## 
     ##     ##
     ##     ##
     ######## 
     ##     ##
     ##     ##
     ######## 
    C
      ###### 
     ##    ##
     ##      
     ##      
     ##      
     ##    ##
      ###### 
    D
     #######  
     ##     ##
     ##     ##
     ##     ##
     ##     ##
     ##     ##
     #######  
    E
     ########
     ##      
     ##      
     ######  
     ##      
     ##      
     ########
    F
     ########
     ##      
     ##      
     ######  
     ##      
     ##      
     ##      
    G
      ######  
     ##    ## 
     ##       
     ##   ####
     ##    ## 
     ##    ## 
      ######  
    H
     ##     ##
     ##     ##
     ##     ##
     #########
     ##     ##
     ##     ##
     ##     ##
    I
     ####
      ## 
      ## 
      ## 
      ## 
      ## 
     ####
    J
           ##
           ##
           ##
           ##
     ##    ##
     ##    ##
      ###### 
    K
     ##    ##
     ##   ## 
     ##  ##  
     #####   
     ##  ##  
     ##   ## 
     ##    ##
    L
     ##      
     ##      
     ##      
     ##      
     ##      
     ##      
     ########
    M
     ##     ##
     ###   ###
     #### ####
     ## ### ##
     ##     ##
     ##     ##
     ##     ##
    N
     ##    ##
     ###   ##
     ####  ##
     ## ## ##
     ##  ####
     ##   ###
     ##    ##
    O
      ####### 
     ##     ##
     ##     ##
     ##     ##
     ##     ##
     ##     ##
      ####### 
    P
     ######## 
     ##     ##
     ##     ##
     ######## 
     ##       
     ##       
     ##       
    Q
      ####### 
     ##     ##
     ##     ##
     ##     ##
     ##  ## ##
     ##    ## 
      ##### ##
    R
     ######## 
     ##     ##
     ##     ##
     ######## 
     ##   ##  
     ##    ## 
     ##     ##
    S
      ###### 
     ##    ##
     ##      
      ###### 
           ##
     ##    ##
      ###### 
    T
     ########
        ##   
        ##   
        ##   
        ##   
        ##   
        ##   
    U
     ##     ##
     ##     ##
     ##     ##
     ##     ##
     ##     ##
     ##     ##
      ####### 
    V
     ##     ##
     ##     ##
     ##     ##
     ##     ##
      ##   ## 
       ## ##  
        ###   
    W
     ##      ##
     ##  ##  ##
     ##  ##  ##
     ##  ##  ##
     ##  ##  ##
     ##  ##  ##
      ###  ### 
    X
     ##     ##
      ##   ## 
       ## ##  
        ###   
       ## ##  
      ##   ## 
     ##     ##
    Y
     ##    ##
      ##  ## 
       ####  
        ##   
        ##   
        ##   
        ##   
    Z
     ########
          ## 
         ##  
        ##   
       ##    
      ##     
     ########
    1
       ##  
     ####  
       ##  
       ##  
       ##  
       ##  
     ######
    2
      ####### 
     ##     ##
            ##
      ####### 
     ##       
     ##       
     #########
    3
      ####### 
     ##     ##
            ##
      ####### 
            ##
     ##     ##
      ####### 
    4
     ##       
     ##    ## 
     ##    ## 
     ##    ## 
     #########
           ## 
           ## 
    5
     ########
     ##      
     ##      
     ####### 
           ##
     ##    ##
      ###### 
    6
      ####### 
     ##     ##
     ##       
     ######## 
     ##     ##
     ##     ##
      ####### 
    7
     ########
     ##    ##
         ##  
        ##   
       ##    
       ##    
       ##    
    8
      ####### 
     ##     ##
     ##     ##
      ####### 
     ##     ##
     ##     ##
      ####### 
    9
      ####### 
     ##     ##
     ##     ##
      ########
            ##
     ##     ##
      ####### 
    0
       #####  
      ##   ## 
     ##     ##
     ##     ##
     ##     ##
      ##   ## 
       #####

  4. #14
    Active Member
    Join Date
    2015-08
    Posts
    59
    Login to Give a bone
    0

    Default Re: AutoLISP 101 - Comments and Headers - Discussion

    Got it to partially work, however it just enters the first character six times. How to get it to go to second, third, etc characters entered.
    Help, I've tried all that I know how. Need to stop repeats of first entered character.
    TIA, Steve

  5. #15
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    0

    Default Re: AutoLISP 101 - Comments and Headers - Discussion

    I am not sure how typing jumbo letters to the text screen is a header.

    Headers are information added to the top of a program file that help explain who wrote it, when, what it does, what the included functions are etc...

    But since you were playing around with writing jumbo letters to the text screen I thought I would create a function to write jumbo words too.

    The text strings are limited to 7 characters wide.

    P=

    Code:
    ;___________________________________________________________________________________________________________|
    ;
    ; Written By: Peter Jamtgaard copyright 2017 All Rights Reserved
    ;___________________________________________________________________________________________________________|
    ;
    ; Any use by unauthorized person or business is strictly prohibited.
    ;___________________________________________________________________________________________________________|
    ;
    ; Abstract: This routine allows the user to type Jumbo Text to the text screen
    ;           There are limited characters (capital letters and numerals) and limited with to 7 characters
    ;___________________________________________________________________________________________________________|
    ;
    ; Command Line Function Header List
    
    ;___________________________________________________________________________________________________________|
    
    ;* C:JumboHelloWorld
    ;* Command Line Function to print Hello World to the text screen
    
    ;* C:JumboWord
    ;* Command Line Function to print a entered text string to the text screen 
    
    ;___________________________________________________________________________________________________________|
    ;
    ; General Function Header List 
    ;___________________________________________________________________________________________________________|
    
    ;* (CSVStringToList strText strChar)
    ;* Function to Convert a CSV String to List
    
    ;* (JumboCharacterTest strLetters)
    ;* Function to remove any unrecognized characters from the string and return a list of single character strings
    
    ;* (JumboLetterData)
    ;* Function to create a list of sublists that can be used to create jumbo letters
    
    ;* (JumboWord strLetters)
    ;* Function to print a string as jumbo letters to the text screen
    
    ;* (MatrixTranspose lstMatrix)
    ;* Function to Transpose a matrix (recursive)
    
    ;$ End Header
    
    ;___________________________________________________________________________________________________________|
    ;
    ; Command Line Functions
    ;___________________________________________________________________________________________________________|
    ;
    ; Command Line Function to print Hello World to the text screen
    ;___________________________________________________________________________________________________________|
    
    (defun C:JumboHelloWorld ()
     (JumboWord "Hello")
     (JumboWord "World")
    )
    
    ;___________________________________________________________________________________________________________|
    ;
    ; Command Line Function to print a entered text string to the text screen 
    ;___________________________________________________________________________________________________________|
    
    (defun C:JumboWord (/ strLetters)
     (if (setq strLetters (getstring "\nEnter Text: "))
      (JumboWord strLetters) 
     )
    )
    
    ;___________________________________________________________________________________________________________|
    ;
    ; General Functions
    ;___________________________________________________________________________________________________________|
    ;
    ; Function to Convert a CSV String to List
    ;___________________________________________________________________________________________________________|
    
    (defun CSVStringToList  (strText strChar / intPosition lstStrings)
     (while (setq intPosition (vl-string-search strChar strText 0))
      (setq lstStrings  (cons (substr strText 1 intPosition) lstStrings)
            strText     (substr strText (+ intPosition 1 (strlen strChar)))
      )
     )
     (if lstStrings
      (reverse (cons strText lstStrings))
      (list strText)
     )
    )
    
    ;___________________________________________________________________________________________________________|
    ;
    ; Function to remove any unrecognized characters from the string and return a list of single character strings
    ;___________________________________________________________________________________________________________|
    
    (defun JumboCharacterTest (strLetters / lstReturn)
     (foreach intAscii (vl-string->list strLetters)
      (if (or (<= 65 intAscii 90)
               (<= 48 intAscii 57)
          )
       (setq lstReturn (cons intAscii lstReturn))
      )
     )
     (reverse lstReturn)
    )
    
    ;___________________________________________________________________________________________________________|
    ;
    ; Function to create a list of sublists that can be used to create jumbo letters
    ;___________________________________________________________________________________________________________|
    
    (defun JumboLetterData ()
     (mapcar '(lambda (X)(csvstringtolist X ","))
      (list
       "A,9,   ###     ,  ## ##    , ##   ##   ,##     ##  ,#########  ,##     ##  ,##     ##  "
       "B,10,########   ,##     ##  ,##     ##  ,########   ,##     ##  ,##     ##  ,########   "
       "C,9, ######    ,##    ##  ,##        ,##        ,##        ,##    ##  , ######   "
       "D,9,#######    ,##     ##  ,##     ##  ,##     ##  ,##     ##  ,##     ##  ,#######    "
       "E,9,########  ,##        ,##        ,######    ,##        ,##        ,########  "
       "F,8,########  ,##        ,##        ,######    ,##        ,##        ,##        "
       "G,9, ######    ,##    ##   ,##         ,##   ####  ,##    ##   ,##    ##   , ######    "
       "H,10,##     ##  ,##     ##  ,##     ##  ,#########  ,##     ##  ,##     ##  ,##     ##  "
       "I,5,####  , ##   , ##   , ##   , ##   , ##   ,####  "
       "J,8,      ##  ,      ##  ,      ##  ,      ##  ,##    ##  ,##    ##  , ######   "
       "K,8,##    ##  ,##   ##   ,##  ##    ,#####     ,##  ##    ,##   ##   ,##    ##  "
       "L,8,##        ,##        ,##        ,##        ,##        ,##        ,########  "
       "M,9,##     ##  ,###   ###  ,#### ####  ,## ### ##  ,##     ##  ,##     ##  ,##     ##  "
       "N,8,##    ##  ,###   ##  ,####  ##  ,## ## ##  ,##  ####  ,##   ###  ,##    ##  "
       "O,9, #######   ,##     ##  ,##     ##  ,##     ##  ,##     ##  ,##     ##  , #######   "
       "P,10,########   ,##     ##  ,##     ##  ,########   ,##         ,##         ,##         "
       "Q,10, #######   ,##     ##  ,##     ##  ,##     ##  ,##  ## ##  ,##    ##   , ##### ##  "
       "R,10,########   ,##     ##  ,##     ##  ,########   ,##   ##    ,##    ##   ,##     ##  "
       "S,9, ######   ,##    ##  ,##        , ######   ,      ##  ,##    ##  , ######   "
       "T,9,########  ,   ##     ,   ##     ,   ##     ,   ##     ,   ##     ,   ##     "
       "U,9,##     ##  ,##     ##  ,##     ##  ,##     ##  ,##     ##  ,##     ##  , #######   "
       "V,9,##     ##  ,##     ##  ,##     ##  ,##     ##  , ##   ##   ,  ## ##    ,   ###     "
       "W,10,##      ##  ,##  ##  ##  ,##  ##  ##  ,##  ##  ##  ,##  ##  ##  ,##  ##  ##  , ###  ###   "
       "X,9,##     ##  , ##   ##   ,  ## ##    ,   ###     ,  ## ##    , ##   ##   ,##     ##  "
       "Y,8,##    ##  , ##  ##   ,  ####    ,   ##     ,   ##     ,   ##     ,   ##     "
       "Z,9,########  ,     ##   ,    ##    ,   ##     ,  ##      , ##       ,########  "
       "1,7,  ##    ,####    ,  ##    ,  ##    ,  ##    ,  ##    ,######  "
       "2,9, #######   ,##     ##  ,       ##  , #######   ,##         ,##         ,#########  "
       "3,10, #######   ,##     ##  ,       ##  , #######   ,       ##  ,##     ##  , #######   "
       "4,9,##         ,##    ##   ,##    ##   ,##    ##   ,#########  ,      ##   ,      ##   "
       "5,9,########  ,##        ,##        ,#######   ,      ##  ,##    ##  , ######   "
       "6,10, #######   ,##     ##  ,##         ,########   ,##     ##  ,##     ##  , #######   "
       "7,8,########  ,##    ##  ,    ##    ,   ##     ,  ##      ,  ##      ,  ##      "
       "8,10, #######   ,##     ##  ,##     ##  , #######   ,##     ##  ,##     ##  , #######   "
       "9,9, #######   ,##     ##  ,##     ##  , ########  ,       ##  ,##     ##  , #######   "
       "0,9,  #####    , ##   ##   ,##     ##  ,##     ##  ,##     ##  , ##   ##   ,  #####  "
      )
     )
    )
    
    ;___________________________________________________________________________________________________________|
    ;
    ; Function to print a string as jumbo letters to the text screen
    ;___________________________________________________________________________________________________________|
    
    (defun JumboWord (strLetters / lstAscii lstJumboLetterData lstJumbos lstLetters)
     (textscr)
     (if (and (setq strLetters         (strcase strLetters))
              (setq strLetters         (substr strLetters 1 7))
              (setq lstAscii           (JumboCharacterTest strLetters))
              (setq lstLetters         (mapcar 'chr lstAscii))
              (setq lstJumboLetterData (JumboLetterData))
              (setq lstJumbos          (mapcar '(lambda (X)(cddr (assoc X lstJumboLetterData))) lstLetters))
              (setq lstJumbos          (matrixtranspose lstJumbos))
         )
      (foreach lstSublist lstJumbos
       (princ "\n")
       (princ (apply 'strcat lstSublist))
      )
     )
     (princ "\n")
     (princ)
    )
    
    ;___________________________________________________________________________________________________________|
    ;
    ; Function to Transpose a matrix (recursive)
    ;___________________________________________________________________________________________________________|
    
    (defun MatrixTranspose (lstMatrix)
     (if (car lstMatrix)
      (cons (mapcar 'car lstMatrix)
            (MatrixTranspose (mapcar 'cdr lstMatrix))
      )
     )
    )
    
    (princ "!")
    (vl-load-com)
    Attached Files Attached Files
    Last edited by peter; 2017-07-03 at 05:26 AM.
    AutomateCAD

  6. #16
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    0

    Default Re: AutoLISP 101 - Comments and Headers - Discussion

    It looks like this

    Code:
    Command: jumbohelloworld
    
    ##     ##  ########  ##        ##         #######
    ##     ##  ##        ##        ##        ##     ##
    ##     ##  ##        ##        ##        ##     ##
    #########  ######    ##        ##        ##     ##
    ##     ##  ##        ##        ##        ##     ##
    ##     ##  ##        ##        ##        ##     ##
    ##     ##  ########  ########  ########   #######
    
    ##      ##   #######   ########   ##        #######
    ##  ##  ##  ##     ##  ##     ##  ##        ##     ##
    ##  ##  ##  ##     ##  ##     ##  ##        ##     ##
    ##  ##  ##  ##     ##  ########   ##        ##     ##
    ##  ##  ##  ##     ##  ##   ##    ##        ##     ##
    ##  ##  ##  ##     ##  ##    ##   ##        ##     ##
     ###  ###    #######   ##     ##  ########  #######
    AutomateCAD

  7. #17
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    561
    Login to Give a bone
    0

    Default Re: AutoLISP 101 - Comments and Headers - Discussion

    It was done as a bit of fun, I thought I had removed the post after double checking and finding an error in the code. Thanks Peter for redoing with much more explanation.

  8. #18
    100 Club
    Join Date
    2000-12
    Location
    Portland, OR area
    Posts
    137
    Login to Give a bone
    0

    Default Re: AutoLISP 101 - Comments and Headers - Discussion

    Nice: I like this for not having to scroll through someone else's code to find all the functions. Or your own and you have forgotten everything that was in it

    [QUOTE=peter;1327528]This is where you all can discuss the AutoLISP 101 - Comments and Headers thread.
    4.) The command line functions with descriptions (alphabetically) including hot key assignments
    5.) The general functions with descriptions

  9. #19
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    0

    Default Re: AutoLISP 101 - Comments and Headers - Discussion

    I am glad you all found the examples and commented on them.

    I plan to post more but wanted to give everyone a chance to study what I had posted.

    Headers are very valuable when you have a lot of code to learn and use.

    P=
    AutomateCAD

Page 2 of 2 FirstFirst 12

Similar Threads

  1. AutoLISP 101
    By peter in forum AutoLISP
    Replies: 10
    Last Post: 2023-01-28, 09:27 PM
  2. Add Schedule Headers to Existing Grouped Headers
    By Wish List System in forum Revit MEP - Wish List
    Replies: 1
    Last Post: 2015-04-22, 03:24 PM
  3. Replies: 14
    Last Post: 2006-11-03, 10:44 AM
  4. Headers
    By rick.74802 in forum Revit Architecture - General
    Replies: 3
    Last Post: 2004-10-20, 03:13 AM

Posting Permissions

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