How to make this pause work

How to make this pause work

murmanator
Advocate Advocate
1,888 Views
13 Replies
Message 1 of 14

How to make this pause work

murmanator
Advocate
Advocate

Hello, Im trying to insert a command pause in between two snap functions in the middle of a pline command. The idea is to allow the user to make as many or as few clicks between the snaps. This is the entire program, you can see the 2 commented out lines that did not work. I fell like Im missing something between the command pause and the second "_CEN" thing.

 

(DEFUN C:RAWL()
(GV)
(COMMAND "-LAYER" "SET" "RUNS" "" "" "")
(COMMAND "-color" "143" "-linetype" "SET" "R_AWL" "")
(COMMAND "PLINE" "_CEN"
;(while (> (getvar "CMDACTIVE") 0) (command pause))
;(while (eq 1 (logand 1 (getvar "CMDACTIVE")))(command pause)
"_CEN" pause)
(while (> (getvar "CMDACTIVE") 0) (command pause))
(LM:QuickField "Length" "%lu2%pr1%ps[Length:,]%ct8[0.08333333]" 3)
(command "-linetype" "set" "Bylayer" "")
(SV)
(princ)
)

 

At first I tried this and it works but only for a single click and I need the flexibility to have a varying number of clicks between snaps

(COMMAND "PLINE" "_CEN" pause "_CEN" pause )

0 Likes
Accepted solutions (1)
1,889 Views
13 Replies
Replies (13)
Message 2 of 14

ВeekeeCZ
Consultant
Consultant

@murmanator wrote:

Hello, Im trying to insert a command pause in between two snap functions in the middle of a pline command. The idea is to allow the user to make as many or as few clicks between the snaps. This is the entire program, you can see the 2 commented out lines that did not work. I fell like Im missing something between the command pause and the second "_CEN" thing.

 

(DEFUN C:RAWL( / osm)
(GV)
(COMMAND "-LAYER" "SET" "RUNS" "" "" "")
(COMMAND "-color" "143" "-linetype" "SET" "R_AWL" "")

(setq osm (getvar 'osmode))

(setvar 'osmode 4)
(COMMAND-s "PLINE")

(setvar 'osmode osm)
(LM:QuickField "Length" "%lu2%pr1%ps[Length:,]%ct8[0.08333333]" 3)
(command "-linetype" "set" "Bylayer" "")
(SV)
(princ)
)

 

At first I tried this and it works but only for a single click and I need the flexibility to have a varying number of clicks between snaps

(COMMAND "PLINE" "_CEN" pause "_CEN" pause )


 

0 Likes
Message 3 of 14

murmanator
Advocate
Advocate

I hadnt thought of using osmode for this and Im not sure it will work overall. I have about 30 of these programs and they all dont go center/center. Some of them go center/end, mid/end and so on. Can we change the osmode in the middle of the pline command? 

 

Also I couldnt seem to get this to work right. It dropped right into a pline starting from the closest center point without me clicking anywhere.

0 Likes
Message 4 of 14

ВeekeeCZ
Consultant
Consultant

If you have some old acad use one of your lines using the cmdactive. -- I guess the _cen override was the culprit of your issues in the first place.

 
0 Likes
Message 5 of 14

Kent1Cooper
Consultant
Consultant

@murmanator wrote:

.... Im trying to insert a command pause in between two snap functions in the middle of a pline command. The idea is to allow the user to make as many or as few clicks between the snaps. ....


If you mean an indeterminate number of picks to which the CENter Osnap does not  apply as desired, between two picks to which it does  apply, how is the routine supposed to know when you've picked as many as you want, and to feed in CENter Osnap for the next one?

 

The CMDACTIVE check can't accomplish that -- it keeps waiting until the entire command is completed, which is not as you describe if this is all inside one PLINE command.

 

I don't know of a way to do what you want [if I understand it correctly], in an automated way.  I suspect you will just need to have the routine feed in the Osnap mode for the first pick, go around making your other picks, and call for the Osnap yourself when you get to where you need it again.

Kent Cooper, AIA
0 Likes
Message 6 of 14

murmanator
Advocate
Advocate

Thanks for your input, Kent. Yes, you understand what Im going for. The first pick is snap to center, then an indeterminate number of picks, then the last pick is snap to center, or mid or whatever. Is there a way to do it by setting the osnap mode within the pline command? It seems to me that if you changed the osnap mode after the first pick it would be ready for the last pick, and all the other picks in between can just be in space somewhere (not snapped). I made a few attempts at this but couldnt nail it down.

 

(COMMAND "PLINE" pause (setvar 'osmode 4) pause (setvar 'osmode 1) pause)

0 Likes
Message 7 of 14

Kent1Cooper
Consultant
Consultant

@murmanator wrote:

.... The first pick is snap to center, then an indeterminate number of picks, then the last pick is snap to center, or mid or whatever. Is there a way to do it by setting the osnap mode within the pline command? .... if you changed the osnap mode after the first pick it would be ready for the last pick, and all the other picks in between can just be in space somewhere (not snapped). ....


The indeterminacy is the problem.  You can change the setting inside the command, but it can't be "ready for the last pick" when it has no way of knowing when that arrives, without your informing it in some way.  So instead of doing whatever it takes to do that, you may as well just call for the Osnap yourself when you get to that point.

 

The only way I can imagine to do it is a two-stage approach:  A routine could start PLINE and call for the Osnap for the first pick, turn off Osnap, then have a prompt built in asking you continue picking but to hit Enter when you're ready for the next pick to be the last  with the designated Osnap mode.  That Enter would actually end  the first PLINE command, and then it could start another, from the last point, call up the Osnap mode and let you pick, end that second PLINE command, and then JOIN the second Polyline to the first.  Does that sound worth pursuing?

Kent Cooper, AIA
0 Likes
Message 8 of 14

murmanator
Advocate
Advocate

It sounds worth pursuing, however all that is way beyond my capabilities. Im concerned its too big an ask, as I wont be able to contribute much. If you are up for it, lets do it. If not I understand and thank you again for your input.

0 Likes
Message 9 of 14

Kent1Cooper
Consultant
Consultant
Accepted solution

Minimally tested and in simplest terms:

 

(defun C:PLCXC (/ pl); = PolyLine CENter-to-[whatever]-to-CENter
  (command "_.pline" "_cen" pause); for first pick
  (while (> (getvar 'cmdactive) 0)
    (prompt "\nContinue Polyline and press ENTER when ready for last CENter-Osnap point: ")
    (command pause)
  ); while
  (setq pl (entlast))
  (command
    "_.pline" "@" "_cen" pause ""
    "_.join" pl (entlast) ""
  ); command
  (princ)
); defun

 

It lets you keep other running Osnap modes that you may have on, for other picks between the beginning and end, restricting it to CENter only for the first and last.  If you don't want that, it could be made to turn Osnap off for the in-between picks, instead.

 

You can do all the options in the Polyline [look for its prompt above the one supplied by the routine], including widths and arc segments.  But if you finish the first one with an arc segment, the second one will still be a line segment, so the result will not be a continuation as an arc segment as if it had been drawn all in one.  If you need that, it could probably be accounted for.

Kent Cooper, AIA
0 Likes
Message 10 of 14

murmanator
Advocate
Advocate

Yeah! That works the charm. I dont need arcs for this, we just use plines. Thank you so much, Kent. Very much appreciated.

0 Likes
Message 11 of 14

Sea-Haven
Mentor
Mentor

You can osmode to any combination you like so you could just set it to CEN MID END, these are discreet enough to not pick wrong point. osmode 7

 

0 Likes
Message 12 of 14

Kent1Cooper
Consultant
Consultant

@Sea-Haven wrote:

You can osmode to any combination you like so you could just set it to CEN MID END, these are discreet enough to not pick wrong point. ….


[That would often not be the case with an Arc or a partial Ellipse or a Polyline arc segment.  Depending on the amount of angle it swings through, when the Osnap aperture is touching the curve itself, one endpoint or the other or the midpoint will very often be closer to the cursor location than the center is, and will therefore be what it snaps to.]

Kent Cooper, AIA
0 Likes
Message 13 of 14

ВeekeeCZ
Consultant
Consultant

Give a try to this adjusted version of Kents routine.

 

The code use a permanent osmode setting which leaves you an ability to set any of the temporary override osmode anytime you need. Unlike hardcoded "_cen"...

 

The commented code is just a starting point for you to be able to adjust that as you think will work best for you.

 

(defun c:RAWL (/ *error* osm pl)

    (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (if osm (setvar 'osmode osm))	; restore osmode if anything goes wrong (inc. ESC)
    (princ))

  ; -----------------------------------------------------------------------------------------
  
  (setq osm (getvar 'osmode))

  (setvar 'osmode (+ 1 2 4)) 		; end+mid+cen for 1st pnt
  (command "_.pline" pause) 		; 1st point
  (setvar 'osmode (boole 7 osm 16384)) 	; restore original osmode and turn off for mid-pnts
  
  (while (> (getvar 'cmdactive) 0)	; all mid points - you still can use any of PLINE options by typing a key letters. (not clickable anymore)
    (prompt "<last point>: ")		; is this prompt needed? if you remove this options of PLINE stay clickable (try the alternative placement prior to the last input).
    (command pause))
  (setq pl (entlast))

  (setvar 'osmode (+ 1 2 4)) 		; end+mid+cen for last point
  (command "_.pline" "@")
  ;(prompt "\nLast point: ")		; (2) alternative
  (command pause ""
	   "_.join" pl (entlast) "")

  (setvar 'osmode osm)			; restore original osmode
  (princ)
)

 Also, experiment with the placement of the last point prompt - if that's necessary to have.

0 Likes
Message 14 of 14

murmanator
Advocate
Advocate

Thank you Z9. I have not had a chance to try it out yet but will. My team really wanted the hard code snap thing, it has been working for us so far. Thanks again

0 Likes