Getangle or ref

Getangle or ref

Anonymous
Not applicable
1,322 Views
6 Replies
Message 1 of 7

Getangle or ref

Anonymous
Not applicable
Ive got a very basic routine that draws an oblong hole, the user inputs length, width and defines a center/input point. After this I'm using getangle to set the rotation using the insertion point as point 1, but I also want to be able to type 'ref' to select 2 points if needed. If tried but this is scrambling my brain today. Any guidance will be appreciated.
0 Likes
Accepted solutions (1)
1,323 Views
6 Replies
Replies (6)
Message 2 of 7

Lee_Mac
Advisor
Advisor

If you omit the basepoint argument for the getangle expression, the user may either enter an angle at the command-line or pick two points to specify the angle.

 

If you necessarily need to retain the basepoint argument for the getangle prompt, you will need to use a keyword (initialised using initget) to allow the user to access an additional getangle prompt where two points may be given.

Message 3 of 7

Anonymous
Not applicable
If I use initget then getkword will that not stop the getangle command with basepoint?
0 Likes
Message 4 of 7

hmsilva
Mentor
Mentor
Accepted solution
(setq p1 (getpoint "\Enter center point: "))
(initget "Ref")
(setq ans (getangle p1 "\n Specify second point, or enter an angle [Ref] <exit>:"))
(cond ((= ans nil)
       (prompt "\nYou did press spacebar or enter, to exit...")
      )
      ((= 'real (type ans))
       (prompt "\nYou enter an angle...")
      )
      ((= "Ref" ans)
       (prompt "\nYou did enter Ref...")
      )
)

 

Hope this helps,
Henrique

EESignature

Message 5 of 7

Lee_Mac
Advisor
Advisor
danielbentley wrote:
If I use initget then getkword will that not stop the getangle command with basepoint?

 

I never said to use getkword - all getXXX functions will support the use of keywords (with the exception of getstring).

0 Likes
Message 6 of 7

Anonymous
Not applicable
So the initget function allows for input while using getxxx?
0 Likes
Message 7 of 7

Lee_Mac
Advisor
Advisor
danielbentley wrote:
So the initget function allows for input while using getxxx?

 

Exactly - you may refer to the tables included in the developer documentation for more information.

 

Here is an example to demonstrate my earlier suggestion:

 

(defun c:test ( / ang bpt )

    (setq bpt '(0.0 0.0 0.0))

    (initget "Reference")
    (if (= "Reference" (setq ang (getangle bpt "\nSpecify angle [Reference]: ")))
        (setq ang (getangle "\nPick two points to define the angle: "))
    )
    (princ "\nAngle: ") (princ (angtos ang))
    (princ)
)

 

 

0 Likes