HELP

Discussion in 'AutoCAD' started by Petur Veliki, Oct 22, 2004.

  1. Petur Veliki

    Petur Veliki Guest

    Hello
    I'm a beginner in AutoLISP and need help with a pronlem

    ; i want to make a selection of lines SEL
    (setq SEL (ssget))
    ; with LEN number of elements
    (setq LEN (sslength SEL))
    ; then how can i give each element in the selection
    ; different name in a while loop automaticly
    (setq i 0)
    (while (< i LEN)
    (setq ENT (ssname SEL i))
    …………
    )
    ; i want the first line of the selection to be ENT1
    ; the second -> ENT2 and so on
    ; How to include the counter i in the variable name?

    THANKS
     
    Petur Veliki, Oct 22, 2004
    #1
  2. Petur Veliki

    Jürg Menzi Guest

    Hi Petur

    I don't know why you wanna bind the entities to variables, there are more
    elegant solutions to work with selection sets.

    Anyway, you can do it like this:
    Code:
    (setq SEL (ssget))
    ; with LEN number of elements
    (setq LEN (sslength SEL))
    ; then how can i give each element in the selection
    ; different name in a while loop automaticly
    (setq i 0)
    (repeat LEN
    (set (read (strcat "ENT" (itoa i))) (ssname SEL i))
    (setq i (1+ i))
    )
    
    Cheers
     
    Jürg Menzi, Oct 22, 2004
    #2
  3. Petur Veliki

    randy benson Guest

    I agree with Jürg - and the oft-repeated suggestion to post your code here would
    assit folks in helping you. Also, if you want to select _only_ lines, you can
    make it easier by using (setq SEL (ssget '((0 . "LINE")))), which will allow you
    to pick by crossing window, automagically filtering out everything crossing the
    window that isn't a line. Note also that you can refine the selection further
    by picking (for instance) only lines that are on a certain layer: (setq SEL
    (ssget '((0 . "LINE")(8 . "YourLayerName")))).
     
    randy benson, Oct 22, 2004
    #3
  4. Petur Veliki

    Petur Veliki Guest

    Thanks
    That's exactly what i was looking for
    I'm trying to make a program for tubes
    Selecting lines it makes fillets and draws 3D tubes
    giving the correct length and ability to be manipulated

    but i'm not very good in autoLISP so i'm struggling
    Anyway
    Thank you again
     
    Petur Veliki, Oct 22, 2004
    #4
  5. Petur Veliki

    Simon Wegner Guest

    Simon Wegner, Oct 22, 2004
    #5
  6. Petur Veliki

    Petur Veliki Guest

    Just sth else
    Creating variabble names like that (stcat "ENT" (itoa i))
    is there a way to make those variables local?
    if i don't know the final value of i
     
    Petur Veliki, Oct 22, 2004
    #6
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.