Unwanted first entry of getkword menu

Unwanted first entry of getkword menu

dlbsurveysuk
Collaborator Collaborator
523 Views
6 Replies
Message 1 of 7

Unwanted first entry of getkword menu

dlbsurveysuk
Collaborator
Collaborator

Anyone know why the first unwanted entry "R" is appearing in these options? Sure it's something very simple but I can't figure it out -

 

getkword menu.JPG

;;
;;  Autocad addin PCCTools (Point Cloud Crop Tools)
;;  must be installed for this to work
;;
;;  Works relative to the current saved project orientation UCS "plan" with one viewport
;; 

(defun c:SFC (/ VNUM VNUMS)                          ;; Section from crop, in 2nd VP

         (defun *error* (MSG)

            (if (/= MSG "Function cancelled")
                (princ (strcat "\nError: " MSG)))

              (if osm (setvar "OSMODE" OSM))

          (princ) )

    (setq OSM   (getvar "OSMODE"))
    (command "OSNAP" "NONE")

    (command "UCS" "V")

             (initget "R P C B")
             (setq CROPTYPE (cond ((getkword "\nChoose [<R>ectangle/<P>olygon/<C>ircle/<B>uffer]: ")) ("R")))

               (if (or (= CROPTYPE "R") (= CROPTYPE "r")) (c:QPCRCROP))
               (if (or (= CROPTYPE "P") (= CROPTYPE "p")) (c:QPCPCROP))
               (if (or (= CROPTYPE "C") (= CROPTYPE "c")) (c:QPCCCROP))
               (if (or (= CROPTYPE "B") (= CROPTYPE "b")) (c:PCBCROP))

           (command "UCS" pause pause "")     ;;  pick UCS points of section
           (command "PLAN" "C")

           (setq VNUM (getvar "CVPORT"))

               (if (> 3 VNUM)                                  ;; check & set 2nd VP number
                    (setq VNUMS (1+ VNUM))
                    (setq VNUMS (1- VNUM))
               )

           (command "VPORTS" 2 "V")

                (command "CVPORT" VNUM)
                (command "UCS" "X" "90")
                (command "PLAN" "C")
                (command "UCS" "X" "-90")
                (command "ZOOM" "O" "P" "")

                (command "CVPORT" VNUMS)
                (command "UCS" "NA" "R" "plan")
                (command "ZOOM" "O" "P" "")

     (setvar "OSMODE" OSM)

  (princ)
)

 

0 Likes
Accepted solutions (1)
524 Views
6 Replies
Replies (6)
Message 2 of 7

ВeekeeCZ
Consultant
Consultant
Accepted solution

Was it you who wrote it?

 

Well, DYNMENU requires a certain format/syntax. And if your code does not follow it, then you can see a weird interpretation.

 

Correct formatting is:

(getkword "\nChoose [Rectangle/Polygon/Circle/Buffer] <Rectangle>: ")

 

 

 

Or better yet, this (initget) syntax covers all you need.

 

  (initget "Rectangle Polygon Circle Buffer")
  (setq CROPTYPE (cond ((getkword "\nChoose [Rectangle/Polygon/Circle/Buffer] <Rectangle>: "))
		       ("Rectangle")))

  (cond ((= CROPTYPE "Rectangle") 	(c:QPCRCROP))
	((= CROPTYPE "Polygon") 	(c:QPCPCROP))
	((= CROPTYPE "Circle") 		(c:QPCCCROP))
	((= CROPTYPE "Buffer")		(c:PCBCROP))
	)

 

Message 3 of 7

dlbsurveysuk
Collaborator
Collaborator

Thanks. That's solved it. Is there a way to highlight the default option, so if the default was "Circle" there would be a dot next to it?

 

Capture.JPG

0 Likes
Message 4 of 7

dlbsurveysuk
Collaborator
Collaborator

PS Yes it was me that wrote it (with difficulty)

0 Likes
Message 5 of 7

ВeekeeCZ
Consultant
Consultant

It's that last <Rectangle> that makes the dot. Use the updated code.

 

Note: It's the conflict me vs this site. The site removes all my <anything within these parents> automatically as a fake tags. Long story, it happens all the time...

0 Likes
Message 6 of 7

dlbsurveysuk
Collaborator
Collaborator

OK that's working. Thanks very much for your help.

0 Likes
Message 7 of 7

Sea-Haven
Mentor
Mentor

Give this a try also, example code is in top of lisp. Can set default button. Just save to a support directory only need like 2 lines to run.

 

0 Likes