3dwannab Posted March 18, 2017 Share Posted March 18, 2017 Just two problems: 1. When I hit return on the default getkword it doesn't run correctly. 2. When I choose anything but the Pick Hatch Location it outputs to the commandline for each hatch entity it has been selected. How do I get rid of that. The osmode is 0. [use current origin/Set new origin/Default to boundary extents] <Use current origin>: [bottom Left/bottom Right/top rIght/top lEft/Center] <bottom Left>:] <bottom Left>: ;;-----------------=={ Hatch_Origin_Location.lsp }==--------------------;; ;; Author: 3dwannab, 2017 ;;----------------------------------------------------------------------;; ;; Version 0.1 - 18-03-2017 ;;----------------------------------------------------------------------;; ;; Hatch Location Options: ;; BottomLeft/BottomRight/TopRight/TopLeft/Center/Pick ;;----------------------------------------------------------------------;; (defun c:HOL nil (c:Hatch_Origin_Location)) (defun c:Hatch_Origin_Location ( / *error* os cmde pt ss ent data ans) (defun *error* (errmsg) (and acDoc (vla-EndUndoMark acDoc)) (and errmsg (not (wcmatch (strcase errmsg) "*CANCEL*,*EXIT*")) (princ (strcat "\n<< Error: " errmsg " >>")) ) (setvar 'cmdecho cmde) (setvar 'osmode os) (princ) ) (setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object))) (or (vla-EndUndoMark acDoc) (vla-StartUndoMark acDoc)) (setq os (getvar "osmode")) (setq cmde (getvar "cmdecho")) (initget "BottomLeft BottomRight TopRight TopLeft Center Pick") (setq ans (getkword "\nChoose Hatch Origin Location ? [bottomLeft/BottomRight/TopRight/TopLeft/Center/Pick] <Pick>: ")) (cond ( (= "Pick" ans) (sssetfirst) (and (setq ent (entsel "\n Select Hatch: ")) (setq pt (getpoint "\n New Hatch Origin:")) (command "._HatchEdit" ent "O" "S" pt "N") ) ) ) (cond ( (/= "Pick" ans) (if (setq ss (ssget "_:L" '((0 . "HATCH"))) ) (repeat (setq i (sslength ss)) (setq ent (ssname ss (setq i (1- i))) data (entget ent) ) (progn (cond ( (= "BottomLeft" ans) (command "._HatchEdit" ent "O" "D" "L" "N")(princ) ) ( (= "BottomRight" ans) (command "._HatchEdit" ent "O" "D" "R" "N")(princ) ) ( (= "TopRight" ans) (command "._HatchEdit" ent "O" "D" "I" "N")(princ) ) ( (= "TopLeft" ans) (command "._HatchEdit" ent "O" "D" "E" "N")(princ) ) ( (= "Center" ans) (command "._HatchEdit" ent "O" "D" "C" "N")(princ) ) ) ) ) ) ) ) (*error* nil) (princ) ) (vl-load-com) (princ (strcat "\n:: Hatch_Origin_Location.lsp | Version 0.1 | \\U+00A9 3dwannab " (menucmd "m=$(edtime,0,yyyy)") " ::" "\n:: Type \"HOL\" or \"Hatch_Origin_Location\" to Run ::" ) ) (princ) Quote Link to comment Share on other sites More sharing options...
danellis Posted March 20, 2017 Share Posted March 20, 2017 I may not be following your logic fully, but I don't *think* there's anything that tells the program to default to "pick." The indicator in the prompt is just for the user. Basically you need a final COND value for ANS being nil. dJE Quote Link to comment Share on other sites More sharing options...
3dwannab Posted March 22, 2017 Author Share Posted March 22, 2017 I may not be following your logic fully, but I don't *think* there's anything that tells the program to default to "pick." The indicator in the prompt is just for the user. Basically you need a final COND value for ANS being nil. dJE Got that bit to work. By setting the variable to 'Pick' with: (if (not ans) (setq ans "Pick")) Can you tell me why this will output to the cmd even when the cmdecho is set to 0 in the program? (command-s "._HatchEdit" pause "O" "D" "L" "N") Full new code: ;;-----------------=={ Hatch_Origin_Location.lsp }==--------------------;; ;; Author: 3dwannab, 2017 ;;----------------------------------------------------------------------;; ;; Version 0.1 - 18-03-2017 ;;----------------------------------------------------------------------;; ;; Hatch Location Options: ;; BottomLeft/BottomRight/TopRight/TopLeft/Center/Pick ;;----------------------------------------------------------------------;; (defun c:HOL nil (c:Hatch_Origin_Location)) (defun c:Hatch_Origin_Location ( / *error* os cmde mutt pt ss ent data ans) (defun *error* (errmsg) (and acDoc (vla-EndUndoMark acDoc)) (and errmsg (not (wcmatch (strcase errmsg) "*CANCEL*,*EXIT*")) (princ (strcat "\n<< Error: " errmsg " >>")) ) (setvar 'cmdecho cmde) (setvar 'osmode os) (setvar 'nomutt mutt) (princ) ) (setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object))) (or (vla-EndUndoMark acDoc) (vla-StartUndoMark acDoc)) (setq os (getvar "osmode")) (setq cmde (getvar "cmdecho")) (setq ex (getvar "expert")) (setq mutt (getvar "nomutt")) (progn (setvar 'cmdecho 0) (setvar 'osmode 0) (setvar 'nomutt 1) (initget "bottomLeft bottomRight toprIght toplEft Center Pick") (setq ans (getkword "\nX Brick Size (Standard=112.5 Joint=10)? [bottom Left/bottom Right/top rIght/top lEft/Center/Pick] <Pick>: ")) (if (not ans) (setq ans "Pick")) (cond ((= "Pick" ans) (sssetfirst) (and (setq ent (entsel "\n Select Hatch: ")) (setq pt (getpoint "\n New Hatch Origin:")) (command "._HatchEdit" ent "O" "S" pt "N") ) ) ) (cond ((/= "Pick" ans) (if (setq ss (ssget "_:L" '((0 . "HATCH"))) ) (repeat (setq i (sslength ss)) (setq ent (ssname ss (setq i (1- i))) data (entget ent) ) (cond ((= "bottomLeft" ans) (command-s "._HatchEdit" ent "O" "D" "L" "N")(princ) ) ((= "bottomRight" ans) (command-s "._HatchEdit" ent "O" "D" "R" "N")(princ) ) ((= "toprIght" ans) (command-s "._HatchEdit" ent "O" "D" "I" "N")(princ) ) ((= "toplEft" ans) (command-s "._HatchEdit" ent "O" "D" "E" "N")(princ) ) ((= "Center" ans) (command-s "._HatchEdit" ent "O" "D" "C" "N")(princ) ) ) ) ) ) ) T ) (*error* nil) (princ) ) (vl-load-com) (princ (strcat "\n:: Hatch_Origin_Location.lsp | Version 0.1 | \\U+00A9 3dwannab " (menucmd "m=$(edtime,0,yyyy)") " ::" "\n:: Type \"HOL\" or \"Hatch_Origin_Location\" to Run ::" ) ) (princ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.