Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

help I am new trying to learn lisps

12 REPLIES 12
Reply
Message 1 of 13
gcsjlewis
477 Views, 12 Replies

help I am new trying to learn lisps

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)

 

12 REPLIES 12
Message 2 of 13
hmsilva
in reply to: gcsjlewis

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

EESignature

Message 3 of 13
devitg
in reply to: hmsilva

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"
Message 4 of 13
hmsilva
in reply to: devitg

Hi Gabriel

\r is a return,

 

Henrique

EESignature

Message 5 of 13
devitg
in reply to: hmsilva

Henrique, thanks .

Can it be repalced by "" ??

Message 6 of 13
hmsilva
in reply to: devitg

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

EESignature

Message 7 of 13
devitg
in reply to: gcsjlewis

Hi Henrique.

 

I put a new brick on the wall.

 

Thanks

 

Message 8 of 13
hmsilva
in reply to: devitg

You're welcome, Gabriel

 

Henrique

EESignature

Message 9 of 13
gcsjlewis
in reply to: hmsilva

Thanks!! ________________________________ The information contained in this message is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately, and delete the original message.
Message 10 of 13
hmsilva
in reply to: gcsjlewis

You're welcome, manamalewis

Henrique

EESignature

Message 11 of 13
devitg
in reply to: hmsilva

What , manamalewis , mean??

Message 12 of 13
gcsjlewis
in reply to: devitg

What does the name mean? ________________________________ The information contained in this message is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately, and delete the original message.
Message 13 of 13
devitg
in reply to: gcsjlewis

Please apologize me , I made a misstake.

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost