Visual LISP, AutoLISP and General Customization

Reply
Distinguished Contributor
manamalewis
Posts: 119
Registered: ‎11-07-2012
Message 1 of 13 (212 Views)

help I am new trying to learn lisps

212 Views, 12 Replies
03-20-2013 01:32 PM

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)

 

*Expert Elite*
hmsilva
Posts: 2,649
Registered: ‎12-17-2004
Message 2 of 13 (188 Views)

Re: help I am new trying to learn lisps

03-20-2013 04:16 PM in reply to: manamalewis

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

Mentor
devitg
Posts: 1,692
Registered: ‎03-14-2004
Message 3 of 13 (180 Views)

Re: help I am new trying to learn lisps

03-20-2013 05:06 PM 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"
*Expert Elite*
hmsilva
Posts: 2,649
Registered: ‎12-17-2004
Message 4 of 13 (176 Views)

Re: help I am new trying to learn lisps

03-20-2013 05:16 PM in reply to: devitg

Hi Gabriel

\r is a return,

 

Henrique

Mentor
devitg
Posts: 1,692
Registered: ‎03-14-2004
Message 5 of 13 (170 Views)

Re: help I am new trying to learn lisps

03-20-2013 05:57 PM in reply to: hmsilva

Henrique, thanks .

Can it be repalced by "" ??

*Expert Elite*
hmsilva
Posts: 2,649
Registered: ‎12-17-2004
Message 6 of 13 (154 Views)

Re: help I am new trying to learn lisps

03-21-2013 02:27 AM 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

Mentor
devitg
Posts: 1,692
Registered: ‎03-14-2004
Message 7 of 13 (144 Views)

Re: help I am new trying to learn lisps

03-21-2013 04:41 AM in reply to: manamalewis

Hi Henrique.

 

I put a new brick on the wall.

 

Thanks

 

*Expert Elite*
hmsilva
Posts: 2,649
Registered: ‎12-17-2004
Message 8 of 13 (142 Views)

Re: help I am new trying to learn lisps

03-21-2013 04:43 AM in reply to: devitg

You're welcome, Gabriel

 

Henrique

Distinguished Contributor
manamalewis
Posts: 119
Registered: ‎11-07-2012
Message 9 of 13 (134 Views)

Re: help I am new trying to learn lisps

03-21-2013 05:26 AM 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.
*Expert Elite*
hmsilva
Posts: 2,649
Registered: ‎12-17-2004
Message 10 of 13 (131 Views)

Re: help I am new trying to learn lisps

03-21-2013 05:31 AM in reply to: manamalewis

You're welcome, manamalewis

Henrique

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community