AUTOLISP Flatten Command

Discussion in 'AutoCAD' started by vmuntean, Feb 8, 2008.

  1. vmuntean

    vmuntean Guest

    Hello,

    I am desperate to find the correct AUTOLISP syntax for the AutoCAD
    "FLATTEN" comamnd. I have the user select the entities, then type
    "flatten" and "no" for remove hidden lines. I cannot figure out what
    the correct syntax is. Please HELP!

    (setq ss1(ssget))
    (command ".......flatten? "n")
    (command "pedit" (ssname ss1 0) "y" "j" (princ ss1) "" "c" "")

    Thank you,
    Vlad
     
    vmuntean, Feb 8, 2008
    #1
  2. vmuntean

    vmuntean Guest

    Nevermind about my initial question. I just realized that the Flatten
    is part of the Express package and it itself is a lsp file. I found it
    on my computer but now the question is how do I incorporate this lsp
    into mine, so the user makes their selection, runs the "flatten.lsp"
    code then joins them into a polyline. Is there a way to incorporate
    multiple lsp routines into one file, or call an existing lsp from the
    one you are running?

    Thank you,
    Vlad
     
    vmuntean, Feb 8, 2008
    #2
  3. You can't run lisps from a lisp. You *can* run lisps from a script, or mash
    together the various lisps you want to run into one. The latter takes a
    little familiarity with lisp.
    --


    MichaelB
    www.michaelbulatovich.ca

    Nevermind about my initial question. I just realized that the Flatten
    is part of the Express package and it itself is a lsp file. I found it
    on my computer but now the question is how do I incorporate this lsp
    into mine, so the user makes their selection, runs the "flatten.lsp"
    code then joins them into a polyline. Is there a way to incorporate
    multiple lsp routines into one file, or call an existing lsp from the
    one you are running?

    Thank you,
    Vlad
     
    Michael Bulatovich, Feb 8, 2008
    #3
  4. vmuntean

    strawberry Guest

    For the OP, a method for flattening drawings that I prefer over the
    EXPRESS TOOLS command (which does some weird things with blocks) is to
    select all the objects and then squish them against the edge of the
    'universe' before moving them all back again to z=0. Although others
    have written some pretty sophisticated versions of this script, it's
    essentially pretty straightforward and very easy to incoporate into a
    lisp routine. It could look something like this (from memory, and
    untested);
    m;all;;0,0,0;0,0,-1e99;m;all;;0,0,-1e99;0,0,0

    You might want to add something for saving and the restoring layer
    states and thawing and unlocking objects. I think that relative to
    their insertion points, block objects are unaffected by this procedure
    - although the insertion points themselves are positioned to z=0.
     
    strawberry, Feb 9, 2008
    #4
  5. vmuntean

    Paul Turvill Guest

    Actually, you CAN run many LISP routines from other LISP routines; what you
    cannot do is to do so with the (command ...) function. You just have to call
    it with the correct LISP syntax. And, of course those that are designed to
    be interactive won't accept their required parameters "up front" like native
    commands; they must still be allowed to run interactively.
    ___
     
    Paul Turvill, Feb 9, 2008
    #5
  6. Yeah, you're right, but that's what the OP was trying to do.

    Should you want to call one lisp from another, assuming it is already
    loaded, how do you do it? Do you just declare it's name in parentheses, like
    an internally defined function?
     
    Michael Bulatovich, Feb 9, 2008
    #6

  7. Except I think you the last 3 zeros are extaneous ; )
    It also doesn't remove thickness from entities.
     
    Michael Bulatovich, Feb 9, 2008
    #7
  8. vmuntean

    Paul Turvill Guest

    Yes. "Flatten" for example, can be launched with a simple

    (C:flatten)
    ___
     
    Paul Turvill, Feb 9, 2008
    #8
  9. vmuntean

    vmuntean Guest

    Hello,

    Thank you all for your help. The (C:flatten) was the key for me. I
    modified the flatten lsp file to remove any user input and had it be
    called from one of my other lsp files silently. It works great. Thank
    you all again,

    Vlad
     
    vmuntean, Feb 11, 2008
    #9
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.