Jump to content

Recommended Posts

Posted

hi

 

i follow this code , it operate the same way the fens selection mode would,

 

i got it all except 2 things ,

 

(grread 5) , what 5 stands for? (didnt understand the docs)

what makes PT to get nil? (as it terminate the program main loop)

 

(defun VECTORS (/ PT PTLIST)
 ; Sequential choice of points
 ; by ElpanovEvgeniy
 ; (2005-10-19 17:59:01)
 ; (VECTORS)
 (setq PTLIST (list
                (setq PT (getpoint "\n Specify the first point  "))
              ) ;_  list
 ) ;_  setq
 (princ "\n Specify the following point  ")
 (princ)
 (while
   (setq PT
          (progn (while
                   (and (setq PT (grread 5))
                        (= (car PT) 5)
                   ) ;_  and
                    (redraw)
                    (mapcar
                      (function
                        (lambda (x1 x2)
                          (grdraw x1 x2 6 5)
                        ) ;_  lambda
                      ) ;_  function
                      (cons (cadr PT) PTLIST)
                      PTLIST
                    ) ;_  mapcar
                 ) ;_  while
                 (if (listp (cadr PT))
                   (cadr PT)
                 ) ;_  if
          ) ;_  progn
   ) ;_  setq
    (setq PTLIST (cons PT PTLIST))
 ) ;_  while
) ;_  defun

 

Thanks

Posted
(grread 5) , what 5 stands for? (didnt understand the docs)

The integer 5 corresponds to the allkeys argument for grread and is a combination of the bit-codes 1 (return 'drag mode' coordinates) and 4 (use the value passed in the 'curtype' argument to control the cursor display).

 

what makes PT to get nil? (as it terminate the program main loop)

 

The grread function will not usually return nil; the while loop will generally be terminated when (car PT) does not equal 5, that is, when the user input is something other than mouse movement (e.g. 2=keyboard input, 3=left-click etc.).

Posted
The integer 5 corresponds to the allkeys argument for grread and is a combination of the bit-codes 1 (return 'drag mode' coordinates) and 4 (use the value passed in the 'curtype' argument to control the cursor display).

 

 

can you give example of using allkeys and curtype arguments?

 

 

The grread function will not usually return nil; the while loop will generally be terminated when (car PT) does not equal 5, that is, when the user input is something other than mouse movement (e.g. 2=keyboard input, 3=left-click etc.).

 

the inner while is terminated when input is other than 5, but the outer will terminate only if PT is nil , so...how does PT gets nil?

 

Thanks

S

Posted
can you give example of using allkeys and curtype arguments?

 

I would suggest reviewing the numerous examples posted in this thread.

 

the inner while is terminated when input is other than 5, but the outer will terminate only if PT is nil , so...how does PT gets nil?

 

For the test expression of the outermost while loop, the symbol PT is assigned the value returned by the following expression:

                  (if (listp (cadr PT))
                   (cadr PT)
                 )

Hence, if the second item (cadr) of the list returned by grread is a point (i.e. if the user has left-clicked a point), the clicked point is returned, else nil is returned, causing the while loop to terminate.

Posted

is it possible to do the same as what the code does but with curved corners?

Posted
is it possible to do the same as what the code does but with curved corners?

 

Yes, you would simply need to calculate a set of vectors to approximate an arc - quick example here.

Posted
Yes, you would simply need to calculate a set of vectors to approximate an arc - quick example here.

 

Thanks Lee

 

i continues to explore the function ,

i write a test program,

 

The user asked to define horizontal border line,

than a point is attached to the curser and change its color

based on its perspective location ,bellow or above the border line.

 

please advice for more efficient way to improve this code.

 

 

;_Casestudy : SFX01A
;_
;_ Shay Gaghe
;_ 24.06.15
;_
;_ The user asked to define horizontal border line,
;_ than a circle is attached to the curser and change its color
;_ based on its perspective location ,bellow or above the border line.


;_pseudo:
;_
;_setvar pdmode 34
;_ask user to define a point as <borderPoint>
;_create xline based on <borderPoint>
;_create a point entity <corsurEntity>

;_while curser moves
;_set corsor location in currentCorsurLocation
;_set the location of corsurEntity as currentCorsurLocation

;_if currentCorsurLocation Y is grater  than borderPoint
;_ turn corsurEntity to Blue
;_ turn corsurEntity to red



(defun C:BORDER2 (/ currentCorsurLocation corsurEntity borderPoint)

 (setvar "PDMODE" 34)
;;;  (setvar "PDSIZE" 50)

 (setq borderPoint (getpoint "Please select a point"))
 (command "_XLINE" "H" borderPoint "")

 (setq	corsurEntity
 (entmakex (list (cons 0 "POINT") ;***
		 (cons 6 "BYLAYER")
		 (cons 8 "0")
		 (cons 10 borderPoint) ;***
		 (cons 39 0.0)
		 (cons 50 0.0)
		 (cons 62 256)
		 (cons 210 (list 0.0 0.0 1.0))
		 ) ;_ list
	   ) ;_ end of entmakex
) ;_ end of setq
 (setq corsurEntity (entget corsurEntity)) ;_gets the -1 DXF value

 (while (and (setq currentCorsurLocation (grread 5))
      (= (car currentCorsurLocation) 5)
      ) ;_ and
   (entmod (subst
      (cons 10 (cadr currentCorsurLocation))
      (assoc 10 corsurEntity)
      corsurEntity
      ) ;_ end of subst
    ) ;_ end of entmod
   (entupd (cdr (assoc -1 corsurEntity)))

   (if	(< (cadr (cadr currentCorsurLocation)) (cadr borderPoint))
     (progn
(entmod	(subst
	  (cons 62 5)
	  (assoc 10 corsurEntity)
	  corsurEntity
	  ) ;_ subst
	) ;_ entmod
) ;_ progn
     (progn
(entmod	(subst
	  (cons 62 2)
	  (assoc 10 corsurEntity)
	  corsurEntity
	  ) ;_ subst
	) ;_ entmod
) ;_ progn
     ) ;_ if

   ) ;_ end of while
 ) ;_ defun

 

 

Thanks

S

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...