Author Topic: create a code out the hatch.  (Read 7414 times)

0 Members and 1 Guest are viewing this topic.

rainier

  • Guest
create a code out the hatch.
« on: December 05, 2007, 09:48:45 PM »
i have a customize hatch pattern and i like to add it to my acad.pat

can u help me...i need the code of that hatch.

 i attach my cad file... 2004 format

or any lisp routine can make a code out of it... if there any...

thanks

wizman

  • Bull Frog
  • Posts: 290
Re: create a code out the hatch.
« Reply #1 on: December 05, 2007, 10:52:42 PM »
Code: [Select]
;|

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+.

|;

http://www.turvill.com/t2/free_stuff/index.htm
« Last Edit: December 06, 2007, 08:44:35 AM by CAB »

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: create a code out the hatch.
« Reply #2 on: December 05, 2007, 11:10:54 PM »
Hi wizman. Sorry, but I must ask, do you the author's (Paul Turvill) permission to post this code?

(just doing my due diligence)

Thanks.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

rainier

  • Guest
Re: create a code out the hatch.
« Reply #3 on: December 05, 2007, 11:56:25 PM »
thanks wizman!!!! 

but an error msg prompt...

Command: HATCH
Select internal point: Selecting everything...
Selecting everything visible...
Analyzing the selected data...

Analyzing internal islands...

Select internal point:
Bad pattern definition file:
Missing parameter on line 587.
?


code has an error on it...

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: create a code out the hatch.
« Reply #4 on: December 06, 2007, 12:02:47 AM »
thanks wizman!!!! 

but an error msg prompt...

Command: HATCH
Select internal point: Selecting everything...
Selecting everything visible...
Analyzing the selected data...

Analyzing internal islands...

Select internal point:
Bad pattern definition file:
Missing parameter on line 587.
?


code has an error on it...

>>> Command: HATCH
The command line for the posted routine was GETPAT


>> Missing parameter on line 587.
line No. what ??

I think you have commands mixed up ?


OR ..

Is this the result from using a file created by the posted routine ?

being explicit helps   :|



kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

rainier

  • Guest
Re: create a code out the hatch.
« Reply #5 on: December 06, 2007, 12:23:56 AM »
oh.. thanks again.. no error at the file generated if you use if in the custom type...  :-)

THANKS ALOT WIZMAN!!! GREAT CODE...  :-) :-) :-)  :kewl:

KERRY, i was using the result of getpat... and paste it in my acad.pat, the output was error result, but i paste in my autocad directory and use it in a custom type... its oki..

 
« Last Edit: December 06, 2007, 12:27:34 AM by rainier »

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: create a code out the hatch.
« Reply #6 on: December 06, 2007, 12:29:56 AM »
Rainier --

Credit where due: Please thank Paul Turvill, the author of that code.

It originated from this web page, which lists some of Paul's free utilities.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: create a code out the hatch.
« Reply #7 on: December 06, 2007, 12:55:24 AM »
..................   i was using the result of getpat... and paste it in my acad.pat, the output was error result, but i paste in my autocad directory and use it in a custom type... its oki..

 

yes, .PAT files MUST be located on the Application SearchPath to be available as custom patterns
.. having it in the same folder as the drawing file should be adequate.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: create a code out the hatch.
« Reply #8 on: December 06, 2007, 12:56:36 AM »
....Credit where due: Please thank Paul Turvill, the author of that code.

..

^^  and What he said !

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

rainier

  • Guest
Re: create a code out the hatch.
« Reply #9 on: December 06, 2007, 01:02:46 AM »
MP, yes i will... hopefully..

* but its for free...  :-) we can use it personally..

wizman

  • Bull Frog
  • Posts: 290
Re: create a code out the hatch.
« Reply #10 on: December 06, 2007, 03:37:49 AM »
Thanks and credits goes to Mr. Paul Turvill for doing a good code that is why i didnt removed his name and link to preserve the owner, promote his site and let his code grow.

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: create a code out the hatch.
« Reply #11 on: December 06, 2007, 04:45:30 AM »
Hi,

A little too late, but here's the one I use.

