TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: ScottMC on September 14, 2021, 12:47:37 PM
-
Trying to simplify region creation and knew pline would be different..
Hope to see a way to avoid point-limit as NOT with this:
All suggestions are helpful.
(defun c:prg ()
(princ "\n Polyline Region..")
(vl-cmdf "pline" "\\" "\\" "\\" "\\") ;; << draw polyline - 4 points.. :(
(command)
(vl-cmdf "pedit" "L" "C" "") ;; close pline
(princ)
(vl-cmdf "region" "L" "")
(princ)
)
(c:prg)
-
ScottMC,
This will work for your scenario I believe.
The inclusion of a "command-s" call is NOT advised in 99% of cases (because it continues the routine), but for the exact scenario you describe, it will work if implemented this way.
(defun c:PRG ( / e)
(setq e (entlast))
(command-s "_.PLINE")
(if (not (equal e (entlast)))
(command "_.REGION" "l" "")
);if
(princ)
);defun
Best,
~DD
-
Similar but will close the pline so you don't have to in the command call :)
-
If I call; "(setq e (entlast)) then (progn (entmod (append (entget e) '((70 . 1)))) (command "_.REGION" "l" "")) <- it works! so I'm gonna try and work these in..
Y'all got permission to avoid me as my version is a2k.. this knocks out some commands as y'all know. Still, I find it [this function] helpful but know even having my limits, there's a more inviting way to work pline and region together.
Here's the others that are EASY..
(defun c:rrg ()
(princ "\n Rectangle -> Region..")
(vl-cmdf "rectang" pause pause)
(vl-cmdf "region" "L" "")
(command "erase" "P" "")
(princ)
)
(defun c:crg ()
(setvar 'cmdecho 0)
(princ "\n Circle Radius -> Region..")
(vl-cmdf "circle" pause pause)
(vl-cmdf "region" "L" "")
(command "erase" "P" "")
(setvar 'cmdecho 1)
(princ)
)
(defun c:2rg ()
(setvar 'cmdecho 0)
(princ "\n 2 Point Circle -> Region..")
(vl-cmdf "circle" "2P" pause pause)
(vl-cmdf "region" "L" "")
(command "erase" "P" "")
(setvar 'cmdecho 1)
(princ)
)
(defun c:3rg ()
(setvar 'cmdecho 0)
(princ "\n 3 Point Circle -> Region..")
(vl-cmdf "circle" "3P" pause pause)
(vl-cmdf "region" "L" "")
(command "erase" "P" "")
(setvar 'cmdecho 1)
(princ)
)
-
Works but, with it like this, it's my choice on the number of vertices. Works but if picking less than 4 it requires an "enter".
(defun c:prg (/ e)
(vl-load-com)
(setq e (entlast))
(command "_.PLINE" "\\" "\\" "\\" "\\" "\\") ;; just one more..
(command)
(setq e (entlast))
;(if (and (not (equal e (setq e (entlast)))) (> (cdr (assoc 90 (entget e))) 2))
(progn (entmod (append (entget e) '((70 . 1)))) (command "_.REGION" "l" "")) ;; nice! - thanks ronjonp
(command )
(vl-cmdf "Erase" "P" "")
(vl-cmdf "_regenall")
(princ)
)
(c:prg)
-
This last statement you made...
Works but, with it like this, it's my choice on the number of vertices.
.....
...directly contradicts your original request...
.....
Hope to see a way to avoid point-limit as NOT with this:
.....
(vl-cmdf "pline" "\\" "\\" "\\" "\\") ;; << draw polyline - 4 points.. :(
.....
Hope you got what you needed though.
Best,
~DD
-
I'd rather it work as a normal pline for creating, but mine doesn't have command-s :(. Been without it and some others since-day-1 with 13c4 w/3-1/2" floppy. This ability would be helpful. Else-wise if there's any other code testing needed, please include me.
-
ScottMC,
...but mine doesn't have command-s :(...
Oh, so you can not run the command-s function? What CAD software are you running then? What year/version?
Does this suit you better?
(defun c:PRG ( / e)
(setq e (entlast))
(command "_.PLINE")
(while (> (getvar 'CMDACTIVE) 0)
(command pause)
);while
(if (not (equal e (entlast)))
(command "_.REGION" "l" "")
);if
(princ)
);defun
Best,
~DD
-
.. 2000! And Mega thanks for getting/sending me that code as it WORKS!! God Bless you.