Stuck in loop

Stuck in loop

DC-MWA
Collaborator Collaborator
1,979 Views
11 Replies
Message 1 of 12

Stuck in loop

DC-MWA
Collaborator
Collaborator

Hi all,

Working on a little routine for drawing finishes. I can't seem to get out of loop cleanly. Also I'm having trouble with layer set portion.

Can someone push me in the right direction with this?

What am I missing?

 

-dc

0 Likes
Accepted solutions (2)
1,980 Views
11 Replies
Replies (11)
Message 2 of 12

dlanorh
Advisor
Advisor
(setq e 3)
(setq pt1 (getpoint "\nPICK FIRST POINT <finish will be place on right>: "))
(while e

Why is e being set to 3? 

 

Since it will always be 3 (it is never reset or changed), the while loop will never end.

 

perhaps

 

(while (setq pt2 (getpoint "\nPICK NEXT POINT: "  pt1 ))

and after
(setq pt1 pt2)
(setq pt2 nil)

This way pressing return instead of picking a point will end the while loop

I am not one of the robots you're looking for

0 Likes
Message 3 of 12

DC-MWA
Collaborator
Collaborator

If I remove the (setq e 3) it crashes.

If I try the new while location, it loses the fillet function?

0 Likes
Message 4 of 12

dlanorh
Advisor
Advisor
Accepted solution
(while (setq pt2 (getpoint "\nPICK NEXT POINT: "  pt1 ))
(setvar "osmode" 0)
(if (/= pt3 nil) (setq f1 pt3)) (if (> c 1) (setq f1 (polar pt3 a W))) ;---------- (setq c (+ c 1)) (setq a (angle pt1 pt2)) (setq pt3 (polar pt1 (- a (dtr 90)) W)) (setq pt4 (polar pt2 (- a (dtr 90)) W)) (command "line" pt3 pt4 "") (setq f2 (polar pt2 (- a (dtr 90)) W)) (setq pt1 pt2) (if (/= f1 nil) (command "._fillet" f1 f2))
(setvar "osmode" 1) (setq pt2 nil) )

As far as I can see the e is redundant as it is set and then always tests true for the while statement. It isn't used anywhere else, hence the question, were you going to use it for something else.

 

I didn't mean change the while location, just the test. See red above. Unless I'm missing something, I can't see a reason why the (getpoint) can't be moved up and used to test the while. If there is a new point, it will continue, if not it will reset sysvars and end. I've shuffled the (setvar "osmode" ..) about so that they still work with the getpoint.

I am not one of the robots you're looking for

0 Likes
Message 5 of 12

ВeekeeCZ
Consultant
Consultant

Would you post some image to see what you're after? Can't you simply draw a polyline and offset that with Erase option on?

0 Likes
Message 6 of 12

DC-MWA
Collaborator
Collaborator

That works. Thank you.

Any thoughts on the layer portion?

 

 

0 Likes
Message 7 of 12

Kent1Cooper
Consultant
Consultant
Accepted solution

On the Layer part, you can do this:


(setq Curlay

  (if (setq layent (car (entsel "\nSelect Object to set Layer <0>: ")))

    (cdr (assoc 8 (entget layent))); then

    "0" ; else

  ); if

); setq

Kent Cooper, AIA
Message 8 of 12

DC-MWA
Collaborator
Collaborator

Perfect.

Thank you. As always, you guys make it seem simple.

0 Likes
Message 9 of 12

ВeekeeCZ
Consultant
Consultant

Just for fun - a bit different approach.

 

(defun c:fin ( / olay oosm e)
  
  (setq olay (getvar 'clayer)
	oosm (getvar 'osmode))
  
  (setvar 'clayer (if (setq e (car (entsel "\nSelect object for Layer <0>:  ")))
		    (cdr (assoc 8 (entget e)))
		    (progn (command "_.layer" "_t" "0" "") "0")))
  
  (or *w
      (setq *w 1.))
  
  (setq *w (cond ((getdist (strcat "\nFinish Thickness <" (rtos *w) ">: ")))
		 (*w)))
  
  (setvar 'osmode 1)
  (command-s "_.mline" "_J" "_B" "_S" *w "_Style" "STANDARD")
  (command "_.explode" "_l")
  (initcommandversion)
  (command "_join" "_p" ""
	   "_.erase" "_l" "")
  
  (setvar 'clayer olay)
  (setvar 'osmode oosm)
  (princ)
  )
0 Likes
Message 10 of 12

Kent1Cooper
Consultant
Consultant

Another suggestion that could simplify it a whole lot more:  Instead of a series of Lines, and requiring the routine to figure out where to pick on them to Fillet the corners, remember where it was with the last one, etc., just draw a Polyline, and Offset it once -- the corners will all be taken care of.  A lot fewer variables, virtually no calculation of anything, etc., etc.

 

(command "_.pline")

(while (> (getvar 'cmdactive) 0) (command pause)); let User complete the Polyline edge

(command "_.offset" ....

 

You can build the Erase-the-original option into the Offset command if you like, or explicitly Erase the source edge.  You can Explode the result if you want it to be separate Lines in the end.  And you can build in figuring out which way to Offset if  you still want to instruct the User about which way it will go, but you could instead leave it to the User to designate a side, so they don't have to do the edge in a particular direction.

Kent Cooper, AIA
0 Likes
Message 11 of 12

DC-MWA
Collaborator
Collaborator

Interesting. It works pretty well. 

0 Likes
Message 12 of 12

DC-MWA
Collaborator
Collaborator

hhmmm

0 Likes