Give me sample

Discussion in 'AutoCAD' started by Adesu, Jul 9, 2004.

  1. Adesu

    Adesu Guest

    Hi every body,can you give me sample a program for "ssname" and
    sslength",just only simple,thanks for your kind
    Best regards
    Ade Suharna
     
    Adesu, Jul 9, 2004
    #1
  2. Adesu

    Paul Turvill Guest

    (setq ss (ssget))
    (setq FirstObject (ssname ss 0))
    (setq SecondObject (ssname ss 1))
    ....etc.

    (setq n (sslength ss))
    returns in n the number of objects in the selection set ss (numbered 0 thru
    n-1).
    ___
     
    Paul Turvill, Jul 9, 2004
    #2
  3. Adesu

    gert Guest

    F1 - acad help ;)
     
    gert, Jul 9, 2004
    #3
  4. ;find all circles in drawing, zoom to each one and pause
    (setq SS (ssget "X" (list (cons 0 "CIRCLE"))))
    (if SS
    (progn
    (setq KK 0 KS (sslength SS))
    (while (< KK KS)
    (setq EG (entget (ssname SS KK)))
    (setq P0 (cdr (assoc 10 EG)))
    (command "ZOOM" "C" P0 (getvar "viewsize"))
    (setq YN (getstring "\nPaused to view Circle ? "))
    (setq KK (1+ KK))
    )
    )
    (princ "\nNo Circles in Drawing.")
    )
     
    Alan Henderson @ A'cad Solutions, Jul 9, 2004
    #4
  5. Adesu

    Adesu Guest

    Any others.......I am not yet understanding it !
     
    Adesu, Jul 12, 2004
    #5
  6. Adesu

    ECCAD Guest

    Ade,
    Command: (setq ss (ssget))

    Select objects: 1 found

    Select objects: 1 found, 2 total

    Select objects: 1 found, 3 total

    Select objects:
    ...............I selected 3 blocks
    <Selection set: 3>

    Command: (setq long (sslength ss))
    3
    .............. how many items selected = sslength

    Command: (setq count 0)
    0
    ................ get 1st item, count = 0

    Command: (setq first_entity (ssname ss count))
    <Entity name: 400fd558>

    Command: (setq count 1)
    1
    ............. get 2nd item, count = 1
    Command: (setq 2nd_entity (ssname ss count))
    <Entity name: 400fb440>

    Command: (setq count 2)
    2

    Command: (setq 3rd_entity (ssname ss count))
    <Entity name: 400fb400>

    ................ get details about 1st item...........
    Command: (setq 1st_item (entget (ssname ss 0)))
    ((-1 . <Entity name: 400fd558>) (0 . "INSERT") (330 . <Entity name: 400fa480>)
    (5 . "563") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 .
    "AcDbBlockReference") (2 . "PBMHNC") (10 4.125 7.0 0.0) (41 . 1.0) (42 . 1.0)
    (43 . 1.0) (50 . 0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0))

    Hope this helps..with ssname, you can either use a number, or setup a counter, then use that for each element.

    Bob
     
    ECCAD, Jul 12, 2004
    #6
  7. Adesu

    Adesu Guest

    Hi ECCAD,your tutorial is good , I began understand it,your explain
    simple,clear and easy to catch it,thanks a lot.
    counter, then use that for each element.
     
    Adesu, Jul 13, 2004
    #7
  8. Adesu

    ECCAD Guest

    Ade,
    As always, you are welcome.

    Bob
     
    ECCAD, Jul 17, 2004
    #8
  9. Adesu

    Adesu Guest

    Hi ECCAD and Paul,
    I've just create a program about "ssname" and "sslength",are there wrong
    interpretation in this below ?
    can you suggest it and lets me to know where I do wrong location,thanks.
    Best regards
    Ade Suharna
    ;------------------------------------------
    (defun lines ()
    (setq p1 (list 0 0))
    (setq p2 (list 10 0))
    (setq p3 (list 0 10))
    (setq p4 (list 10 10))
    (setq p5 (list 0 20))
    (setq p6 (list 10 20))
    ;------------------------
    (command "_line" p1 p2 "") ; draw a line
    (command "_line" p3 p4 "") ; draw a line
    (command "_line" p5 p6 "") ; draw a line
    ;------------------------
    (setq ss (ssget)) ; user input collect
    object
    (setq long (sslength ss)) ; determine how much
    entity
    ;-------------------------
    (setq count1 (setq 1st_entity (ssname ss 0)))
    (setq 1st_item (entget(ssname ss 0)))
    (setq 1st_list_p1 (cdr (assoc 10 1st_item))) ; same as point p1
    (setq 1st_list_p2 (cdr (assoc 11 1st_item))) ; same as point p2
    ;------------------------------------------
    (setq count2 (setq 2nd_entity (ssname ss 1)))
    (setq 2nd_item (entget(ssname ss 1)))
    (setq 2nd_list_p3 (cdr (assoc 10 2nd_item))) ; same as point p3
    (setq 2nd_list_p4 (cdr (assoc 11 2nd_item))) ; same as point p4
    ;------------------------------------------
    (setq count3 (setq erd_entity (ssname ss 2)))
    (setq 3rd_item (entget(ssname ss 2)))
    (setq 3rd_list_p5 (cdr (assoc 10 3rd_item))) ; same as point p5
    (setq 3rd_list_p6 (cdr (assoc 11 3rd_item))) ; same as point p6
    )
     
    Adesu, Jul 22, 2004
    #9
  10. Adesu

    zeha Guest

    Hi Ade,

    look at the modified code

    ;------------------------------------------
    (defun lines ( / p1 p2 p3 p4 p5 p6 ss long count1 item list_p10 list_p11); set vars to local
    (setq p1 '( 0 0) p2 '( 10 0) p3 '( 0 10) p4 '( 10 10) p5 '( 0 20) p6 '( 10 20))
    ;------------------------
    (command "_line" p1 p2 "") ; draw a line
    (command "_line" p3 p4 "") ; draw a line
    (command "_line" p5 p6 "") ; draw a line
    ;------------------------
    (setq ss (ssget) long (sslength ss)) ; user input collect object and determine how much entity
    ; but you don't now wich object the user choose, neither the sequence.
    ; the way you choose is only true if you first pick the line p1 p2
    ; mostly you intersted by the coordinate
    ; the follow modified give' a list of coordinates from dxf code 10 and if exist code 11

    ;-------------------------
    (setq count1 0); >>>>> sets a counter to 0
    (while (< count1 long); >>>>> do while long > count1
    (setq item (entget(ssname ss count1)))
    (setq list_p10 (cons (cdr (assoc 10 item)) list_p10)) ; >>>>>make a list of first points
    (setq list_p (cdr (assoc 11 item)))
    (if list_p (setq list_p11 (cons list_p list_p11))) ; >>>>> make a list of second points if exist
    (setq count1 (1+ count1)); count up with one
    )
    (foreach pt list_p10 (command "_.point" "_Non" pt)); >>>> draws a point on dxf code 10
    (princ list_p10) ; print all code 10
    (princ "\n"); print new line
    (princ list_p11); print all code 11
    (princ); print quiet
    )
     
    zeha, Jul 22, 2004
    #10
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.