SSName won't work

Hi!

I have code it work in AutoCAD but when I am trying to run in BricsCAD it not working.

(setq pickpt (last (last (ssname ss 0))))

Any suggestion

Welcome!

It looks like you're new here. Sign in or register to get started.

Comments

  • Hello.

    The code might not be complete.

    (ssname ...) returns an entity name.

    (last ...) requires a list as argument.
    When used with an entity name, it will trigger an error in both Bricscad and Autocad.

  •  (setq ss (ssget ":S"))

    (if (/= ss nil)
    (progn
    (setq ent (ssname ss 0)
    pickpt (last (last (car (ssname ss 0)))))
    (setq sel ss)
    (repeat (setq idx (sslength sel))
    (setq enx (entget (ssname sel (setq idx (1- idx))))
    sph (cdr (assoc 10 enx)) ;Start point of line
    eph (cdr (assoc 11 enx)) ;End point of line
    )
    ) ;Repeat
    (setq BLen (distance sph eph))
    (setq eph1 eph)
    (setq sph1 sph)
    (if (> (distance sph pickpt) (distance pickpt eph))
    (progn
    (setq sph eph1)
    (setq eph sph1) )
    ) ))

  • Hello.

    Thank you for posting a larger sequence of code.
    However, I was referring to the specific use of (last) - I thought there was something missing there.

    (car) doesn't work either with an entity name, it also requires a list as argument.

    If the purpose is to get the coordinates of the last point input in the drawing, then you could use the LASTPOINT system variable.
    For instance:
    (setq pickpt (getvar 'lastpoint))

  • A ssname does not have a pick point, rather its a entity, so depending on the entity you can get various Point properties, start, end, insertionpoint and so on. Explain what point your after with relation to an object.

  • edited October 2024

    Dear @AvinashPatil

    seems, for your code, you copied + adjusted it from other code using (entsel) ? 😉

    As (entsel) returns a list (ENAME POINT)

    : (entsel)
    Select entity: (<Entity name: 66674910> (2219.78545011787 923.283289942553 0.0))

    Alan & Virgil explained that (ssname …) returns an ENAME, not a list …

    And your code can not + does not work in AutoCAD :

    Command: (setq ss (ssget))

    Select objects: Specify opposite corner: 1 found

    Select objects: <Selection set: 5>

    Command: (setq pickpt (last (last (ssname ss 0))))
    ; error: bad argument type: listp <Entity name: 275d20e25e0>

    many greetings !

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.