Stringing Commands together

Discussion in 'AutoCAD' started by deegola, Oct 21, 2004.

  1. deegola

    deegola Guest

    I would like to be able to create a button that would Step 1: Create a region using the boundary command 2: perform an extrude (of a pre-defined height) on that same item then 3: move the new item to a pre-defined layer.

    I can do 2 out of the 3 so far with separate customized buttons, but would love to be able to string it all together.

    Any help would be greatly appreciated.

    Thanks,

    DJ Delten
     
    deegola, Oct 21, 2004
    #1
  2. deegola

    T.Willey Guest

    (defun c:ExtBou (/ ent1 ohp ocmd)

    (vl-load-com)
    (command "_.undo" "_end")
    (command "_.undo" "_group")
    (setq ocmd (getvar "cmdecho"))
    (setq ohp (getvar "hpbound"))
    (setvar "hpbound" 0)
    (setvar "cmdecho" 1)
    (command "_.-boundary")
    (while (= (getvar "cmdactive") 1)
    (command pause)
    )
    (setvar "cmdecho" 0)
    (setq ent1 (entlast))
    (command "_.extrude" ent1"" "5" "") ; <- change 5 to height desired
    (setq ent1 (vlax-ename->vla-object (entlast)))
    (vla-put-Layer ent1 "0") ;<- change "0" to layer desired
    (setvar "hpbound" ohp)
    (command "_.undo" "_end")
    (setvar "cmdecho" ocmd)
    (princ)
    )

    See how this works for you, but you will have to change a few things that are labeled to change.

    Tim
     
    T.Willey, Oct 21, 2004
    #2
  3. deegola

    Rick Keller Guest

    I guess you are looking for the layer changing portion...

    Place this first and it will change the current layer to your chosen layer
    then
    the new entity will be created on the new layer.

    (setvar "clayer" "your layer name")(command "boundary" pause )(command
    "extrude" pause "" "3" "")

    Rick
     
    Rick Keller, Oct 21, 2004
    #3
  4. deegola

    deegola Guest

    I'm sorry, I can't get this to work. Do I have taken out the notes, made the changes, but just can't run it. Can I paste this into a buttons properties? Or do I have to run it as a script?

    Thanks,

    DJ
     
    deegola, Oct 21, 2004
    #4
  5. deegola

    deegola Guest

    This seems to work pretty well for me, but I get "hung up" after I try to get to the second command. It will set the layer easy enough, and then move to the boundary command, but then I need (I guess) to have it auto-select the object in use, and then try to start then next command in the series???

    Is this too much for a button, do I have to run scripts, or can buttons be as complicated as you'd like them to be?

    Thanks,

    DJ
     
    deegola, Oct 21, 2004
    #5
  6. deegola

    T.Willey Guest

    It is a lisp routine. You could copy/paste it into a text editing program, I use Notepad. Then save it as something with the extension of ".lsp". Once in autocad you can use the command "appload" "ap" to select the file you created. Then at the command line type "extbou".

    Hope that is clear.
    Tim
     
    T.Willey, Oct 21, 2004
    #6
  7. deegola

    deegola Guest

    Thanks! Worked like a charm. So, now I can set the few variables, to create a few different versions of that, and simply connect the command to a button after I load the app......My last question, then I'll quit bugging you.

    If I create (lets say 6-10) different versions of that same LSP file (with slightly modded variables) how can I get CAD to autoload all those at startup? Or do they auto-start with a template (I could add them to one...) Know whaat I mean?

    Thanks again, you are all being VERY VERY helpfull to me, I appreciate it greatly.

    DJ
     
    deegola, Oct 21, 2004
    #7
  8. deegola

    T.Willey Guest

    What variables do you want to change? I could add a prompt to ask for the desired height, but if it's going onto different layers then it would be a little harder.

    How I do it is, I have lisp files (.lsp) that may contain more then one lisp in each, and have a custom menu file to load them all when autocad starts, or opens a new drawing. If you are only going to have this one lisp file that you want to be loaded, then you can just add it to the start up suite. When you type "ap" at the command prompt, a dialog box appears. At the bottom right side you will see a breifcase, hit the contents button, then click add, and add your lisp file. That way it will be loaded into all drawing files that you open.

    Hope I answered your questions, if not sorry, ask again and I will try again. Hope this helps.
    Tim
     
    T.Willey, Oct 21, 2004
    #8
  9. deegola

    Rick Keller Guest

    I see Tim has solved your problem.
    It is probably getting hung up on the boundary command I never use it so I'm
    not getting it exactly right.

    But to answer your questions about buttons. Buttons can have many commands
    linked together but I think I would
    stop about 3 or 4 after that I use a lisp routine such as Tim has created.
    Then you just tell the button to load the routine then run it.
    Then at the click of a button you can do anything in autocad.

    Rick
     
    Rick Keller, Oct 21, 2004
    #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.