+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Super Member halam's Avatar
    Using
    AutoCAD 2017
    Join Date
    Jul 2015
    Posts
    644

    Default GETPAT.lsp needs dwgprefix handling

    Registered forum members do not see this ad.

    In the Netherlands some bright people can up with the idea to standarize the national standard with custom hatch patterns. I never understood this because it only leads to .. welll.., a whole lot of custom made (not standard) .pat files in use. ..Go figure.. GETPAT.lsp is a good tool to obtain these missing .pat files (sender forgets them 9 out of 10 times). However, it can be made much better if it was able to write the .pat files in the current directory. I was trying to find somebody clever with lisp who could fix this in a decent fashion. Good for profiling lisp for yourselfs

    Hope it's ok to link this url to Autodesk forum. That's were google send me too..


    https://forums.autodesk.com/t5/visua...456378#M360240
    Modelling is done with two hands, 2d & 3d. Let it work together..
    https://twitter.com/halammerts

  2. #2
    Super Member halam's Avatar
    Using
    AutoCAD 2017
    Join Date
    Jul 2015
    Posts
    644

    Default

    Quote Originally Posted by halam View Post

    Hope it's ok to link this url to Autodesk forum. That's were google send me too..


    https://forums.autodesk.com/t5/visua...456378#M360240

    Solved it!
    Modelling is done with two hands, 2d & 3d. Let it work together..
    https://twitter.com/halammerts

  3. #3
    Super Member
    Computer Details
    tombu's Computer Details
    Operating System:
    Windows 7 64-bit
    Computer:
    Dell
    Discipline
    Civil
    tombu's Discipline Details
    Occupation
    Design Analyst
    Discipline
    Civil
    Details
    Small Street & Stormwater projects. Traffic Calming and other issues.
    Using
    Civil 3D 2018
    Join Date
    Dec 2010
    Location
    Tallahassee, FL USA
    Posts
    729

    Default

    I've modified mine to save the pattern definitions to a Customization folder on the network that's been added to the Support Path so they're easily accessible to the hatch command in any drawing.
    I also modified it to work on a pre-selected hatch so I could add it to the hatch right-click menu.

    Best thing about lisp code is that it's easily customizable to suit our needs. Less than a third of the code I use was created by me. While I've modified much of the code I've downloaded I keep the Author's header and the link to where I got the code in appreciation of the work they did so I didn't have to.
    I also recommend Tee Square Graphics RRL.lsp, but GETPAT.lsp is their best.
    Layer 0 for ByBlock Block entities, everything else ByLayer. So many issues can be solved with good templates.

  4. #4
    Super Member halam's Avatar
    Using
    AutoCAD 2017
    Join Date
    Jul 2015
    Posts
    644

    Default

    Nice idea. Doesn't work with Revit dwgs missing decent mapping. The problem with that it that FP_ are likely to be different for every single export. One addition question 'Save to support path?' To do both.
    Modelling is done with two hands, 2d & 3d. Let it work together..
    https://twitter.com/halammerts

  5. #5
    Super Member
    Computer Details
    tombu's Computer Details
    Operating System:
    Windows 7 64-bit
    Computer:
    Dell
    Discipline
    Civil
    tombu's Discipline Details
    Occupation
    Design Analyst
    Discipline
    Civil
    Details
    Small Street & Stormwater projects. Traffic Calming and other issues.
    Using
    Civil 3D 2018
    Join Date
    Dec 2010
    Location
    Tallahassee, FL USA
    Posts
    729

    Default

    Quote Originally Posted by halam View Post
    Nice idea. Doesn't work with Revit dwgs missing decent mapping. The problem with that it that FP_ are likely to be different for every single export. One addition question 'Save to support path?' To do both.
    Not familiar with Revit. For AutoCAD as long as it's in the Support File Search Path it's available to the Hatch command. You could easily add a vl-file-copy if you want it in current directory as well.
    Layer 0 for ByBlock Block entities, everything else ByLayer. So many issues can be solved with good templates.

  6. #6
    Super Member
    Computer Details
    tombu's Computer Details
    Operating System:
    Windows 7 64-bit
    Computer:
    Dell
    Discipline
    Civil
    tombu's Discipline Details
    Occupation
    Design Analyst
    Discipline
    Civil
    Details
    Small Street & Stormwater projects. Traffic Calming and other issues.
    Using
    Civil 3D 2018
    Join Date
    Dec 2010
    Location
    Tallahassee, FL USA
    Posts
    729

    Default

    Quote Originally Posted by halam View Post
    The problem with that it that FP_ are likely to be different for every single export. One addition question 'Save to support path?' To do both.
    Modified version to both save it in the same location as "GETPAT.lsp" and the current drawing folder.
    "GETPAT.lsp" must be in both the "Support File Search Path" and in "Trusted Folders" for it to both find the file and have permission to run it.
    Code:
    ;|
    http://www.turvill.com/t2/free_stuff/getpat.lsp
    GETPAT.LSP (c) 2001 Tee Square Graphics
        Version 1.01b - 1/22/2002
    
    This routine may be used to extract hatch pattern data
    from existing drawings when the .pat file containing
    the original information is not available.
    
    After loading the file in the usual manner, type the
    command GETPAT at the AutoCAD Command: prompt, select
    any (non-SOLID) hatch object, and the pattern information
    will be written to a .pat file having the same name as
    the pattern (e.g., pattern information for the hatch
    pattern WOODS will be written to WOODS.PAT.
    
    Ver. 1.01b includes two small fixex to eliminate "Bad
    Argument" LISP errors when run with certain installations
    of AutoCAD 2000+.
    
    Modified to use a prselected hatch and place in both the current
    location of "GETPAT.lsp" and the current drawing folder by Tom Beauford.
    
    Add command with macro: ^P(or C:GETPAT (load "GETPAT.lsp"));GETPAT
    to CUI => Shortcut Menus => Hatch Object Menu
    |;
    
    (defun C:GETPAT (/ cmde hat elst rotn hnam temp xofs yofs what
                       temp outf CustPath DwgPath flin angl tmp1 tmp2 xvec yvec)
      (setq cmde (getvar "cmdecho"))
      (setvar "cmdecho" 0)
      (setq elst (entget(ssname(ssget "+.:E:S" '((0 . "hatch")))0)) path elst)
      (if (= (cdr (assoc 0 elst)) "HATCH")
        (progn
          (setq rotn (* 180 (/ (cdr (assoc 52 elst)) pi))
                hnam (cdr (assoc 2 elst))
                hscl (cdr (assoc 41 elst))
          )
    
    ;; The following nine lines may optionally be omitted.
    ;; Their purpose is to create a temporary "clone" of the
    ;; selected hatch with a 0 deg. rotation angle, in case
    ;; the hatch object specified a rotation angle. If these
    ;; lines are omitted, the current rotation of the selected
    ;; hatch will become the "0" deg. rotation for the extracted
    ;; pattern definition.
          (if (not (zerop rotn))
            (progn
              (setq temp elst)
              (entmake temp)
              (command "_.rotate" (entlast) "" (cdr (assoc 10 temp))(- rotn))
              (setq elst (entget (entlast)))
              (entdel (entlast))
            )
          )
    ;; End of optional code.
    
          (setq xofs (cdr (assoc 43 elst))
                yofs (cdr (assoc 44 elst))
                elst (member (assoc 53 elst) elst)
          )
          (setq outf (vl-string-subst (strcat hnam ".pat") "getpat.lsp" (findfile "getpat.lsp"))
                CustPath outf
                DwgPath (strcat (getvar "dwgprefix") hnam ".pat")
          )
          (if (findfile outf)
            (progn
              (initget "Overwrite Append")
              (setq what (getkword (strcat "\n" outf " already exists; [Overwrite/Append]? ")))
            )
          )
          (setq outf (open outf (if (= what "Append") "a" "w"))
                flin (strcat "*" hnam)
          )
          (foreach x elst
            (cond
              ((= (car x) 53)
                (write-line flin outf)
                (setq angl (cdr x)
                      flin (trim (angtos angl 0 7))
                )
              )
              ((= (car x) 43)
                (setq flin (strcat flin ", " (trim (rtos (/ (- (cdr x) xofs) hscl) 2 7))))
              )
              ((= (car x) 44)
                (setq flin (strcat flin "," (trim (rtos (/ (- (cdr x) yofs) hscl) 2 7))))
              )
              ((= (car x) 45)
                (setq tmp1 (cdr x))
              )
              ((= (car x) 46)
                (setq tmp2 (cdr x)
                      xvec (/ (+ (* tmp1 (cos angl))(* tmp2 (sin angl))) hscl)
                      yvec (/ (- (* tmp2 (cos angl))(* tmp1 (sin angl))) hscl)
                      flin (strcat flin ", " (trim (rtos xvec 2 7)) "," (trim (rtos yvec 2 7)))
                )
              )
              ((= (car x) 49)
                (setq flin (strcat flin ", " (trim (rtos (/ (cdr x) hscl) 2 7))))
              )
              ((= (car x) 98)
                (write-line flin outf)
              )
              (T nil)
            )
          )
          (write-line "" outf)
          (close outf)
          (alert (strcat "Pattern definition written to " CustPath))
        )
        (alert "Selected object not a HATCH.")
      )
      (setvar "cmdecho" cmde)
      (vl-file-copy CustPath DwgPath)
      (princ)
    )
    (defun trim (x / n)
      (setq n (strlen x))
      (while (and (/= x "0")(= (substr x n 1) "0"))
        (setq n (1- n)
              x (substr x 1 n)
        )
      )
      (if (= (substr x n 1) ".")
        (setq x (substr x 1 (1- n)))
      )
      x
    )
    (princ)
    Layer 0 for ByBlock Block entities, everything else ByLayer. So many issues can be solved with good templates.

  7. #7
    Super Member halam's Avatar
    Using
    AutoCAD 2017
    Join Date
    Jul 2015
    Posts
    644

    Default

    Registered forum members do not see this ad.

    Good work Tom !!
    Modelling is done with two hands, 2d & 3d. Let it work together..
    https://twitter.com/halammerts

Similar Threads

  1. Excel handling
    By Costinbos77 in forum AutoLISP, Visual LISP & DCL
    Replies: 21
    Last Post: 9th Jul 2013, 06:55 am
  2. Error Handling
    By Bill Tillman in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 25th May 2013, 09:32 am
  3. Layout Handling
    By fabriciorby in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 19th Apr 2013, 07:20 pm
  4. handling blocks
    By nila_joy in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 5th Jun 2012, 07:08 am
  5. Can we change DWGNAME and DWGPREFIX?
    By hikerVancouver in forum AutoCAD General
    Replies: 12
    Last Post: 27th Apr 2011, 10:14 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