Rubberband

Discussion in 'AutoCAD' started by TCEBob, Jun 21, 2004.

  1. TCEBob

    TCEBob Guest

    Is there a way to rubberband from a point when not using getpoint, getangle,
    etc.? It happens that I want to select a point and then select some text.
    Object: leader. Best I can do so far is to fake a point near the text and then
    select the text "nea" the point. But the user has to cooperate and that makes it
    iffy. How about grread?

    rs
     
    TCEBob, Jun 21, 2004
    #1
  2. TCEBob

    Scrutch Guest

    Not sure what you want here...? *Maybe* you are looking for the insertion of the text? The insert point is where the text was justified when placed in the drawing.
    Example:
    Dist (di)
    Point (nod)
    Insertion (ins)

    Cheers,
    Scrutch
     
    Scrutch, Jun 21, 2004
    #2
  3. TCEBob

    ECCAD Guest

    Suggestion:
    Since you already 'calculated' a point..use that point (e.g. Pt1) as a reference, and use (setq Pt2 (getpoint Pt1 "Pick ...")).

    Bob
     
    ECCAD, Jun 21, 2004
    #3
  4. TCEBob

    TCEBob Guest

    Lemme see if I can explain: I don't want a second point. I want to select
    something and while wandering around on the screen have a rubber band follow me.
    Then when I select something I'd like the rubber band to disappear.

    rs
     
    TCEBob, Jun 21, 2004
    #4
  5. TCEBob

    andywatson Guest

    Here's something I created a while back...
    I hasn't been thoroughly tested, use at your own risk :)

    Just load and start with "rubberband".
    It will ask you to pick points, and as you pick them, it will "rubberband" them.

    Andrew

    Code:
    ;; function 2dp
    ;; receives list of coordinates
    ;; returns 2d list of coordinates
    (defun 2dp (p / )
    (list (car p) (cadr p))
    ); defun
    
    
    ;; rubberband.lsp
    ;; program prompts user for polygonal boundary, using "grvecs" function
    ;; to connect picked points with stretching lines.
    (defun c:rubberband ( / p1 continue grInput lstP lstVecs tmpP tmpP1 tmpP2)
    (prompt "\nPick your rubberband points...")
    ;; add first picked point to lstP
    (setq p1 (2dp (getpoint "\nFirst point: "))
    lstP (cons p1 lstP)
    continue T)
    (prompt "\nNext point: ")
    ;; while user does not hit <enter>
    (while (and (/= grInput '(2 13)) (/= (car grInput) 12))
    ;; track user device input
    (setq grInput (grread T 14 0))
    (redraw)
    (cond
    
    ;; user entered keyboad entry
    ((= (car grInput) 2)
    (setq intAscii (cadr grInput))
    ;; user typed "U" for undo
    (if (= "U" (strcase (chr intAscii)))
    (if (> (length lstP) 1)
    (progn
    ;; remove last point from lstP
    (setq lstP (reverse (cdr (reverse lstP))))
    ;; if lstP contains only one picked point
    (if (< (length lstP) 2)
    ;; do not show undo option
    (prompt "\nNext point: ")
    ;; otherwise, show undo option
    (prompt "\nNext point [Undo]: ")
    ); if
    ); progn
    ); if
    ); if
    )
    
    ;; user picked point
    ((= (car grInput) 3)
    ;; strip z elevation and add to lstP
    (setq tmpP (2dp (cadr grInput))
    lstP (append lstP (list tmpP)))
    (prompt "\nNext point [Undo]: ")
    )
    
    ;; user is currently dragging mouse
    ((= (car grInput) 5)
    ;; strip z from current cordinate of mouse crosshairs
    ;; remove old lstVecs values
    ;; make copy of lstP
    (setq tmpP (2dp (cadr grInput))
    lstVecs nil
    lsttmp lstP)
    ;; loop while there are at least two points in lsttmp
    ;; get second point
    (while (setq tmpP2 (cadr lsttmp))
    ;; get first point
    (setq tmpP1 (car lsttmp))
    ;; add "vector" from tmpP1 to tmpP2 to vector list
    (setq lstVecs (append lstVecs (list 7 tmpP1 tmpP2)))
    ;; remove first element from lsttmp
    (setq lsttmp (cdr lsttmp))
    ); while
    ;; append last point in lstP
    (setq lstVecs (append
    (list 7 (last lstP) tmpP)
    lstVecs
    (list 7 tmpP (car lstP))))
    ;; draw rubberband
    (grvecs lstVecs)
    )
    (T nil)
    ); cond
    ); while
    (redraw)
    (princ "\nHere is your list of picked points: ")
    (princ lstP)
    (princ)
    ); defun
    
     
    andywatson, Jun 21, 2004
    #5
  6. (defun c:Tst (/ pt1 pt2 ent)
    (setq Pt1 (print (getpoint "Base Point: ")))
    (setq Pt2 (print (getpoint Pt1 "Pick ...")))
    (setq ent (nentselp pt2))
    )
     
    Allen Johnson, Jun 21, 2004
    #6
  7. If you all ready have the 2 points you can use (grdraw Point1 Point2
    ColorNumber) to draw a temporary screen line. Then you can use (grdraw
    Point1 Point2 0) to un-draw or not (as soon as the user pans or regens the
    temporary line disappears).
     
    Alan Henderson @ A'cad Solutions, Jun 21, 2004
    #7
  8. TCEBob

    Scrutch Guest

    Andy,

    Me 2... However I see some merit in your routine. Haven't been able to make it work for me but I will dig into it. I can't get the routine to exit without hitting the escape key, must have something to do with the enter key guy...? If you want to help great, if not I'll fumble around with it.

    Cheers,
    Scrutch
     
    Scrutch, Jun 21, 2004
    #8
  9. TCEBob

    TCEBob Guest

    Thanks, Andy. I'll give it a try.

    rs
     
    TCEBob, Jun 21, 2004
    #9
  10. TCEBob

    TCEBob Guest

    It was supposed to say "thanks Andy and Allen."

    rs
     
    TCEBob, Jun 21, 2004
    #10
  11. TCEBob

    Scrutch Guest

    Andy,
    I've got it working now... Thanks for sharing this routine.
    I can think of several ways that I can make use of a routine like this. It's a pretty slick little routine.
    Thanks again,
    Scrutch
     
    Scrutch, Jun 21, 2004
    #11
  12. TCEBob

    CAB2k Guest

    That's the way I would do it Andy :)
    Just kidding Allen

    Code:
    (defun c:tst (/ pt1 pt2 ent loop)
    (setq loop t
    ent nil)
    ;;  allows exit at first pick only
    (if (setq pt1 (getpoint "Pick Base Point: "))
    (while loop
    (if (setq pt2 (getpoint pt1 "Select Object ..."))
    (progn
    (if (setq ent (nentselp pt2))
    (setq Loop nil)
    (prompt "\nNothing selected. Try again!")
    )
    )
    (prompt "\nYou must make a selection.")
    )
    )
    (prompt "\nUser quit. Return ")
    )
    (if ent ent nil)
    )
    
     
    CAB2k, Jun 21, 2004
    #12
  13. TCEBob

    TCEBob Guest

    Allen,

    I never quite understood nentselp. Thanks for showing it in action.

    I modified your routine a bit to include osnap "ins". One little thing, why the
    print commands? Seems to work just fine without 'em.

    rs
     
    TCEBob, Jun 21, 2004
    #13
  14. TCEBob

    TCEBob Guest

    Well, let's give And. . .Allen the benefit of doubt that, given a chance, he
    would add in all those goodies. I will study your code closely.

    rs

     
    TCEBob, Jun 21, 2004
    #14
  15. TCEBob

    andywatson Guest

    Don't thank me...you asked for apples and I gave you oranges :)
     
    andywatson, Jun 21, 2004
    #15
  16. TCEBob

    TCEBob Guest

    Don't flagellate yourself. Your oranges will be helpful in the future. (I keep
    this stuff.)

    rs
     
    TCEBob, Jun 21, 2004
    #16
  17. TCEBob

    CAB2k Guest

    For more on nentsel...
    Goto
    http://www.smadsen.com/

    Select the following on the left column:
    Selections
    By User
    Subentities
     
    CAB2k, Jun 22, 2004
    #17
  18. TCEBob

    TCEBob Guest

    Thanks, all. Just for fun, here's the final cut:

    (defun c:rub ( / ent) ;rubberband to select an object
    (#osset 64) ;insert
    (setq ent(nentselp (getpoint (getpoint "Base Point: ") "Select text: ")))
    (#osset -1) ;restore
    (princ))

    rs
     
    TCEBob, Jun 22, 2004
    #18
  19. TCEBob

    randy benson Guest

    what in the wide world of sports is (#osset...)?
     
    randy benson, Jun 22, 2004
    #19
  20. TCEBob

    ECCAD Guest

    You don't HAVE to use Pt2. Just using the getpoint function with original point - Pt1, as a reference point, and rubber-band effect. Since you are going to 'pick' something, use the 2nd point to do ssget at that point.

    Bob
     
    ECCAD, Jun 22, 2004
    #20
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.
Similar Threads
Loading...