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?
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
@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" "") )
@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.
manamalewis, try
(defun c:fl () (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) (strcat "flatten all \r\r")) (princ) )
Hope that helps
Henrique
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)