I "stole" the lisp for the flatten command posted below. I am trying to modify it so after it prompts me to select objects, it automatically selects "all", and then when it prompts me if I want to remove hidden lines, it automatically does. I tried this
(defun c:fl () (command "flatten" "all" "yes")) as well as
(defun c:fl () (c:flatten "all" "yes"))
but this will not recognize any input after flatten. I can manually type them in, but I can't get the lisp to automatically do it. So I chose to modify the flatten lisp itself (FYI this is an express lisp if that matters)
(defun c:fl ( / ss ans ) (acet-error-init (list nil 1)) (princ "\nSelect objects to convert to 2d...") (if (not acet:flatn-hide) (setq acet:flatn-hide "No") );if (if (and (setq ss (ssget "_:l" '((-4 . "<NOT") (0 . "VIEWPORT") (-4 . "NOT>"))));setq (setq ss (car (acet-ss-filter (list ss nil T)))) );and (progn (initget "Yes No") (setq ans (getkword (acet-str-format "\nRemove hidden lines? <%1>: " acet:flatn-hide ) );getkword );setq (if (not ans) (setq ans acet:flatn-hide) (setq acet:flatn-hide ans) );if (if (equal ans "No") (acet-flatn ss nil) (acet-flatn ss T) );if );progn then );if (acet-error-restore) );defun c:flatten
(acet-autoload2 '("FLATTENSUP.LSP" (acet-flatn ss hide))) (princ)
manamalewis,
Flatten is not a AutoCAD native command, it is a external function.
As I had already posted in your previous post "select all command in autolisp", using vla-sendcommand, it is possible to send to the command line the answers to the prompts of the function Flatten...
(vl-load-com);; Loads Visual LISP extensions to AutoLISP (defun c:fl ();;select all and don't remove hidden lines (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "flatten all\r no\r") (princ) ) (defun c:fy ();;select all and remove hidden lines (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "flatten all\r yes\r") (princ) )
hope that helps
Henrique
Hi Henrique , Enrique is my second first name , no H .
Wahat do it mean te \r in , is it a carriage return or ENTER??
Gabriel Enrique
"flatten all\r no\r"
Hi Gabriel,
as you can see I have not used the (strcat) function, it is not necessary, so, just a space will do the trick, if you try this string "flatten all yes ",
the command runs as expected, but on the command line, the echon appear without changing lines.
I use \ r to view the line changes while I'm writing code and that the echo is as close as possible to the original command echo.
Cheers
Henrique
Can't find what you're looking for? Ask the community or share your knowledge.