Offset returns error

Discussion in 'AutoCAD' started by Jimmy D, Jan 7, 2005.

  1. Jimmy D

    Jimmy D Guest

    Hi,

    Why does this:

    (setq L1 (entsel "\nSelect 1st Line ..."))
    (setq L2 (entsel "\nSelect 2nd Line ..."))
    (setq OffSetDist (getreal "\nGive Offset Distance..."))
    (setq PF1 (cadr L1)
    PF2 (cadr L2))
    (command ".offset" OffSetDist L2 PF1 L1 PF2 "" )

    give this error:
    ; error: bad argument type: lentityp nil

    but when I CtrC/CtrV this:
    (command ".offset" OffSetDist L2 PF1 L1 PF2 "" )
    to the command line it works OK?

    Jim.
     
    Jimmy D, Jan 7, 2005
    #1
  2. I think you want (car L1) and (car L2), rather than (cadr). As I recall,
    (car) gives you the entity, and (cdr) or (cadr) would give you othe point at
    which it was selected.
     
    Kent Cooper, AIA, Jan 7, 2005
    #2
  3. Hi, I, tested and ok!!!!

    No errors in cad 2k5.

    (defun C:eek:fs ()
    (setq L1 (entsel "\nSelect 1st Line ..."))
    (setq L2 (entsel "\nSelect 2nd Line ..."))
    (setq OffSetDist (getreal "\nGive Offset Distance..."))
    (setq PF1 (cadr L1)
    PF2 (cadr L2))
    (command ".offset" OffSetDist L2 PF1 L1 PF2 "" )
    (princ))

    :)

    Rogerio
     
    Rogerio_Brazil, Jan 7, 2005
    #3
  4. Oops... too quick on the draw. I didn't quite read your (command) line
    closely enough. What you want is

    (setq L1 (car (entsel "\nSelect 1st Line ...")))
    and
    (setq L2 (car (entsel "\nSelect 2nd Line ...")))

    This is because (entsel) returns the entity as the first item, and the point
    you picked it at as the second (I think your PF1 and PF2 are correct). So
    to save the entity itself to be fed back for object selection, you have to
    put the (car) in front of the (entsel).
     
    Kent Cooper, AIA, Jan 7, 2005
    #4
  5. Jimmy D

    Jimmy D Guest

    Thanx both, but my problem still isn't solved.
    (car gives entity name; cdr gives (( 10.0 10.0 0.0)) in dubble brackets and doesn't work).
     
    Jimmy D, Jan 7, 2005
    #5
  6. It occurs to me that since PF1 and PF2 are locations, which would work for
    selecting in the Offset command, you might also be able to do

    (command ".offset" OffSetDist PF2 PF1 PF1 PF2 "" )

    And, I think you could even skip saving the line entities at all -- just
    save those two points as points in the first place.
    --
    Kent Cooper, AIA


    ...
    .....
     
    Kent Cooper, AIA, Jan 7, 2005
    #6
  7. Jimmy D

    Jimmy D Guest

    I think the problem is with the "ENTER" to close offset command. This is what I get in my text window when using the lisproutine:

    ....
    Specify offset distance or [Through] <Through>: 50.00
    Select object to offset or <exit>:
    Specify point on side to offset:
    Select object to offset or <exit>:
    Specify point on side to offset:
    Select object to offset or <exit>: ----->error created here
    Command: ; error: bad argument type: lentityp nil

    This is what I get with CtrC/CtrV the line to the command line (which works OK)

    Command: (command ".offset" OffSetDist L2 PF1 L1 PF2 "" )
    offset
    Specify offset distance or [Through] <50.000>: 50.00
    Select object to offset or <exit>:
    Specify point on side to offset:
    Select object to offset or <exit>:
    Specify point on side to offset:
    Select object to offset or <exit>: ----> no error here
    Command: nil
     
    Jimmy D, Jan 7, 2005
    #7
  8. I think (without digging into help to get the gory details) that (cdr) gives
    you the REST OF THE LIST after the first member. Apparently it returns it
    in the form of a list with, in the case of what it's starting with from
    (entsel), only one member, and that one member has parentheses around it,
    but so does the list -- hence the double parentheses.

    But apparently (cadr) gives the FIRST MEMBER of the rest of the list after
    the first member. It's returning an item, not a list, so it only has the
    one set of parentheses.

    I tried it out -- where (cdr (entsel)) returns
    ((10.0 10.0 0.0)),
    doing (cadr (entsel)) instead returns
    (10.0 10.0 0.0)

    Does that fix it?
     
    Kent Cooper, AIA, Jan 7, 2005
    #8
  9. Jimmy D

    Jimmy D Guest

    Hi Kent and Rogerio,

    I've tried all your suggestions, but none work :(
    I have the weekend to think it over (it's evening
    over here and I'm already 1 hour in overtime) so I think
    I will give it a rest.
    Thanks for your help and have a nice weekend!

    Jim
     
    Jimmy D, Jan 7, 2005
    #9
  10. See:

    OFFSETDIST = VARIABLE

    OffSetDist = your variable

    Try renaming OffSetDist to OffDist.

    (defun C:eek:fs ()
    (setq L1 (entsel "\nSelect 1st Line ..."))
    (setq L2 (entsel "\nSelect 2nd Line ..."))
    (setq OffDist (getreal "\n Give Offset Distance..."))
    (setq PF1 (cadr L1)
    PF2 (cadr L2))
    (command ".offset" OffDist L2 PF1 L1 PF2 "" )
    (princ))

    or

    (defun C:eek:fs ()
    (setq L1 (entsel "\nSelect 1st Line ..."))
    (setq L2 (entsel "\nSelect 2nd Line ..."))
    (setq OffDist (getreal "\n Give Offset Distance..."))
    (setq PF1 (cadr L1)
    PF2 (cadr L2))
    (command ".offset" OffDist L1 PF1 "")
    (command ".offset" OffDist L2 PF2 "")
    (princ))

    :)

    Rogerio
     
    Rogerio_Brazil, Jan 7, 2005
    #10
  11. That's odd. I can't say it would explain the difference you're getting, but
    is there any chance the extra spaces have anything to do with it? You have
    two spaces after OffSetDist, and two spaces after PF2, and a space after the
    final "", none of which I think are needed. I know in macros and scripts
    and such, outside (command) functions, every space really matters and means
    something, but maybe it ignores extras inside (command) functions. But I
    guess it would be pretty unexplainable if it ignored them when the (command)
    function is by itself, but didn't ignore them when it's part of a longer
    routine.
     
    Kent Cooper, AIA, Jan 7, 2005
    #11
  12. Really strange. In cad 2005 a routine run fine, without modifications.

    Have a nice weekend too!

    Rogerio :)
     
    Rogerio_Brazil, Jan 7, 2005
    #12
  13. Jimmy D

    Jimmy D Guest

    I have tried all your suggestions (car, cdr, cadr, OFFDIST, ...) but nothing works. The problems seems to be with the last "" to close the offset command.
    When I try the following at the command line everything works fine:

    Command:
    OFFSET
    Specify offset distance or [Through] <50.000>: 50
    Select object to offset or <exit>: !L1
    (<Entity name: 40082fa0> (351.228 120.822 0.0))
    Specify point on side to offset: !PF2
    (461.965 219.989 0.0)
    Select object to offset or <exit>: !L2
    (<Entity name: 40082fa8> (461.965 219.989 0.0))
    Specify point on side to offset: !PF2
    (461.965 219.989 0.0)
    Select object to offset or <exit>:
    Command:

    Anyway, I'm realy going home now!
    Have a nice weekend!
     
    Jimmy D, Jan 7, 2005
    #13
  14. Jimmy D

    Joe Burke Guest

    Gory details?

    Command: (setq lst '(1 2))
    (1 2)
    Command: (car lst)
    1
    Command: (cadr lst)
    2
    Command: (cdr lst)
    (2)

    Joe Burke
     
    Joe Burke, Jan 7, 2005
    #14
  15. Jimmy D

    Jeff Mishler Guest

    For what it's worth, I tried the code in the original post in R2002 and it
    works just fine........
     
    Jeff Mishler, Jan 7, 2005
    #15
  16. Yeah, gory details, by which I meant I didn't go in and look again at the
    particulars about exactly what a's and d's mean between the c and the r, and
    what you can do with car, cdr, cadr, caddr, cdaddyor, cyabbadabbadoor, or
    whatever. It had just occurred to me that this might the source of the
    double parentheses, and I checked it out by trying it on-screen rather than
    looking it up in Help. Your illustration further confirms my bruised, but
    not quite beaten to the level of gory, recollection of the difference
    between (car) and (cadr). Unfortunately, it looks like that's not the
    source of Jimmy D's problem, anyway.
     
    Kent Cooper, AIA, Jan 7, 2005
    #16
  17. Between the C and the R you can have a string of up to 4 variations of A and
    D. It works from right to left with a D returning everything in the list
    except the first element, and the A returning the first element.

    Examples:

    lst = (0 1 2 3 4)
    (caddr lst) would return 2 since the 1st D returns (1 2 3 4), the second D
    returns (2 3 4) so the A would return the 1st element.

    best regards,

    Dale
     
    Dale Levesque, Jan 7, 2005
    #17
  18. Jimmy D

    Don Butler Guest

    Works here on R2005.

    I believe that "lentityp nil" means that the interpreter expected a valid
    ENAME and got NIL instead.

    Weird...

    Don
     
    Don Butler, Jan 9, 2005
    #18
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.