Code Red > AutoLISP (Vanilla / Visual)

Clean way to use "pline" for multi [#?] points w/arc,second,undo?

(1/2) > >>

ScottMC:
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)

CodeDing:
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.


--- Code: ---(defun c:PRG ( / e)
  (setq e (entlast))
  (command-s "_.PLINE")
  (if (not (equal e (entlast)))
    (command "_.REGION" "l" "")
  );if
  (princ)
);defun

--- End code ---

Best,
~DD

ronjonp:
Similar but will close the pline so you don't have to in the command call :)

--- Code - Auto/Visual Lisp: ---(defun c:prg (/ e)  (setq e (entlast))  (command-s "_.PLINE")  (if (and (not (equal e (setq e (entlast)))) (> (cdr (assoc 90 (entget e))) 2))    (progn (entmod (append (entget e) '((70 . 1)))) (command "_.REGION" "l" ""))  )  (princ))

ScottMC:
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)
)

ScottMC:
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)

Navigation

[0] Message Index

[#] Next page

Go to full version