PS: Bruno 'Bonuscad' Valsecchi (the original author) is OK for sharing.
The french code is available here.

Code: [Select]
;; Apply a transformation matrix to a vector by Vladimir Nesterovsky
(defun mxv (m v)
  (mapcar '(lambda (r) (apply '+ (mapcar '* r v))) m)
)

;;;**************************************************************************;;;
;; Original code by Bruno 'Bonuscad' Valescchi
;; Matrix handling and save purpose by 'gile'
;;
;; Returns the hatch model definition in the text screen
;; Purpose to save it in a file.

(defun c:model_hatch
       (/ err zindim ent elst vec rot scale nb ang n first)

  (defun err (msg)
    (if (= msg "Function cancelled")
      (princ)
      (princ (strcat "\nError: " msg))
    )
    (setvar "dimzin" zindim)
    (setq *error* m:err
  m:err nil
    )
    (princ)
  )

  (setq m:err *error*
*error* err
  )
  (while (not (setq ent (entsel "\nChoose the hatch model: ")))
  )
  (setq elst   (entget (car ent))
zindim (getvar "dimzin")
  )
  (if (= (getvar "measurement") 1)
    (setvar "dimzin" 8)
    (setvar "dimzin" 12)
  )
  (if (= (cdr (assoc 0 elst)) "HATCH")
    (progn
      (setq
descr (strcat "\n*" (cdr (assoc 2 elst)))
rot   (cdr (assoc 52 elst))
scale (/ 1.0 (cdr (assoc 41 elst)))
nb    (cdr (assoc 78 elst))
first T
      )
      (repeat nb
(setq elst  (member (assoc 53 elst) elst)
      ang   (cdar elst)
      descr
    (strcat descr
    "\n"
    (angtos (- ang rot) 0 14)
    )
      elst  (cdr elst)
)
(repeat 2
  (setq vec
((lambda (a)
    (mxv (list
   (list (cos a) (- (sin a)) 0.0)
   (list (sin a) (cos a) 0.0)
   '(0.0 0.0 1.0)
)
(list (* scale (cdar elst))
       (* scale (cdadr elst))
       0.0
)
    )
  )
   (if first
     (- rot)
     (- ang)
   )
)
  )
  (setq first nil)
  (setq descr (strcat descr
      ","
      (rtos (car vec) 2 14)
      ","
      (rtos (cadr vec) 2 14)
      )
elst  (cddr elst)
  )
)
(repeat (cdr (assoc 79 elst))
  (setq elst (cdr elst))
  (setq descr (strcat descr
      ","
      (rtos (* scale (cdar elst)) 2 14)
      )
  )
)
(setq first T)
      )
      (textscr)
      (princ descr)
      (initget "Yes No")
      (if (and
    (= (getkword
"\nSave in a file ? [Yes/No] <No>: "
       )
       "Yes"
    )
    (setq file (getfiled "Select a file"
(if (= (getvar "measurement") 1)
   (findfile "acadiso.pat")
   (findfile "acad.pat")
)
"pat"
33
       )
    )
  )
(progn
  (setq file (open file "a"))
  (princ (strcat (substr descr 2) "\n") file)
  (close file)
)
      )
      (graphscr)
    )
    (T (prompt "\nSelected entity is not a hatch."))
  )
  (setvar "dimzin" zindim)
  (setq *error* m:err
m:err nil
  )
  (princ)
)
Speaking English as a French Frog

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: create a code out the hatch.
« Reply #12 on: December 06, 2007, 08:51:06 AM »
Thanks gile.
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.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: create a code out the hatch.
« Reply #13 on: December 06, 2007, 08:55:16 AM »
but its for free ... we can use it personally.

I don't refute that.

However, this does not relieve us of the duty to treat Paul honorably. When posting code authored by others, in particular those that are not members of the swamp, it would be best to get permission to post prior to posting, acknowledge same was performed in the post. Eliminates potential problems and gives proper attribution to the author.

I contacted Paul Turvill. He said as long as the commented header is left fully intact all is good.

Thanks all.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: create a code out the hatch.
« Reply #14 on: December 06, 2007, 09:08:10 AM »
Oops, I zapped the code leaving the header & a link to the code. :police:
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.