<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: trying to make a string of code that will be able to pull chunks of a file name structure for different cells in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trying-to-make-a-string-of-code-that-will-be-able-to-pull-chunks/m-p/11685792#M35760</link>
    <description>&lt;P&gt;OK&lt;/P&gt;&lt;P&gt;Would this function be useful to you?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun extract_str (l_read / character l_str)
  (cond
    ((eq (type l_read) 'STR)
      (while (vl-string-position 45 l_read)
        (setq
          character (substr l_read 1 (vl-string-position 45 l_read))
          l_str (cons character l_str)
          l_read (substr l_read (+ 2 (vl-string-position 45 l_read)))
        )
      )
      (reverse (cons l_read l_str))
    )
  )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;exemple of use : &lt;STRONG&gt;(extract_str "Customer-Location-Job-Drawing")&lt;/STRONG&gt; -&amp;gt; ("Customer" "Location" "Job" "Drawing")&lt;/P&gt;&lt;P&gt;You obtain a list of your words&lt;/P&gt;</description>
    <pubDate>Tue, 17 Jan 2023 16:33:24 GMT</pubDate>
    <dc:creator>CADaSchtroumpf</dc:creator>
    <dc:date>2023-01-17T16:33:24Z</dc:date>
    <item>
      <title>trying to make a string of code that will be able to pull chunks of a file name structure for different cells</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trying-to-make-a-string-of-code-that-will-be-able-to-pull-chunks/m-p/11685164#M35756</link>
      <description>&lt;P&gt;currently our file convention is as fallows&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;customer - location - job - detail.dwg&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;im looking for a code where I can have it look for the " - " and then I can modify the code to subtract what ever section is after or before like lets say I wanted to pull in job I want the program to be able to find the seccond " - " even if it has to find the first one delete then find the new first one and then I can do the subtract function as needed after that and then find the " - " right after Job and subtract every thing after respectively&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Im doing this so I can put it inside of a custom title block for us to use and then when we refference it in it would scan the file name structure and pull the information&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;heres the wrinch in the mix we deal with so many different jobs that no two jobs will have the same amount of characters between sections that is why I need it to look for the " - " ... now if the program cant look for " - " we can update our file naming to have&amp;nbsp; , or _ or any other marker that would not brake the file.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 13:06:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trying-to-make-a-string-of-code-that-will-be-able-to-pull-chunks/m-p/11685164#M35756</guid>
      <dc:creator>charlesXB5AM</dc:creator>
      <dc:date>2023-01-17T13:06:38Z</dc:date>
    </item>
    <item>
      <title>Re: trying to make a string of code that will be able to pull chunks of a file name structure for different cells</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trying-to-make-a-string-of-code-that-will-be-able-to-pull-chunks/m-p/11685463#M35757</link>
      <description>&lt;P&gt;I'm not answering your question, but why not use drawing properties.&lt;BR /&gt;You could use for example in the "Customize" tab two keys.&lt;BR /&gt;Customer: where you will enter the name of the customer&lt;BR /&gt;Job: for the nature of the work&lt;/P&gt;&lt;P&gt;Then in your drawing make a block which will consist of four dynamic fields&lt;BR /&gt;1 which will look for the "Customer" key in the properties&lt;BR /&gt;2 which will fetch the "File name" by checking "Path only"&lt;BR /&gt;3 which will look for the "Job" key in the properties&lt;BR /&gt;4 which will fetch the "File name" by checking "File name only" (with or without "Show file extension")&lt;/P&gt;&lt;P&gt;So your block will automatically update: at any time you can change the "Customer" and "Job" keys to impact the value of the blocks already inserted&lt;BR /&gt;Then an extraction of the attributes would be easy&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 14:54:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trying-to-make-a-string-of-code-that-will-be-able-to-pull-chunks/m-p/11685463#M35757</guid>
      <dc:creator>CADaSchtroumpf</dc:creator>
      <dc:date>2023-01-17T14:54:51Z</dc:date>
    </item>
    <item>
      <title>Re: trying to make a string of code that will be able to pull chunks of a file name structure for different cells</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trying-to-make-a-string-of-code-that-will-be-able-to-pull-chunks/m-p/11685511#M35758</link>
      <description>&lt;P&gt;reason I was trying to focus on pulling from the file name, was in order to eliminate entering the information twice since it needs to be entered into the file name anyway&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 15:07:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trying-to-make-a-string-of-code-that-will-be-able-to-pull-chunks/m-p/11685511#M35758</guid>
      <dc:creator>charlesXB5AM</dc:creator>
      <dc:date>2023-01-17T15:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: trying to make a string of code that will be able to pull chunks of a file name structure for different cells</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trying-to-make-a-string-of-code-that-will-be-able-to-pull-chunks/m-p/11685593#M35759</link>
      <description>&lt;P&gt;Sorry, I don't have much time--to solve the entire problem--, but I can try and help you solve the string problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is something I found in a production script I wrote years ago for doing something very similar.&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(defun instr? (sstr str c-sen / a)
 ;;===================================================================;
 ;; instr?                                                            ;
 ;;-------------------------------------------------------------------;
 ;; Returns the charater position of the first occurnce               ;
 ;; of the substring in the string                                    ;
 ;;                                                                   ;
 ;; Usage: (instr? "test" "this is a test of johns procedure" nil)    ;
 ;;      &amp;gt; 11  (The index number of the first occurance.)             ;
 ;;                                                                   ;
 ;; Arguments: sstr - A sub-string to search for.                     ;
 ;;            str - A string to search.                              ;
 ;;            c-sen - T = case matters                               ;
 ;;                    nil = Case dose not matter                     ;
 ;;                                                                   ;
 ;; Notes: This procedure uses recursion, so handeling a large lists  ;
 ;;        is not recomemded. (you could get a stack error.)          ;
 ;;                                                                   ;
 ;; Author: John Kaul                                                 ;
 ;;                                                                   ;
 ;; Revision History:                                                 ;
 ;; 0.1 - initial                                                     ;
 ;; 0.2 - added case sensitivity                                      ;
 ;;                                                                   ;
 ;; TODO:                                                             ;
 ;;      Add the option to choose case sensitivity. ~DONE~            ;
 ;;===================================================================;
  (cond ((eq c-sen nil) (setq sstr (strcase sstr))
               (setq str (strcase str))))
  ;; if the user wants case sensivity then set the str's
  ;; case to upper, otherwise dont evaluate (less steps)
  (defun instr-nest (sstr str)
    (cond ((&amp;gt; (strlen str) 0)
           ;; If there is still more string to search
           (if (eq sstr (substr str 1 (strlen sstr)))
           ;; Check the substring with a part of the string
           ;; to see if they match if they do...
             str ; Return the string
             (instr-nest sstr (substr str 2)))))) ; go thur again
  (setq a (instr-nest sstr str)) ; Set a variable for testing
  ;; if there is a good result... otherwise...
  (if a (1+ (- (strlen str) (strlen a))) nil) )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 15:29:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trying-to-make-a-string-of-code-that-will-be-able-to-pull-chunks/m-p/11685593#M35759</guid>
      <dc:creator>john.kaulB9QW2</dc:creator>
      <dc:date>2023-01-17T15:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: trying to make a string of code that will be able to pull chunks of a file name structure for different cells</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trying-to-make-a-string-of-code-that-will-be-able-to-pull-chunks/m-p/11685792#M35760</link>
      <description>&lt;P&gt;OK&lt;/P&gt;&lt;P&gt;Would this function be useful to you?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun extract_str (l_read / character l_str)
  (cond
    ((eq (type l_read) 'STR)
      (while (vl-string-position 45 l_read)
        (setq
          character (substr l_read 1 (vl-string-position 45 l_read))
          l_str (cons character l_str)
          l_read (substr l_read (+ 2 (vl-string-position 45 l_read)))
        )
      )
      (reverse (cons l_read l_str))
    )
  )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;exemple of use : &lt;STRONG&gt;(extract_str "Customer-Location-Job-Drawing")&lt;/STRONG&gt; -&amp;gt; ("Customer" "Location" "Job" "Drawing")&lt;/P&gt;&lt;P&gt;You obtain a list of your words&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 16:33:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trying-to-make-a-string-of-code-that-will-be-able-to-pull-chunks/m-p/11685792#M35760</guid>
      <dc:creator>CADaSchtroumpf</dc:creator>
      <dc:date>2023-01-17T16:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: trying to make a string of code that will be able to pull chunks of a file name structure for different cells</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trying-to-make-a-string-of-code-that-will-be-able-to-pull-chunks/m-p/11685884#M35761</link>
      <description>A string tokenizer is a fun idea! I'll have to find some time to play because there is so many ways to play -i.e. in C I was just working on a parser/tokenizer that used a "truth table" (that method would be akin to making your nails to build a birdhouse) but it was so fun.</description>
      <pubDate>Tue, 17 Jan 2023 17:00:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trying-to-make-a-string-of-code-that-will-be-able-to-pull-chunks/m-p/11685884#M35761</guid>
      <dc:creator>john.kaulB9QW2</dc:creator>
      <dc:date>2023-01-17T17:00:43Z</dc:date>
    </item>
    <item>
      <title>Re: trying to make a string of code that will be able to pull chunks of a file name structure for different cells</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trying-to-make-a-string-of-code-that-will-be-able-to-pull-chunks/m-p/11686001#M35762</link>
      <description>&lt;P&gt;It turns out I had a beginner challenge at theswamp.org that was a string indexer. That challenge was constructed to support different needs that should fit your current and future needs (using "-" or "_" or...). I'll post my simple solution to that challenge, but I think I also remember pBe's method beat mine because it used WCMATCH instead of my crude look up table method (I'm sorry but, you'll have to research the other methods posted there for the best one that fits your needs or is fast enough for your taste because I really need to get my project specifications done).&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(defun ispunct ( nu )
  (or (and (&amp;gt;= nu 33) (&amp;lt;= nu 47))
      (and (&amp;gt;= nu 58) (&amp;lt;= nu 64))
      (and (&amp;gt;= nu 91) (&amp;lt;= nu 96))))

(defun string-index (proc str / alst cntr)
  ;; string-index
  ;; Check each char of a string against a given process
  ;; and return an idex number list if process returns T.
  (if (= cntr '()) (setq cntr 1))
  (setq len (strlen str))
  (while (&amp;lt;= cntr len)
         (if (eval (list proc (ascii (substr str cntr 1))))
           (setq alst (cons cntr alst)))
         (setq cntr (1+ cntr))
         )
  (reverse alst) )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which you can use to index the string like this:&lt;/P&gt;&lt;P&gt;(string-index 'ispunct "Customer-Location-Job-Drawing")&lt;BR /&gt;&amp;gt; (9 18 22)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now you can pull the substrings.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 17:36:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trying-to-make-a-string-of-code-that-will-be-able-to-pull-chunks/m-p/11686001#M35762</guid>
      <dc:creator>john.kaulB9QW2</dc:creator>
      <dc:date>2023-01-17T17:36:48Z</dc:date>
    </item>
    <item>
      <title>Re: trying to make a string of code that will be able to pull chunks of a file name structure for different cells</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trying-to-make-a-string-of-code-that-will-be-able-to-pull-chunks/m-p/11686031#M35763</link>
      <description>&lt;P&gt;There are assorted functions defined in the Forums to split up a text string into a &lt;STRONG&gt;&lt;EM&gt;list of shorter strings&lt;/EM&gt;&lt;/STRONG&gt;, using whatever delimiting character(s) you want [space, comma, semicolon, your " - ", etc.].&amp;nbsp; Then you can pull the pieces from the list, to use as desired.&amp;nbsp; I leave it to you to Search, but this is a pretty common thing.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 17:51:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/trying-to-make-a-string-of-code-that-will-be-able-to-pull-chunks/m-p/11686031#M35763</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2023-01-17T17:51:52Z</dc:date>
    </item>
  </channel>
</rss>

