Help for subst

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

  1. Adesu

    Adesu Guest

    (setq listpos (entget (car loc)))

    (-1 . <Entity name: 1496580>) (0 . "TEXT") (330 . <Entity name: 14964f8>) (5
    .. "48") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 .
    "AcDbText") (10 6.84953 8.45375 0.0) (40 . 2.5) (1 . "Adesu") (50 . 0.0) (41
    .. 1.0) (51 . 0.0) (7 . "Standard") (71 . 0) (72 . 0) (11 0.0 0.0 0.0) (210
    0.0 0.0 1.0) (100 . "AcDbText") (73 . 0))

    (setq degpos2 45
    const (cons 50 degpos2)
    ed (subst 'const (assoc 50 listpos)ed)))

    Can someone's help me to "subst" this program,I've got trouble to solve
    it,thanks a lot,the result always "nil",what wrong in format "subst".
    Best regards
    Ade Suharna
     
    Adesu, Jul 30, 2004
    #1
  2. Adesu

    zeha Guest

    (subst (cons 50 degpos2)
    (assoc 50 listpos) lispos)
     
    zeha, Jul 30, 2004
    #2
  3. Adesu

    Adesu Guest

    Hi zeha ,thanks a lot ,here my program
    ;-------------------------------------------------------------------------
    ; mot is stand for making of oblig text
    ; Design by Ade Suharna
    ; 30 july 2004
    ; edit by zeha 30/07/2004 1).
    (defun dtr (a)
    (* pi (/ a 180.0)))
    (defun c:mot (/ oldosmode oldcmdecho loc deg tex listpos
    degpos1 texs degpos2 ed)
    (setq oldosmode (getvar "osmode")) ; get osmode setting
    (setvar "osmode" 0) ; osmode set to 0
    (setq oldcmdecho (getvar "cmdecho")) ; get cmdecho setting
    (setvar "cmdecho" 0) ; cmdecho set to 0
    (vl-load-com)
    (setq loc (entsel "\nCLICK TEXT FOR ROTATE:"))
    (setq deg (getreal "\nENTER NEW VALUE FOR OBLIGUING:")) ; set 45
    (setq tex "TEXT")
    (setq listpos (entget (car loc)))
    (setq degpos1 (cdr (assoc 50 listpos)))
    (setq texs (cdr (assoc 0 listpos)))
    (if loc (cond ((/= tex texs)(princ "YOUR CHOOSE OBJECT INVALID"))
    ((= tex texs)(progn
    (setq degpos2 deg)
    (setq ed
    (subst
    (cons 50 degpos2) ; 1).
    (assoc 50 listpos) listpos))
    (entmod ed)
    (entupd listpos)
    ) ; end of progn
    )
    ) ; end of cond
    ) ; end of if
    (setvar "osmode" oldosmode) ; return setting
    (setvar "cmdecho" oldcmdecho) ; return setting
    (princ)
    )

    ;---------------------------------------------------------------------------
     
    Adesu, Jul 30, 2004
    #3
  4. Adesu

    zeha Guest

    Hi Adesu,

    I have your function comment and renamed to motOld
    I have mot modified to a function for multiple text objects, not attributes and dimension text or attrubutes definition.

    I hope this is useful.


    (defun c:motOld (/ oldosmode oldcmdecho loc tex listpos
    degpos1 texs degpos2 ed)
    (if (/= (type deg)'REAL)(setq deg 45.0)); !! added his line for default deg
    ;;(setq oldosmode (getvar "osmode")) ; !! not neccesary in this program
    ;;(setvar "osmode" 0) ; !! not neccesary in this program
    (setq oldcmdecho (getvar "cmdecho")) ; get cmdecho setting
    (setvar "cmdecho" 0) ; cmdecho set to 0
    ;;(vl-load-com) !! not neccesary in this program ther is no vl- function used
    (setq loc (entsel "\nCLICK TEXT FOR ROTATE: ")); !! add a space for nice display
    (setq deg (strcat (getreal "\nENTER NEW VALUE FOR OBLIGUING <"(rtos deg 2)">: "))) ; set 45
    ;;(setq tex "TEXT") !! not neccesary it used only one time
    (setq listpos (entget (car loc))); !! what is the user picked none or give's a return
    (setq degpos1 (cdr (assoc 50 listpos)))
    (setq texs (cdr (assoc 0 listpos)))
    (if loc (cond ((/= tex texs)(princ "YOUR CHOOSE OBJECT INVALID"))
    ((= tex texs)
    ;(progn !! not neccesary in cond statement
    (setq degpos2 deg)
    (setq ed
    (subst
    (cons 50 degpos2) ; 1).
    (assoc 50 listpos) listpos))
    (entmod ed)
    (entupd listpos)
    ;;) ; end of progn !! not neccesary in cond statement
    )
    ) ; end of cond
    ) ; end of if
    ;;(setvar "osmode" oldosmode) ; return setting
    (setvar "cmdecho" oldcmdecho) ; return setting
    (princ)
    )


    ;; here is a example for more then one text entity
    (defun c:mot (/ oldcmdecho sstext deg i listpos)
    (if (/= (type globalDeg)'REAL)(setq globalDeg 45.0)); this is a global variable for example to be use the second time
    (setq oldcmdecho (getvar "cmdecho")) ; get cmdecho setting
    (setvar "cmdecho" 0) ; cmdecho set to 0
    (prompt "\nSELECT TEXT FOR ROTATE: ")
    (if (setq sstext (ssget '((0 . "*TEXT")))); filter only for text or mtext
    (progn
    (initget 0); Enter allowed (bit 0 1 2) 0 + 0 + 0
    (setq deg (getangle (strcat"\nENTER NEW VALUE FOR OBLIGUING <"(angtos globalDeg (getvar "aunits") 3)">: "))) ; set 45
    (if deg (setq globalDeg deg)(setq deg globalDeg)); test if the user give a input
    (setq i 0); counter for use ssname
    (while (> (sslength sstext) i)
    (setq listpos (entget (ssname sstext i)) i (1+ i)); counter increment
    (entmod (subst (cons 50 deg)(assoc 50 listpos) listpos))
    (entupd (cdr (assoc -1 listpos)))
    );; end while
    (princ (strcat "CHANGED "(itoa (sslength sstext))" TEXT OBJECT."))
    );; end of progn
    (princ "YOUR CHOOSE NOT A TEXT OBJECT.")
    );; end if
    (setvar "cmdecho" oldcmdecho) ; return setting
    (princ)
    )

    Good luck.
     
    zeha, Aug 1, 2004
    #4
  5. Adesu

    Fatty Guest

    ;;;Hallo, Ade!
    ;;;I think your problem solve like this:

    (setq loc (entsel))
    (setq listpos (entget (car loc)))
    (setq ed (entnext (car loc)))
    (setq degpos2 45.0
    const (cons 50 degpos2)
    listpos (subst const (assoc 50 listpos) listpos)
    )
    (entmod listpos)
    (entupd ed)

    ;this work correct with TEXT and MTEXT
    ;Note: value of 50 group is real not integer!!!

    ;;;Best regards,
    ;;;Fatty
     
    Fatty, Aug 2, 2004
    #5
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.