Where does the insertion point go?

Discussion in 'AutoCAD' started by anton, Nov 2, 2004.

  1. anton

    anton Guest

    Hi, everyone.
    I need a little help from you, please.
    I use a button macro ^c^c_EA;10,10: for edit an attribute value
    where EA is an Autolisp (not created by me, of course) and 10,10 are the coordinates of the insertion point of the attribute. This works perfectly, but I would like to put the coordinates of the insertion point inside the autolisp (so i wouldl delete the botton macro)and run the new autolisp.
    I double my Thanks if you can be explicit, i am starting
    with autolisp

    it is the autolisp(its dialog ea doesn't matter now)

    (defun c:ea (/ att el oldVal dh newVal)
    (while (setq att (car (nentsel "\nSelect attribute: ")))
    (setq el (entget att))
    (cond
    ((not (= (cdr (assoc 0 el)) "ATTRIB"))
    (princ "\nObject selected is not an attribute.")
    )
    ('T
    (setq
    oldVal (cdr (assoc 1 el))
    dh (load_dialog "ea")
    )
    (if (and dh (new_dialog "ea" dh))
    (progn
    (set_tile "att_edit" oldVal)
    (action_tile "att_edit" "(setq newVal $value)")
    (if (= (start_dialog) 1) ;if ok is picked...
    (progn
    (setq el (subst (cons 1 newVal) (assoc 1 el) el))
    (entmod el)
    (entupd att)
    )
    )
    (unload_dialog dh)
    ) ;end progn
    (exit) ;if the DCL file can't be found
    ) ;end if
    ) ;end 'T
    ) ;end cond
    ) ;end while
    (princ)
    );end c:ea
     
    anton, Nov 2, 2004
    #1
  2. anton

    ECCAD Guest

    This might do it. Have fun with it.

    (defun c:ea (/ att el oldVal dh newVal P1 P2)
    (setq P1 (list 10.0 10.0 0.0)); establish the beginning point
    (setq P2 (list (+ (car P1) 0.125)(+ (cadr P1) 0.0))); point to right + 1/8"
    (setq att (ssget "C" P1 P2)); get 'crossing' point1 and 2
    (setq att (ssname att 0)); get entity

    ;;;(while (setq att (car (nentsel "\nSelect attribute: "))); requires a pick.
    (setq el (entget att))
    (cond
    ((not (= (cdr (assoc 0 el)) "ATTRIB"))
    (princ "\nObject selected is not an attribute.")
    )
    ('T
    (setq
    oldVal (cdr (assoc 1 el))
    dh (load_dialog "ea")
    )
    (if (and dh (new_dialog "ea" dh))
    (progn
    (set_tile "att_edit" oldVal)
    (action_tile "att_edit" "(setq newVal $value)")
    (if (= (start_dialog) 1) ;if ok is picked...
    (progn
    (setq el (subst (cons 1 newVal) (assoc 1 el) el))
    (entmod el)
    (entupd att)
    )
    )
    (unload_dialog dh)
    ) ;end progn
    (exit) ;if the DCL file can't be found
    ) ;end if
    ) ;end 'T
    ) ;end cond
    ;;) ;end while
    (princ)
    );end c:ea

    Bob
     
    ECCAD, Nov 2, 2004
    #2
  3. anton

    anton Guest

    Thanks Bob, for your answer. I appreciate it.
    When I ran the autolisp, it was on error:
    ;error: bad argument type:
    lselsetp nil. Then i did this

    (defun c:ea (/ att el oldVal dh newVal P1 P2)
    ;(setq P1 (list 10.0 10.0 0.0)); establish the beginning point
    ;(setq P2 (list (+ (car P1) 0.125)(+ (cadr P1) 0.0))); point to right + 1/8"
    (setq att (ssget "C" '(15 2) '(3 15))); get 'crossing' point1 and 2
    (setq att (ssname att 0)); get entity

    but says it is not an attribute.
    When i run the button macro, the area around the insertion point is zoomed, so never get an error because of pickbox size.

    I use the insertion point of text to edit these too (their position
    is always the same, you know) and edit others entities.
    I though it was a simple way to give the insertion point inside an autolisp that call for a pick.

    Please, if you find how to fix it, let me know.

    Thanks in advance
     
    anton, Nov 2, 2004
    #3
  4. anton

    ecable Guest

    You are selecting the block, not the attribute.
    Try
    (setq att (ssget "C" '(15 2) '(3 15))); get 'crossing' point1 and 2
    (setq att (ssname att 0)); get entity
    (setq att (entnext att))
    This assumes that you only have one attribute, or that the attribute is the first sub-entity.
    Hope that helps.
     
    ecable, Nov 2, 2004
    #4
  5. anton

    T.Willey Guest

    If he knows the point, and the point doesn't change, couldn't he do (setq att (nentselp '(10 10 0))) ?

    Tim
     
    T.Willey, Nov 2, 2004
    #5
  6. anton

    ECCAD Guest

    TIm,
    He needs both text and attrib editor. The approach is wrong to
    do a 'fixed' position in either case. Better to select with a pick,
    and edit either ?
    Anton was correct (for the example) you need to do:
    (setq att (entnext att))
    to 'extract' the attrib.

    See my attached .zip for a better way.

    Thanks,

    Bob
     
    ECCAD, Nov 2, 2004
    #6
  7. anton

    ECCAD Guest

    Tim,
    I tried that, but if you have a "CCCC" or some text font that
    does not 'touch' 10 10 0, it doesn't pick it up. Best to pick it.?

    Bob
     
    ECCAD, Nov 2, 2004
    #7
  8. anton

    ECCAD Guest

    Here's your program, with needed modifications.

    (defun c:ea (/ att el oldVal dh newVal P1 P2)
    (setq P1 (list 10.0 10.0 0.0)); establish the beginning point
    (setq P2 (list (+ (car P1) 0.125)(+ (cadr P1) 0.0))); point to right + 1/8"
    (setq att (ssget "C" P1 P2)); get 'crossing' point1 and 2
    (setq att (ssname att 0)); get entity
    (setq att (entnext att)); [per ecable]
    (setq el (entget att))
    (cond
    ((not (= (cdr (assoc 0 el)) "ATTRIB"))
    (princ "\nObject selected is not an attribute.")
    )
    ('T
    (setq
    oldVal (cdr (assoc 1 el))
    dh (load_dialog "ea")
    )
    (if (and dh (new_dialog "ea" dh))
    (progn
    (set_tile "att_edit" oldVal)
    (action_tile "att_edit" "(setq newVal $value)")
    (if (= (start_dialog) 1) ;if ok is picked...
    (progn
    (setq el (subst (cons 1 newVal) (assoc 1 el) el))
    (entmod el)
    (entupd att)
    )
    )
    (unload_dialog dh)
    ) ;end progn
    (exit) ;if the DCL file can't be found
    ) ;end if
    ) ;end 'T
    ) ;end cond
    (princ)
    );end c:ea

    Bob
     
    ECCAD, Nov 2, 2004
    #8
  9. anton

    anton Guest

    Hi Bob, and everyone helping.
    No working yet. The same error.
    I know that it is not the right approach to attributes. It is like a First Aid when i don't know how to work with attributes. But i can modify every ot them knowing the insertion points.
    Actually, it is a Title Block i created, and have 8 attributes (dealer, date, page, job number, etc).I don't insert it. It is always in the same position of my template.
    If i click on one of the value, (grips pop-up), then i can read the coordinates of the insertion point (placing the cursor over the grip ).

    If i want to edit a text (always in the same position) i do:
    (command "ddedit" "10,10" "") 10,10 are the coordinates of insertion point

    By the way, is there something like this for

    (command "autolispname" "coordinates ins point" "") ??

    I appreciate your help. Thanks

    Anton
     
    anton, Nov 2, 2004
    #9
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.