GỘP 2 MẪU HATCH LẠI VỚI NHAU
- Mỗi lần bạn sử dụng một mẫu hatch, bạn phải sử dụng 2 hatch chập nhau. Ví dụ như khi bạn sử dụng hatch bê tông cốt thép, bạn phải sử dụng nét chéo (LINE) và nét gạch vỡ (AR-CONC). Làm sao để bạn nối 2 mẫu hatch này lại thành 1 mẫu mới?
- Bạn tạo 1 file mới có tên trùng với tên mẫu hatch mà bạn đặt với đuôi là .pat. Ví dụ: BE_TONG.PAT.
Bạn mở file Acad.pat trong thư mục support ra, tìm đoạn mà cad mô tả về gạch vỡ, copy vào file mới này, tìm đoạn cad mô tả về Line, copy vào tiếp. Save lại, sử dụng lệnh hatch là ok.
- Ví dụ:
*AR-CONC, Random dot and stone pattern
50, 0,0, 4.12975034,-5.89789472, 0.75,-8.25
355, 0,0, -2.03781207,7.37236840, 0.60,-6.6
100.4514, 0.5977168,-0.0522934, 5.7305871,-6.9397673, 0.6374019,-7.01142112
46.1842, 0,2, 6.19462551,-8.84684208, 1.125,-12.375
96.6356, 0.88936745,1.86206693, 8.59588071,-10.40965104, 0.95610288,-10.51713
351.1842, 0,2, 7.74328189,11.0585526, 0.9,-9.9
21, 1,1.5, 4.12975034,-5.89789472, 0.75,-8.25
326, 1,1.5, -2.03781207,7.37236840, 0.60,-6.6
71.4514, 1.49742233,1.16448394, 5.7305871,-6.9397673, 0.6374019,-7.01142112
37.5, 0,0, 2.123,2.567, 0,-6.52,0,-6.7,0,-6.625
7.5, 0,0, 3.123,3.567, 0,-3.82,0,-6.37,0,-2.525
-32.5, -2.23,0, 4.6234,2.678, 0,-2.5,0,-7.8,0,-10.35
-42.5, -3.23,0, 3.6234,4.678, 0,-3.25,0,-5.18,0,-7.35
gộp với:
*LINE, Parallel horizontal lines
0, 0,0, 0,.125
thành:
*BE_TONG, Random dot and stone pattern
50, 0,0, 4.12975034,-5.89789472, 0.75,-8.25
355, 0,0, -2.03781207,7.37236840, 0.60,-6.6
100.4514, 0.5977168,-0.0522934, 5.7305871,-6.9397673, 0.6374019,-7.01142112
46.1842, 0,2, 6.19462551,-8.84684208, 1.125,-12.375
96.6356, 0.88936745,1.86206693, 8.59588071,-10.40965104, 0.95610288,-10.51713
351.1842, 0,2, 7.74328189,11.0585526, 0.9,-9.9
21, 1,1.5, 4.12975034,-5.89789472, 0.75,-8.25
326, 1,1.5, -2.03781207,7.37236840, 0.60,-6.6
71.4514, 1.49742233,1.16448394, 5.7305871,-6.9397673, 0.6374019,-7.01142112
37.5, 0,0, 2.123,2.567, 0,-6.52,0,-6.7,0,-6.625
7.5, 0,0, 3.123,3.567, 0,-3.82,0,-6.37,0,-2.525
-32.5, -2.23,0, 4.6234,2.678, 0,-2.5,0,-7.8,0,-10.35
-42.5, -3.23,0, 3.6234,4.678, 0,-3.25,0,-5.18,0,-7.35
45, 0,0, 0,1.25
Chú ý:cuối file BE_TONG.PAT này phải có một dòng trống.
coppy file be_tong.pat này vào thư mục support trong cad xong vào hatch/custom trong cad để lấy mẫu này
Hoặc có thể dùng lisp tạo hatch sau
đánh drawhatch để tạo sau khi tạo xong thì đánh savehatch
;;;CADALYST 10/05 Tip 2065: HatchMaker.lsp Hatch Maker (c) 2005 Larry Schiele
;;;* ====== B E G I N C O D E N O W ======
;;;* HatchMaker.lsp written by Lanny Schiele at TMI Systems Design Corporation
;;;*
Lanny.Schiele@tmisystems.com;;;* Tested on AutoCAD 2002 & 2006. -- does include a 'VL' function -- should work on Acad2000 on up.
(defun C:DrawHatch (/)
(command "undo" "be")
(setq os (getvar "OSMODE"))
(setvar "OSMODE" 0)
(command "UCS" "w")
(command "PLINE" "0,0" "0,1" "1,1" "1,0" "c")
(command "zoom" "c" "0.5,0.5" 1.1)
(setvar "OSMODE" os)
(setvar "SNAPMODE" 1)
(setvar "SNAPUNIT" (list 0.01 0.01))
(command "undo" "e")
(alert
"Draw pattern within 1x1 box using LINE or POINT entities only..."
)
(princ)
)
(defun C:SaveHatch (/ round dxf ListToFile
user SelSet SelSetSize ssNth
Ent EntInfo EntType pt1 pt2
Dist AngTo AngFrom XDir YDir
Gap DeltaX DeltaY AngZone Counter
Ratio Factor HatchName HatchDescr
FileLines FileLines FileName
Scaler ScaledX ScaledY RF x
y h _AB _BC _AC
_AD _DE _EF _EH _FH
DimZin
)
;;;* BEGIN NESTED FUNCTIONS
(defun round (num)
(if (>= (- num (fix num)) 0.5)
(fix (1+ num))
(fix num)
)
)
(defun dxf (code EnameOrElist / VarType)
(setq VarType (type EnameOrElist))
(if (= VarType (read "ENAME"))
(cdr (assoc code (entget EnameOrElist)))
(cdr (assoc code EnameOrElist))
)
)
(defun ListToFile (TextList FileName DoOpenWithNotepad
AsAppend / TextItem
File RetVal
)
(if (setq File (open FileName
(if AsAppend
"a"
"w"
)
)
)
(progn
(foreach TextItem TextList
(write-line TextItem File)
)
(setq File (close File))
(if DoOpenWithNotepad
(startapp "notepad" FileName)
)
)
)
(FindFile FileName)
)
;;;* END NESTED FUNCTIONS
(princ
(strcat
"\n."
"\n 0,1 ----------- 1,1"
"\n | | "
"\n | Lines and | "
"\n | points must | "
"\n | be snapped | "
"\n | to nearest | "
"\n | 0.01 | "
"\n | | "
"\n 0,0 ----------- 1,0"
"\n."
"\nNote: Lines must be drawn within 0,0 to 1,1 and lie on a 0.01 grid."
)
)
(textscr)
(getstring "\nHit [ENTER] to continue...")
(princ
"\nSelect 1x1 pattern of lines and/or points for new hatch pattern..."
)
(while (not (setq SelSet (ssget (list (cons 0 "LINE,POINT")))))
)
(setq ssNth 0
SelSetSize (sslength SelSet)
DimZin (getvar "DIMZIN")
)
(setvar "DIMZIN" 11)
(if (> SelSetSize 0)
(princ "\nAnalyaing entities...")
)
(while (< ssNth SelSetSize)
(setq Ent (ssname SelSet ssNth)
EntInfo (entget Ent)
EntType (dxf 0 EntInfo)
ssNth (+ ssNth 1)
)
(cond
((= EntType "POINT")
(setq pt1 (dxf 10 EntInfo)
FileLine (strcat "0,"
(rtos (car pt1) 2 6)
","
(rtos (cadr pt1) 2 6)
",0,1,0,-1"
)
)
(princ (strcat "\n" FileLine))
(setq FileLines (cons FileLine FileLines))
)
((= EntType "LINE")
(setq pt1 (dxf 10 EntInfo)
pt2 (dxf 11 EntInfo)
Dist (distance pt1 pt2)
AngTo (angle pt1 pt2)
AngFrom (angle pt2 pt1)
IsValid nil
)
(if
(or (equal (car pt1) (car pt2) 0.0001)
(equal (cadr pt1) (cadr pt2) 0.0001)
)
(setq DeltaX 0
DeltaY 1
Gap (- Dist 1)
IsValid T
)
(progn
(setq Ang (if (< AngTo pi)
AngTo
AngFrom
)
AngZone (fix (/ Ang (/ pi 4)))
XDir (abs (- (car pt2) (car pt1)))
YDir (abs (- (cadr pt2) (cadr pt1)))
Factor 1
RF 1
)
(cond
((= AngZone 0)
(setq DeltaY (abs (sin Ang))
DeltaX (abs (- (abs (/ 1.0 (sin Ang))) (abs (cos Ang)))
)
)
)
((= AngZone 1)
(setq DeltaY (abs (cos Ang))
DeltaX (abs (sin Ang))
)
)
((= AngZone 2)
(setq DeltaY (abs (cos Ang))
DeltaX (abs (- (abs (/ 1.0 (cos Ang))) (abs (sin Ang)))
)
)
)
((= AngZone 3)
(setq DeltaY (abs (sin Ang))
DeltaX (abs (cos Ang))
)
)
)
(if (not (equal XDir YDir 0.001))
(progn
(setq Ratio (if (< XDir YDir)
(/ YDir XDir)
(/ XDir YDir)
)
RF (* Ratio Factor)
Scaler (/ 1
(if (< XDir YDir)
XDir
YDir
)
)
)
(if (not (equal Ratio (round Ratio) 0.001))
(progn
(while
(and
(<= Factor 100)
(not (equal RF (round RF) 0.001))
)
(setq Factor (+ Factor 1)
RF (* Ratio Factor)
)
)
(if (and (> Factor 1) (<= Factor 100))
(progn
(setq _AB (* XDir Scaler Factor)
_BC (* YDir Scaler Factor)
_AC (sqrt (+ (* _AB _AB) (* _BC _BC)))
_EF 1
x 1
)
(while (< x (- _AB 0.5))
(setq y (* x (/ YDir XDir))
h (if (< Ang (/ pi 2))
(- (+ 1 (fix y)) y)
(- y (fix y))
)
)
(if (< h _EF)
(setq _AD x
_DE y
_AE (sqrt (+ (* x x) (* y y)))
_EF h
)
)
(setq x (+ x 1))
)
(if (< _EF 1)
(setq _EH (/ (* _BC _EF) _AC)
_FH (/ (* _AB _EF) _AC)
DeltaX (+ _AE
(if (> Ang (/ pi 2))
(- _EH)
_EH
)
)
DeltaY (+ _FH)
Gap (- Dist _AC)
IsValid T
)
)
)
)
)
)
)
)
(if (= Factor 1)
(setq Gap (- Dist (abs (* Factor (/ 1 DeltaY))))
IsValid T
)
)
)
)
(if
IsValid
(progn
(setq FileLine
(strcat
(angtos AngTo 0 6)
","
(rtos (car pt1) 2
","
(rtos (cadr pt1) 2
","
(rtos DeltaX 2
","
(rtos DeltaY 2
","
(rtos Dist 2
","
(rtos Gap 2
)
)
(princ (strcat "\n" FileLine))
(setq FileLines (cons FileLine FileLines))
)
(princ (strcat "\n * * * Line with invalid angle "
(angtos AngTo 0 6)
(chr 186)
" omitted. * * *"
)
)
)
)
((princ
(strcat "\n * * * Invalid entity " EntType " omitted.")
)
)
)
)
(setvar "DIMZIN" DimZin)
(if
(and
FileLines
(setq HatchDescr
(getstring T
"\nBriefly describe this hatch pattern: "
)
)
(setq FileName (getfiled "Hatch Pattern File"
"I:\\Acad\\Hatch\\"
"pat"
1
)
)
)
(progn
(if (= HatchDescr "")
(setq HatchDescr "Custom hatch pattern")
)
(setq HatchName (vl-filename-base FileName)
FileLines (cons (strcat "*" HatchName "," HatchDescr)
(reverse FileLines)
)
)
(princ
"\n============================================================"
)
(princ
(strcat "\nPlease wait while the hatch file is created...\n"
)
)
(ListToFile FileLines FileName nil nil)
(command "delay" 1500) ;delay required so file can be created and found (silly, but req.)
(if (findfile FileName)
(progn
(setvar "HPNAME" HatchName)
(princ (strcat "\nHatch pattern '"
HatchName
"' is ready to use!"
)
)
)
(progn
(princ "\nUnable to create hatch pattern file:")
(princ (strcat "\n " FileName))
)
)
)
(princ
(if FileLines
"\nCancelled."
"\nUnable to create hatch pattern from selected entities."
)
)
)
(princ)
)
(princ "\n ************************************************************** ")
(princ "\n** **")
(princ "\n* HatchMaker.lsp written by Lanny Schiele -- enjoy! *")
(princ "\n* *")
(princ "\n* Type in DRAWHATCH to have the environment created to draw. *")
(princ "\n* Type in SAVEHATCH to save the pattern you created. *")
(princ "\n** **")
(princ "\n ************************************************************** ")
(princ)
Nguồn bài viết :
http://chiennuce.blogspot.com/2016/06/gop-2-mau-hatch-lai-voi-nhau.html