Simplest Offset command, in AutoLISP?

Discussion in 'AutoCAD' started by porkin, Feb 7, 2005.

  1. porkin

    porkin Guest

    My understanding of AutoLISP is very rudimentary.

    I am trying to develop a simple customization of the OFFSET command.

    Could someone please post here the most basic AutoLISP substitute for the built-in OFFSET comand that they know how to create?
    I don't even know what program setup parameters or such that AutoLisp requires to consider a routine to be valid.

    If someone could just post a real simple routine so I can have a place to start tinkering, I feel I have a chance of getting something out of this. I'd really appreciate it; I have downloaded all the other routines I used at my last employment, but never had access to copying for my own use -- all but this last one I am trying to develop myself.
    Thanks in advance.
     
    porkin, Feb 7, 2005
    #1
  2. porkin

    Adesu Guest

    Hi porkin, like this may be

    (command "_offset" 2 pause pause "")

    built-in OFFSET comand that they know how to create?
    requires to consider a routine to be valid.
    start tinkering, I feel I have a chance of getting something out of this.
    I'd really appreciate it; I have downloaded all the other routines I used at
    my last employment, but never had access to copying for my own use -- all
    but this last one I am trying to develop myself.
     
    Adesu, Feb 7, 2005
    #2
  3. porkin

    krispy Guest

    as a function:
    Code:
    (defun c:myOffset()
    (command "._offset")
    (princ)
    )
    
     
    krispy, Feb 7, 2005
    #3
  4. porkin

    porkin Guest

    Ok, thanks Krispy -- but I guess OFFSET is more difficult to understand than I thought. I don't see where that routine gets its keyboard input, for one thing. The other thing is, it won't load, but says it does; system will not respond to the defined name OR the name it inexplicably says the routine was loaded to respond to:

    Command: ap
    APPLOAD AutoDesk OFF.lsp successfully loaded.

    Command: myoffset
    Unknown command "MYOFFSET". Press F1 for help.

    Command: off
    Unknown command "OFF". Press F1 for help.

    ... so then I type OFFSET, and the built-in thing turns out to still be available, but the idea is to make a simple half-offset and double-offset.

    Can anyone tell me why this thing won't load (or just write a half-offset, since AutoLISP is looking more opaque than even I gave it credit for)???
     
    porkin, Feb 7, 2005
    #4
  5. porkin

    porkin Guest

    O ya, BTW, I used other comman-line entries to invoke the routine, such as the lisp filename (on disk), and everything gets me back a "unknown command" response.

    What might be best is the simplest routine that would follow an "undefine" statement at the top of the file; thinking that maybe the program logic would be more transparent that way. I've come so far in getting my library decked out with routines I really value, ANYTHING that gets me to my modified-OFFSET routine is greatly appreciated.
     
    porkin, Feb 7, 2005
    #5
  6. porkin

    krispy Guest

    type this at the command line:
    (defun c:myoffset() (command "._offset") (princ))
    then type:
    myoffset
    should run the offset command.
    also note that when you load a lisp it only loads into the current drawing, so if you switch to another drawing it wont be available in that drawing, only in the original
     
    krispy, Feb 7, 2005
    #6
  7. porkin

    porkin Guest

    Yes, that works! (dunno why apploader ain't gittin it)

    Now, what do I multiply by 2 to have the function double the distance at which each offset occurs? (I dont see a variable)
     
    porkin, Feb 7, 2005
    #7
  8. porkin

    porkin Guest

    It works! Can anyone tell me why apploader doesn't seem to like this thing (looks like what might be called a User-Defined Function routine)?

    I have one more Q: what variable does this "._offset" command take its offset from? I started this thread wanting an autocad offset command that offsets entities a constant factor of the user-input distance, so I think I need a variable in which the user-input distance resides while the command finishes offsetting the entities. That's why I originally asked if anybody had a replacement routine for the built-in command; i.e., one that does not itself USE a built-in autocad "offset" command.

    Can someone tell me if I'm even pointed in the right direction, or am I looking down a dead-end with the previous-listed routine?
     
    porkin, Feb 8, 2005
    #8
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.