TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: PM on June 30, 2021, 12:47:29 PM
-
Hi i am using this lisp code to hatch buildings , but sudenly stop and dont work in my Autocad 2020 and i don't know why. Can any one help?
(COMMAND "_layer" "_m" "HATCH" "_c" "171" "" "_lw" "0.15" "" "") (if (= SCL
nil)(setq SCL
200)) (if (> SCL
1000.0)(setq SCL
1000)) (if (= d
nil)(setq platos
0.50)) (if (/= d
nil)(setq platos d
)) (setq kl
(- (/ SCL
1000.00)(/ (expt SCL
1.2) 12000.00))) (if (= str
"L")(setq genet
1)) (if (= str
"Left")(setq genet
1)) (if (= str
"R")(setq genet
-1)) (if (= str
"Right")(setq genet
-1))
)
(setq diafora
(+ (- xxa xxt
)( - yya yyt
)))
(setq arshm
(/ (- mhkos
6) 3))
(setq number
(+ number
1)) (command "linetype" "s" "bylayer" "")
(setq xp
(nth (+ (* number
3) -3) lista
)) (setq yp
(nth (+ (* number
3) -2) lista
)) (setq zp
(nth (+ (* number
3) -1) lista
))
(setq xo
(nth (+ (* number
3) 0) lista
)) (setq yo
(nth (+ (* number
3) 1) lista
)) (setq zo
(nth (+ (* number
3) 2) lista
))
(setq xe
(nth (+ (* number
3) 3) lista
)) (setq ye
(nth (+ (* number
3) 4) lista
)) (setq ze
(nth (+ (* number
3) 5) lista
))
(setq xm
(nth (+ (* number
3) 6) lista
)) (setq ym
(nth (+ (* number
3) 7) lista
)) (setq zm
(nth (+ (* number
3) 8) lista
))
(setq gonia1
(/ (+ f1 f2
) 2)) (setq gonia2
(/ (+ v1 v2
) 2))
;left hatch
(setq d2
(* genet platos
))
(setq sin1
(/ ( - f2 f1
) 2)) (setq sin2
(/ ( - v2 v1
) 2))
(setq sin1
(/ ( - f2 f1
) 2)) (setq sin2
(/ ( - v2 v1
) 2))
(setq gv
(+ (* vv
45) (/ (* f2
180) 3.1415926)))
(COMMAND "HATCH" "LINE" kl gv
"" "N" ns1 ns2 sse sso
"close" "") )
(command "linetype" "s" "bylayer" "") )
[/code
Thanks
-
PM,
What does the command history say when you run it? can you post it please?
Best,
~DD
-
the command run but not create hatch. Before the problem i run the command use as default the 0.50 offset pick the points and create a hatch with Hatch scale 0.125. Now is not create the hatch and ask me to select object !!!!!! i can not understand what happend. I didn't change anything in this code
-
If your pattern is too dense you may have to change your maxhatch env.
(setenv "MaxHatch" "1000000")
Something like that.
-
Can you post your Command History when you run the command please.. That would provide some useful insight.
I've tried to run your command a handful of times and do not understand how your command works. I don't want to read your code Line-By-Line to understand it.
Please post the command history.
-
Try this will need a couple of changes like offset value and hatch settings, supports the boundary is on more than 1 layer eg sides & back may be different to front.
; hatch a strip inside a closed area
; By AlanH July 2021
(defun c:hatstrip ( / off ss lays x pt pt2 ent1 ent2 co-ord oldsnap oldlay)
(setq off 1.0
oldsnap (getvar 'osmode)
oldlay (getvar 'clayer))
(if (not (tblsearch "Layer" "HATCH"))
(COMMAND "_layer" "_m" "HATCH" "_c" "171" "" "_lw" "0.15" "" "")
)
(prompt "\nPick objects for outside 1 is ok more for multi layer ")
(if (setq ss (ssget))
(progn
(command "layiso" ss "")
(setvar 'osmode 0)
(setq pt (getpoint "\nPlease pick point inside"))
(command "bpoly" pt "")
(setq ent1 (entlast))
(setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (entlast)))))
(setq pt2 (polar (nth 0 co-ord) (angle (nth 0 co-ord) pt) (/ off 2.0)))
(command "offset" 10.0 ent1 pt "")
(setq ent2 (entlast))
(setvar 'Clayer "HATCH")
(command "-hatch" "P" "ANSI31" 1 0 pt2 "")
(command "erase" ent1 ent2 "")
(command "layuniso")
)
)
(setvar 'osmode oldsnap)
(setvar 'clayer oldlay)
(princ)
)
(c:hatstrip)