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

select all command in autolisp

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
gcsjlewis
4533 Views, 5 Replies

select all command in autolisp

I am trying to write a simple (or at least I thought it was) code to flatten a 3d object into a 2d shape.  For some reason after ACAD runs the lisp it recognizes the flatten command but it will not select all.  this is what I have:

 

(defun c:fl () (command "flatten" "all") ) 

 

I have even tried the pick first command, to select all then run the flatten command but that still doesn't work.  Any Ideas?

5 REPLIES 5
Message 2 of 6
Kent1Cooper
in reply to: gcsjlewis


@gcsjlewis wrote:

I am trying to write a simple (or at least I thought it was) code to flatten a 3d object into a 2d shape.  For some reason after ACAD runs the lisp it recognizes the flatten command but it will not select all.  this is what I have:

 

(defun c:fl () (command "flatten" "all") ) 

 

I have even tried the pick first command, to select all then run the flatten command but that still doesn't work.  Any Ideas?


I haven't used Flatten, but if it's like other commands involving object selection, you need to tell it you're done picking things.  After all, you could select All and then use the Remove option to take a few things out of the selection, etc.  Try [untested] adding an Enter to complete the selection:

 

(defun c:fl () (command "flatten" "all" "") )

Kent Cooper, AIA
Message 3 of 6
gcsjlewis
in reply to: Kent1Cooper

I tried that as well. It doesn't recognize the all command ________________________________ 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 4 of 6
Kent1Cooper
in reply to: gcsjlewis


@gcsjlewis wrote:
I tried that as well. It doesn't recognize the all command....

I think it's the Flatten command that it doesn't recognize, rather than the All option.  That's because Flatten isn't a native AutoCAD command but a specialty function -- you can tell by the fact that when you first call for it in a given editing session, "Initializing..." goes by on the Command: line before the selection prompt.

 

The (command) function only recognized native AutoCAD command names.  To use specialty functions, or your own custom commands made using (defun C:Whatever...), in AutoLISP code, you need to enclose the name in parentheses and put the C: before it:

 

(C:FLATTEN)

 

However, I don't think you can give it followup answer-the-prompts information like selection options in the way that you can with native AutoCAD commands.  Try searching the Discussion Group -- this may have come up before.

Kent Cooper, AIA
Message 5 of 6
hmsilva
in reply to: gcsjlewis

manamalewis, try

 

(defun c:fl ()
(vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) (strcat "flatten all \r\r"))
(princ)
)

 

Hope that helps

Henrique

EESignature

Message 6 of 6
smaher12
in reply to: gcsjlewis

You can modify the origianl from ssget "_:l" to ssget "X"

 

(defun c:flatten ( / 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 "X" '((-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)

 

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

Post to forums  

Autodesk Design & Make Report

”Boost