+ Reply to Thread
Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 29
  1. #11
    Full Member
    Using
    AutoCAD 2015
    Join Date
    Sep 2016
    Posts
    99

    Default

    Registered forum members do not see this ad.

    You started your 1st mail by saying you have a text file on a specific location. But probably not a problem. Each drawing has it own txt / csv file or one big mother of all csv / txt files for multiple files (drawings) , so multiple lines? And if so , how is the structure of your drawing name or is it just 9574896 as in your example? If so , is each sheet on a separate (named?) layout?
    Yes, I have a big mother file for all drawings. and i have attached here sample only, my original file is slightly Different from this sample.

  2. #12
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,569

    Default

    Quote Originally Posted by gmmdinesh View Post
    I have already tried that lee-mac Lisp, when i run that lisp its opening the dialog box for select the csv file. and also it was working with CSV file, but i have a Text file only.

    Could you please help me, how to fill automatically using text file.
    • A CSV file is merely a Text file whose data is delimited using commas - you can easily convert your Text file to a CSV file.
    • You can configure my program to source the data automatically without prompting the user for the file - read the program description.
    • With the program configured to run without prompting the user for the file, you can run my program across mutiple drawings using a Script (which could even be created using my Script Writer program).
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  3. #13
    Super Member rlx's Avatar
    Computer Details
    rlx's Computer Details
    Operating System:
    W10
    Computer:
    i74ghz/ssd500/2tbhdd
    Discipline
    Electrical
    rlx's Discipline Details
    Occupation
    electrical designer dragon
    Discipline
    Electrical
    Details
    I dont excel in anything but I rearly give up
    Using
    AutoCAD 2016
    Join Date
    Nov 2014
    Location
    Bergen op Zoom , Netherlands
    Posts
    1,011

    Default

    Code:
    ; having no complete list , using provided sample drawing and 1 data row only
    ; also use a fixed blockname ("1")
    
    
    (defun SplitStr ( s d / p )
      (if (setq p (vl-string-search d s))
         (cons (substr s 1 p) (SplitStr (substr s (+ p 1 (strlen d))) d)) (list s)))
    
    (defun c:t3 ( / fn-in fp-in attribute-names-list attribute-values-list ss blk)
      ; change attribute
      (defun _CA (a v)
        (vl-some '(lambda (x)
      (if (eq (strcase a) (strcase (vla-get-tagstring x)))(vla-put-textstring x v)))
          (vlax-invoke blk 'getattributes)))
      
      ; if filename has fixed name & location (setq fn-in "c:/bla/bladie/blabla.txt) "
      (setq bn "1" fn-in (getfiled "Text file containing" "" "txt" 0) fp-in (open fn-in "r"))
      (setq attribute-names-list (cddr (SplitStr (read-line fp-in) "\t")))
      (setq attribute-values-list (cddr (SplitStr (read-line fp-in) "\t")))
      (if fp-in (close fp-in))
      (foreach layout (layoutlist)
        (if (and (setq ss (ssget "_X" (list (cons 0 "INSERT")(cons 2 bn))))
          (setq blk (vlax-ename->vla-object (ssname ss 0))))
          (mapcar '(lambda (att val) (_CA att val))
                        attribute-names-list attribute-values-list
          )
        )
      )
      (princ)
    )
    Last edited by rlx; 7th Jun 2018 at 02:28 pm.

  4. #14
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2017
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,225

    Default

    Hi,

    I wrote this program based on txt file & sample drawing that attached earlier by the OP.

    Code:
    (defun c:AutoAttsUpd ( / *error* _peelstring  txt dir opn lst str sel int ent soc pos)
      ;; Tharwat - 07.Jun.2018	;;
      (defun *error* (msg)
        (and opn (close opn))
        (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*"))
             (princ (strcat "\nError => " msg ))
        )
      )
      
      (setq txt "Att") ;; text File name that must be available in the directory of current drawing.
      (if (and (setq dir (strcat (getvar 'DWGPREFIX) txt ".txt"))
               (or (findfile dir)
                   (alert (strcat "Text file " dir " is not found in current drawing's directory <!>"))
                   )
               (setq opn (open dir "r"))
               (read-line opn)
               )
        (progn
          (defun _peelstring (string del / str pos lst)
            (while (setq pos (vl-string-search del string 0))
              (setq str    (substr string 1 pos)
                    string (substr string (+ pos (1+ (strlen del))))
                    )
              (and str (/= str "") (setq lst (cons str lst)))
              )
            (and string (/= string "") (setq lst (cons string lst)))
            (reverse lst)
            )
          (while (setq str (read-line opn))
            (setq lst (cons (_peelstring str "\t") lst))
            )
          (and (setq int -1 sel (ssget "_X" (list '(0 . "INSERT") '(66 . 1) (cons 2 (apply 'strcat (mapcar '(lambda (u) (strcat (cadr u) ",")) lst))))))
               (while (setq ent (ssname sel (setq int (1+ int))))
                 (and (setq soc (assoc (cdr (assoc 5 (entget ent))) lst))
                      (setq soc (cddr soc)
                            pos -1)
                      (princ "\nProcessing ...")
                      (mapcar '(lambda (x) (vla-put-textstring x (nth (setq pos (1+ pos)) soc)))
                              (vlax-invoke (vlax-ename->vla-object ent) 'getattributes))
                      )
                 )
               )
          )
        )
      (*error* nil)
      (princ)
      ) (vl-load-com)

  5. #15
    Full Member
    Using
    AutoCAD 2015
    Join Date
    Sep 2016
    Posts
    99

    Default

    Hello,
    Thank you all for your Code,
    Tharwat,when i tried your code i got error like file not found on current drawing directory.
    Actually my text file is not placed on current drawing directory. so how to mention the path in lisp?

    Thanks

  6. #16
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2017
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,225

    Default

    Quote Originally Posted by gmmdinesh View Post
    Tharwat,when i tried your code i got error like file not found on current drawing directory.
    Actually my text file is not placed on current drawing directory. so how to mention the path in lisp?

    Thanks
    Hi,
    Select your txt file then right click then properties, then from the properties window go to security tab then copy the path of the file then close that window.

    Now just replace the path with the following from my codes above.

    Code:
     (setq txt "Att") ;; text File name ..... <--- REMOVE THIS LINE FROM THE PROGRAM SINCE YOU DON'T NEED IT ANYMORE.
      (if (and (setq dir "C:\\Users\\Tharwat\\Desktop\\Att.txt") ;; YOU SHOULD HAVE THE PATH WITH TWO BACK SLASHES OR ONE FORWARD SLASH.
               (or (findfile dir)
                    (alert (strcat "Text file was not found in current path => " dir))
               )
               ;;; THE REST OF CODES

  7. #17
    Full Member
    Using
    AutoCAD 2015
    Join Date
    Sep 2016
    Posts
    99

    Default

    Hello Tharwat,
    I have changed the code as you posted above, but it's not changed anything.
    Code:
    (defun c:AutoAttsUpd ( / *error* _peelstring  txt dir opn lst str sel int ent soc pos)
      ;; Tharwat - 07.Jun.2018	;;
      (defun *error* (msg)
        (and opn (close opn))
        (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*"))
             (princ (strcat "\nError => " msg ))
        )
      )
      
     ; (setq txt "Att") ;; text File name ..... <--- REMOVE THIS LINE FROM THE PROGRAM SINCE YOU DON'T NEED IT ANYMORE.
      (if (and (setq dir "B:\\AppData\\Local\\Autodesk\\Autodesk AutoCAD Map 3D 2014\\R19.1\\enu\\LISP\\Att.txt") ;; YOU SHOULD HAVE THE PATH WITH TWO BACK SLASHES OR ONE FORWARD SLASH.
               (or (findfile dir)
                    (alert (strcat "Text file was not found in current path => " dir))
               )
               (setq opn (open dir "r"))
               (read-line opn)
               )
        (progn
          (defun _peelstring (string del / str pos lst)
            (while (setq pos (vl-string-search del string 0))
              (setq str    (substr string 1 pos)
                    string (substr string (+ pos (1+ (strlen del))))
                    )
              (and str (/= str "") (setq lst (cons str lst)))
              )
            (and string (/= string "") (setq lst (cons string lst)))
            (reverse lst)
            )
          (while (setq str (read-line opn))
            (setq lst (cons (_peelstring str "\t") lst))
            )
          (and (setq int -1 sel (ssget "_X" (list '(0 . "INSERT") '(66 . 1) (cons 2 (apply 'strcat (mapcar '(lambda (u) (strcat (cadr u) ",")) lst))))))
               (while (setq ent (ssname sel (setq int (1+ int))))
                 (and (setq soc (assoc (cdr (assoc 5 (entget ent))) lst))
                      (setq soc (cddr soc)
                            pos -1)
                      (princ "\nProcessing ...")
                      (mapcar '(lambda (x) (vla-put-textstring x (nth (setq pos (1+ pos)) soc)))
                              (vlax-invoke (vlax-ename->vla-object ent) 'getattributes))
                      )
                 )
               )
          )
        )
      (*error* nil)
      (princ)
      ) (vl-load-com)
    Could you please check this.

  8. #18
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2017
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,225

    Default

    A few restriction points as per your txt file:
    • Do you have the attributed block names as included in the txt file in the second column?
    • Do the attributed blocks in the drawing matching the handle codes as in the txt file in the first column?

  9. #19
    Full Member
    Using
    AutoCAD 2015
    Join Date
    Sep 2016
    Posts
    99

    Default

    Do you have the attributed block names as included in the txt file in the second column?
    Do the attributed blocks in the drawing matching the handle codes as in the txt file in the first column?
    Yes I have same Attribute Block with same name as Text file and the Handle Name also Same.
    But when i tried to manually it's working (Using ATTIN)

  10. #20
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2017
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,225

    Default

    Registered forum members do not see this ad.

    So can you upload a real sample drawing along with the txt file you have tested the program with to take a close look?

Similar Threads

  1. Lee Mac's Update Title Block
    By Craisbeck in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 7th Mar 2013, 05:04 pm
  2. Trying to Automatically update/redefine block in Thousands of drawings
    By john_waggs in forum The CUI, Hatches, Linetypes, Scripts & Macros
    Replies: 4
    Last Post: 13th Feb 2013, 02:19 pm
  3. Automatically Update Title block lisp HELP!
    By Millsy29 in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 15th Jul 2010, 05:29 pm
  4. Update the attribute title block
    By andy_gs in forum AutoCAD Beginners' Area
    Replies: 3
    Last Post: 4th May 2010, 04:22 am
  5. Title Block Update
    By eddablin in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 18th Apr 2009, 01:35 pm

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