TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: V-Man on May 05, 2011, 12:00:05 PM
-
The following code works in 2008 but not in 2010. Any ideas?
(setq ss (ssget "X" '((0 . "LWPOLYLINE")(8 . "0")(70 . 1))));0=Type , 8=Layer Name , 70=lypolylines closed only
(if (= ss nil)
(alert "There are NO LwPolylines!")
)
(if ss
(repeat (setq n (sslength ss))
(setq n (1- n))
(command ".-hatch" "p" "HONEY" "140" "" (ssname ss n) "")
)
)
-
I don't have 2010 installed, but the code looks ok ...
Have you tried to step through the code one line at a time?
Where does it specifically fail?
-
Here is what I get when stepping through code.
Command: (setq ss (ssget "X" '((0 . "LWPOLYLINE")(8 . "0")(70 . 1))))
<Selection set: 69f3>
Command: (repeat (setq n (sslength ss))
(_> (setq n (1- n))
(_> (command ".-hatch" "p" "HONEY" "140" "" (ssname ss n) "")
(_> )
2D point or option keyword required.
; error: Function cancelled
Specify internal point or [Properties/Select objects/draW boundary/remove
Boundaries/Advanced/DRaw order/Origin/ANnotative]: *Cancel*
-
Hi, maybe some change in the hatch command option.
Look ŕ the the error reported on command line, it's often helpfull to debug issues with the 'command' function...
(command "_.hatch" "HONEY" "140" "" (ssname ss n) "") works with A2011.
-
That is exactly what I was going to suggest. It looks like "" might need to be changed to "S"
(command "_.hatch" "HONEY" "140" "S" (ssname ss n) "")
-
I allways use
(setq ss (ssget "X" '((0 . "LWPOLYLINE")(8 . "0")(-4 . "<OR")(70 . 1)(70 . 129)(-4 . "OR>"))))
because plinegen could be 1 instead 0 when then the polyline was created...
-
I allways use
(setq ss (ssget "X" '((0 . "LWPOLYLINE")(8 . "0")(-4 . "<OR")(70 . 1)(70 . 129)(-4 . "OR>"))))
because plinegen could be 1 instead 0 when then the polyline was created...
True, by my side, I'd rather use the "&" operator:
(setq ss (ssget "X" '((0 . "LWPOLYLINE") (8 . "0") (-4 . "&") (70 . 1))))
-
Thanks to everyone.
The reason I placed a hyphen there in front of the command is for whatever reason, I have 1 machine the code does not work. The code pulls up the hatch dialog box. All other machines the code works fine.
Thanks...
-
If you use -hatch instead of hatch and change your HPSEPARATE variable, you don't have to step through the selectionset.
eg.
(defun c:test (/ ov vl ss)
(setq ov (mapcar 'getvar (setq vl '("CMDECHO" "HPSCALE" "HPNAME" "HPSEPARATE"))))
(mapcar 'setvar vl '(0 140. "HONEY" 1))
(if (setq ss (ssget "_X"
'((0 . "LWPOLYLINE")
(8 . "0")
(-4 . "<OR")
(70 . 1)
(70 . 129)
(-4 . "OR>")
)
)
)
(command "_.-hatch" "_S" ss "" "_A" "_H" "_Y" "" "")
)
(mapcar 'setvar vl ov)
(princ)
)