Author Topic: Clean way to use "pline" for multi [#?] points w/arc,second,undo?  (Read 245 times)

0 Members and 1 Guest are viewing this topic.

ScottMC

  • Newt
  • Posts: 87
  • ...if we don't ask, we won't receive..
Clean way to use "pline" for multi [#?] points w/arc,second,undo?
« 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)

CodeDing

  • Newt
  • Posts: 24
Re: Clean way to use "pline" for multi [#?] points w/arc,second,undo?
« Reply #1 on: September 14, 2021, 02:41:52 PM »
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: [Select]
(defun c:PRG ( / e)
  (setq e (entlast))
  (command-s "_.PLINE")
  (if (not (equal e (entlast)))
    (command "_.REGION" "l" "")
  );if
  (princ)
);defun

Best,
~DD

ronjonp

  • Needs a day job
  • Posts: 7327
Re: Clean way to use "pline" for multi [#?] points w/arc,second,undo?
« Reply #2 on: September 14, 2021, 03:45:07 PM »
Similar but will close the pline so you don't have to in the command call :)
Code - Auto/Visual Lisp: [Select]
  1. (defun c:prg (/ e)
  2.   (setq e (entlast))
  3.   (command-s "_.PLINE")
  4.   (if (and (not (equal e (setq e (entlast)))) (> (cdr (assoc 90 (entget e))) 2))
  5.     (progn (entmod (append (entget e) '((70 . 1)))) (command "_.REGION" "l" ""))
  6.   )
  7.   (princ)
  8. )

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

ScottMC

  • Newt
  • Posts: 87
  • ...if we don't ask, we won't receive..
Re: Clean way to use "pline" for multi [#?] points w/arc,second,undo?
« Reply #3 on: September 14, 2021, 04:29:17 PM »
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)
)
« Last Edit: September 14, 2021, 05:01:03 PM by ScottMC »

ScottMC

  • Newt
  • Posts: 87
  • ...if we don't ask, we won't receive..
Re: Clean way to use "pline" for multi [#?] points w/arc,second,undo?
« Reply #4 on: September 14, 2021, 05:14:52 PM »
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)
« Last Edit: September 15, 2021, 12:46:42 PM by ScottMC »

CodeDing

  • Newt
  • Posts: 24
Re: Clean way to use "pline" for multi [#?] points w/arc,second,undo?
« Reply #5 on: September 14, 2021, 05:47:41 PM »

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

ScottMC

  • Newt
  • Posts: 87
  • ...if we don't ask, we won't receive..
Re: Clean way to use "pline" for multi [#?] points w/arc,second,undo?
« Reply #6 on: September 14, 2021, 06:00:43 PM »
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.
« Last Edit: September 15, 2021, 12:44:03 PM by ScottMC »

CodeDing

  • Newt
  • Posts: 24
Re: Clean way to use "pline" for multi [#?] points w/arc,second,undo?
« Reply #7 on: September 15, 2021, 03:43:11 PM »
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?
Code: [Select]
(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

ScottMC

  • Newt
  • Posts: 87
  • ...if we don't ask, we won't receive..
Re: Clean way to use "pline" for multi [#?] points w/arc,second,undo?
« Reply #8 on: September 15, 2021, 04:17:23 PM »
.. 2000! And Mega thanks for getting/sending me that code as it WORKS!! God Bless you.