Not working!! HELP PLEASE? :o(

Discussion in 'AutoCAD' started by Kieren, May 27, 2004.

  1. Kieren

    Kieren Guest

    Can someone PLEASE tell me where I am going wrong?!
    Looking to update block attrib with numerical value (from insertion point) followed by the letter N.
    Think problem is in line

    (setq ad (strcat (rtos (/ xp 1000) 2 3) "N"))

    but damned if I can see it!
    Times ticking away, and I have a very tight deadline to meet.
    Thanks all who look,
    ..::KIEREN::..


    -------------------------------------------------------------------
    (defun c:upcv (/ olddimz ss i en xp an ad)

    ;;;TRIM RIGHT ZEROS
    (setq olddimz (getvar "DIMZIN"))
    (setvar "DIMZIN" 8)

    ;;;MAKE SELECTION SET
    (while (not ss)
    (princ "\nSelect Inserts With XVAL Attribute")
    (setq ss
    (ssget
    (list (cons 0 "INSERT")
    (cons 66 1)
    (cons 67 (if (= (getvar "TILEMODE") 1) 0 1))))))

    ;;;SET EASTING VAL
    (setq i (sslength ss))
    (while (not (minusp (setq i (1- i))))
    (setq en (ssname ss i)
    xp (car (cdr (assoc 10 (entget en))))
    an en)
    (while (/= "SEQEND" (cdr (assoc 0 (entget (entnext an)))))
    (setq an (entnext an)
    ad (entget an))
    (and (assoc 2 ad)
    (= "EASTING" (strcase (cdr (assoc 2 ad))))
    (setq ad (strcat (rtos (/ xp 1000) 2 3) "N"))
    (assoc 1 ad) ad))
    (entmod ad)
    (entupd en))))

    ;;;RESET DIMZIN
    (setvar "DIMZIN" olddimz)
    (prin1))
    -------------------------------------------------------------------
     
    Kieren, May 27, 2004
    #1
  2. Kieren

    Jeff Mishler Guest

    Try this, it did have to do with that line and the ones aound it.

    (defun c:upcv (/ olddimz ss i en xp an ad)

    ;;;TRIM RIGHT ZEROS
    (setq olddimz (getvar "DIMZIN"))
    (setvar "DIMZIN" 8)

    ;;;MAKE SELECTION SET
    (while (not ss)
    (princ "\nSelect Inserts With XVAL Attribute")
    (setq ss
    (ssget
    (list (cons 0 "INSERT")
    (cons 66 1)
    (cons 67
    (if (= (getvar "TILEMODE") 1)
    0
    1
    )
    )
    )
    )
    )
    )

    ;;;SET EASTING VAL
    (setq i (sslength ss))
    (while (not (minusp (setq i (1- i))))
    (setq en (ssname ss i)
    xp (car (cdr (assoc 10 (entget en))))
    an en
    )
    (while (/= "SEQEND" (cdr (assoc 0 (entget (entnext an)))))
    (setq an (entnext an)
    ad (entget an)
    )
    (and (assoc 2 ad)
    (= "EASTING" (strcase (cdr (assoc 2 ad))))
    (setq ad (subst (cons 1 (strcat (rtos (/ xp 1000) 2 3) "N"))
    (assoc 1 ad)
    ad
    )
    )
    (entmod ad)
    (entupd en)
    )
    )
    )

    ;;;RESET DIMZIN
    (setvar "DIMZIN" olddimz)
    (prin1)
    )

    Good luck,
    Jeff
     
    Jeff Mishler, May 28, 2004
    #2
  3. Kieren

    andywatson Guest

    Kieren,
    I know you are trying to update a block with northing and easting attributes to the block's current coordinates, correct?
    A few questions:
    What's the block's name?
    What is the northing attribute's tag?
    What is the easting attribute's tag?
    It appears you want the northing value to read "1233.45N"
    Is it the same format for easting?
    What EXACTLY do you want a program to do, and how EXACTLY should the information appear.

    I copied and pasted your code, and it's missing a closing bracket...meaning anything could be wrong. I have a routine that updates northing's and easting's, if you let me know the above information I can tailor it to your needs.
    Andrew
     
    andywatson, May 28, 2004
    #3
  4. Kieren

    T.Willey Guest

    (setq ad (strcat (rtos (/ xp 1000) 2 3) "N"))
    You set ad to a string, it has no "assoc 1". What are you trying to do here??

    Tim
     
    T.Willey, May 28, 2004
    #4
  5. Kieren

    T.Willey Guest

    (defun c:upcv (/ olddimz ss i en xp an ad)

    ;;;TRIM RIGHT ZEROS
    (setq olddimz (getvar "DIMZIN"))
    (setvar "DIMZIN" 8)

    ;;;MAKE SELECTION SET
    (while (not ss)
    (princ "\nSelect Inserts With XVAL Attribute")
    (setq ss
    (ssget
    (list (cons 0 "INSERT")
    (cons 66 1)
    (cons 67
    (if (= (getvar "TILEMODE") 1)
    0
    1); if
    ); cons
    ); list
    ); ssget
    ); setq
    ); while

    ;;;SET EASTING VAL
    (setq i (sslength ss))
    (while (not (minusp (setq i (1- i))))
    (setq en (ssname ss i)
    xp (car (cdr (assoc 10 (entget en))))
    an en)
    (while (/= "SEQEND" (cdr (assoc 0 (entget (entnext an)))))
    (setq an (entnext an)
    ad (entget an))
    (if (= (assoc 2 ad) "EASTING")
    (setq ad (strcat (rtos (/ xp 1000) 2 3) "N"))
    (setq ad (assoc 1 ad))
    ); if
    );while
    (entmod ad)
    (entupd en)
    );while

    ;;;RESET DIMZIN
    (setvar "DIMZIN" olddimz)
    (prin1)
    ); defun


    Best I could do for now. If you still need help I can try something tomorrow, but you may get better help before then.

    Tim
     
    T.Willey, May 28, 2004
    #5
  6. Not sure what you are trying to do, but here is another solution.
    Block = NE with Attributes NORTH and EAST (in that order)

    (defun C:UDB ()
    (setq ES (entsel "\nSelect Block to Update North and East attributes with
    block's Insertion Point ? "))
    (while ES ;loop until ENTER key hit or nothing selected
    (setq EG (entget (car ES)))
    (if (and (= (cdr (assoc 0 EG)) "INSERT") (= (cdr (assoc 2 EG)) "NE"))
    ;check if entity selected is NE block
    (progn
    (setq A1 (entget (entnext (cdr (assoc -1 EG)))))
    ;get 1st attribute
    (setq A2 (entget (entnext (cdr (assoc -1 A1)))))
    ;get 2nd attribute
    (setq P0 (cdr (assoc 10 EG)))
    ;get NE block insertion point
    (setq NORTH (strcat (rtos (/ (cadr P0) 1000) 2 3) "N"))
    ;calculate northing
    (setq EAST (strcat (rtos (/ (car P0) 1000) 2 3) "E"))
    ;calculate easting
    (setq A1 (subst (cons 1 NORTH) (assoc 1 A1) A1)) ;change 1st
    attribute
    (setq A2 (subst (cons 1 EAST) (assoc 1 A2) A2)) ;update
    2nd attribute
    (entmod A1) ;update 1st attribute
    (entmod A2) ;update 2nd attribute
    (entupd (cdr (assoc -1 EG))) ;redraw block to show new attributes
    )
    (progn "\nError - Entity Seleted is not NE block.")
    )
    (setq ES (entsel "\nSelect Next Block to Update North and East attributes
    with block's Insertion Point ? "))
    )
    (princ)
    )
     
    Alan Henderson @ A'cad Solutions, May 28, 2004
    #6
  7. Kieren

    David Bethel Guest

    (setq nv (strcat (rtos (/ xp 1000) 2 3) " N"))
    (setq ad (subst nv (assoc 1 ad) ad))
    (entmod ad)
    (entupd en)


    Should work.

    -David
     
    David Bethel, May 28, 2004
    #7
  8. Kieren

    bru Guest

    (setq ad (subst (cons 1 nv) (assoc 1 ad) ad))
     
    bru, May 28, 2004
    #8
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.