Is It Right Way to do?

Discussion in 'AutoCAD' started by John, May 10, 2004.

  1. John

    John Guest

    2002 ADT 3.3

    Autolisp beginner



    I'm trying to take room name "waiting room" and number "101" from room tag
    and put into door tag. The routine work fine but some problem needs to be
    solved. I'm able get room name but not able to get room number because data
    store same (cdr (assoc 1 EL)), please see (setq EL (entget (car EN))).
    Please advice me if there is other way to do it. Thank you for your help



    (defun c:DrInfo (/ EN EL RNA RNU DRO)

    (setvar "CMDECHO" 1)



    (setq EN (entsel "\nSelect Room Tag: ")) ;operator input

    (if EN ; Verfiy entity selction

    (progn

    (setq EL (entget (car EN))) ;verfiy it is a Attribute

    (if (= (cdr (assoc 0 EL)) "AEC_MVBLOCK_REF") ;verfy the Object name

    (setq RNA (cdr (assoc 1 EL)) ;get room name

    RNU (cdr (assoc 1 EL)) ;get room number, why the
    same assoc?

    )

    )

    )

    )

    (setq DRO (entsel "\nSelect Door Tag: "))

    (command "-PropertyDataEdit" "p" "" "HHADROBJECTS:Room Name" RNA "")

    (setq mes(strcat "Updated Door Name to" RNA))

    (prompt mes)

    (princ)

    )

    ;end



    (setq EL (entget (car EN)))

    ((-1 . <Entity name: 4044d1f8>) (0 . "AEC_MVBLOCK_REF") (330 . <Entity name:

    4041ecf8>) (5 . "BA87") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 .

    "A-Flor-Iden") (100 . "AecDbEntity") (102 . "{AEC_SUBOBJECT") (300 .

    "AecImpMvBlockRef") (100 . "AecImpObj") (3 . "") (100 . "AecImpEnt") (171 .
    0)

    (100 . "AecImpGeo") (10 2966.31 770.189 0.0) (15 1.0 0.0 0.0) (16 0.0 1.0
    0.0)

    (210 0.0 0.0 1.0) (360 . <Entity name: 4044d218>) (100 . "AecImpBlockRef")
    (341

    .. <Entity name: 40430c00>) (15 4.5 4.5 4.5) (100 . "AecImpMvBlockRef") (102
    ..

    "{AEC_DISP_REPBLOCK_INSTANCES") (100 . "AecImpObj") (3 . "") (100 .

    "AecImpArray") (90 . 1) (102 . "{AEC_SUBOBJECT") (300 .

    "AecMvBlockViewInstance") (100 . "AecImpObj") (3 . "") (100 .

    "AecMvBlockViewInstance") (341 . <Entity name: 40430b38>) (15 0.0 0.0 0.0)
    (102

    .. "{AEC_ATTRIBUTES") (100 . "AecImpObj") (3 . "") (100 . "AecImpArray") (90
    ..

    3) (102 . "{AEC_SUBOBJECT") (300 . "AecMvBlockAttribute") (100 .
    "AecImpObj")

    (3 . "") (100 . "AecMvBlockAttribute") (305 . "Room name") (340 . <Entity
    name:

    4041ec80>) (172 . 0) (341 . <Entity name: 4041eca0>) (149 . 0.0)
    (10 -7.17516

    1.0 0.0) (40 . 1.33333) (1 . "WAITING ROOM") (50 . 0.0) (41 . 1.0) (51 .
    0.0)

    (342 . <Entity name: 40442250>) (71 . 0) (72 . 1) (11 1.11022e-016 1.0 0.0)

    (210 0.0 0.0 1.0) (73 . 0) (2 . "ROOMOBJECTS:NAME") (70 . 0) (74 . 0) (173 .

    -2) (174 . 0) (343 . <Entity name: 0>) (102 . "AEC_SUBOBJECT}") (102 .

    "{AEC_SUBOBJECT") (300 . "AecMvBlockAttribute") (100 . "AecImpObj") (3 . "")

    (100 . "AecMvBlockAttribute") (305 . "Number") (340 . <Entity name:
    4041ec80>)

    (172 . 0) (341 . <Entity name: 4041eca0>) (149 . 0.0) (10 -1.5 -1.5 0.0) (40
    ..

    1.0) (1 . "101") (50 . 0.0) (41 . 1.29604) (51 . 0.0) (342 . <Entity name:

    40442250>) (71 . 0) (72 . 5) (11 1.5 -1.5 0.0) (210 0.0 0.0 1.0) (73 . 0) (2
    ..

    "ROOMOBJECTS:NUMBER") (70 . 0) (74 . 0) (173 . -2) (174 . 0) (343 . <Entity

    name: 0>) (102 . "AEC_SUBOBJECT}") (102 . "{AEC_SUBOBJECT") (300 .

    "AecMvBlockAttribute") (100 . "AecImpObj") (3 . "") (100 .

    "AecMvBlockAttribute") (305 . "Height") (340 . <Entity name: 4041ec80>) (172
    ..

    0) (341 . <Entity name: 4041eca0>) (149 . 0.0) (10 -0.735081 3.29583 0.0)
    (40 .

    0.5) (1 . "9'-0\"") (50 . 0.0) (41 . 1.0) (51 . 0.0) (342 . <Entity name:

    40442250>) (71 . 0) (72 . 1) (11 -0.0573105 3.29583 0.0) (210 0.0 0.0 1.0)
    (73

    .. 0) (2 . "SPACESTYLES:HEIGHT") (70 . 1) (74 . 0) (173 . -2) (174 . 0) (343
    ..

    <Entity name: 0>) (102 . "AEC_SUBOBJECT}") (102 . "AEC_ATTRIBUTES}") (102 .

    "AEC_SUBOBJECT}") (102 . "AEC_DISP_REPBLOCK_INSTANCES}") (102 .

    "AEC_SUBOBJECT}") (102 . "{AEC_NULLOBJECT}") (100 . "AecDbGeo") (100 .

    "AecDbBlockRef") (100 . "AecDbMvBlockRef"))
     
    John, May 10, 2004
    #1
  2. John

    ECCAD Guest

    (setq RNA (cdr (assoc 1 EL)) ;get room name
    RNU (cdr (assoc 1 EL)) ;
    Above will set variable RNA and RNU both to room name.
    You need to dig a level deeper to extract the room number.
    Hint: is (assoc 1), but not in 'EL'

    (342 . <Entity name: 40442250>) (71 . 0) (72 . 1) (11 1.11022e-016 1.0 0.0)
    (210 0.0 0.0 1.0) (73 . 0) (2 . "ROOMOBJECTS:NAME") (70 . 0) (74 . 0) (173 .
    -2) (174 . 0) (343 . <Entity name: 0>) (102 . "AEC_SUBOBJECT}") (102 .
    "{AEC_SUBOBJECT") (300 . "AecMvBlockAttribute") (100 . "AecImpObj") (3 . "")
    (100 . "AecMvBlockAttribute") (305 . "Number") (340 . <Entity name:
    4041ec80>)
    (172 . 0) (341 . <Entity name: 4041eca0>) (149 . 0.0) (10 -1.5 -1.5 0.0) (40. 1.0) (1 . "101") (50 . 0.0) (41 . 1.29604) (51 . 0.0) (342 . <Entity name:

    Bob

    40442250>) (71 . 0) (72 . 5) (11 1.5 -1.5 0.0) (210 0.0 0.0 1.0) (73 . 0) (2
     
    ECCAD, May 10, 2004
    #2
  3. John

    John Guest

    Thanks for the hint. spent hours but didn't get it.

    John

    (40. 1.0) (1 . "101") (50 . 0.0) (41 . 1.29604) (51 . 0.0) (342 . <Entity
    name:
    (2
     
    John, May 10, 2004
    #3
  4. John

    John Guest

    Good morning,

    Other hint please.

    John


    (40. 1.0) (1 . "101") (50 . 0.0) (41 . 1.29604) (51 . 0.0) (342 . <Entity
    name:
    (2
     
    John, May 11, 2004
    #4
  5. John

    ECCAD Guest

    See my post: 10th 19:40
    Bob
     
    ECCAD, May 11, 2004
    #5
  6. John

    John Guest

    Find messgae
    from ECCAD

    103 messages(s), 0 unread, monitoring for new items.

    I think, i found closer to my subject is

    Try adding:
    (setq csor (vl-sort c (function (lambda (e1 e2) (< (car e1) (car e2))))))
    ... just before
    (setq csor (vl-sort c (function (lambda (e1 e2) (< (cadr e1) (cadr e2))))))

    ????????????????????????????????????????????????????
     
    John, May 11, 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.