Results 1 to 6 of 6

Thread: Can this be done with reactors?

  1. #1
    Member kieren's Avatar
    Join Date
    2003-04
    Location
    Stafford, UK
    Posts
    34
    Login to Give a bone
    0

    Question Can this be done with reactors?

    Hi guys!
    I have this modified routine for placing text in PS giving the scale of a selected viewport.
    It works fine, but was wondering if this can be done by reactors, so that if the scale of the viewport is changed, the text updates with it?
    I have absolutely no idea about reactors. Is anyone kind enough to share a reactor if they have one that does this function? ;o)

    Many thanks,
    ..::KIEREN::..

    Code:
    ;;--------------------------------------
    (defun c:getvpscale (/ ent elist vpscale)
      (setq clay (getvar "clayer"))
      (setq ent (car (entsel "\nSelect viewport: ")))
      (if ent
        (progn
          (setq elist (entget ent))
          (cond ((= (cdr (assoc 0 elist)) "VIEWPORT") t)
            ((and (= (cdr (assoc 0 elist)) "LWPOLYLINE")
                (assoc 330 elist)
              )
              (setq elist (entget (cdr (assoc 330 elist))))
            )
            (t (princ "\nNot a valid viewport object....")(setq elist nil)))
          (if elist (setq vpscale (/ (cdr (assoc 45 elist)) (cdr (assoc 41elist)))))
        )
      )
      (princ "\nPosition text.....")
      (setvar "cmdecho" 0)
      (setq sst (strcat "Scale=1:"(rtos vpscale 2 0)))
      (setq clay (getvar "clayer"))
      (if (= (tblsearch "layer" "Z000T-ScaleText") nil)
        (command "layer" "m" "Z000T-ScaleText" "c" "4" "" "")
        (command "layer" "s" "Z000T-ScaleText" "")
      )
      (command ".text" "j" "m" pause 3 0 sst)
      (if vpscale
        (princ (strcat "\nActual Vpscale (3 dec places)= 1:" (rtos vpscale 2 3)))
        (princ "\nNothing selected.....")
      )
      (setvar "clayer" clay)
      (princ)
    )
    ;;--------------------------------------------------
    Last edited by Mike.Perry; 2004-10-06 at 11:57 AM. Reason: Code tags added

  2. #2
    All AUGI, all the time BCrouse's Avatar
    Join Date
    2003-04
    Location
    Bethlehem, PA
    Posts
    980
    Login to Give a bone
    0

    Default Re: Can this be done with reactors?

    Quote Originally Posted by kieren
    Hi guys!
    I have this modified routine for placing text in PS giving the scale of a selected viewport.
    It works fine, but was wondering if this can be done by reactors, so that if the scale of the viewport is changed, the text updates with it?
    I have absolutely no idea about reactors. Is anyone kind enough to share a reactor if they have one that does this function? ;o)

    Many thanks,
    ..::KIEREN::..

    Code:
    ;;--------------------------------------
    (defun c:getvpscale (/ ent elist vpscale)
      (setq clay (getvar "clayer"))
      (setq ent (car (entsel "\nSelect viewport: ")))
      (if ent
        (progn
          (setq elist (entget ent))
          (cond ((= (cdr (assoc 0 elist)) "VIEWPORT") t)
            ((and (= (cdr (assoc 0 elist)) "LWPOLYLINE")
                (assoc 330 elist)
              )
              (setq elist (entget (cdr (assoc 330 elist))))
            )
            (t (princ "\nNot a valid viewport object....")(setq elist nil)))
          (if elist (setq vpscale (/ (cdr (assoc 45 elist)) (cdr (assoc 41elist)))))
        )
      )
      (princ "\nPosition text.....")
      (setvar "cmdecho" 0)
      (setq sst (strcat "Scale=1:"(rtos vpscale 2 0)))
      (setq clay (getvar "clayer"))
      (if (= (tblsearch "layer" "Z000T-ScaleText") nil)
        (command "layer" "m" "Z000T-ScaleText" "c" "4" "" "")
        (command "layer" "s" "Z000T-ScaleText" "")
      )
      (command ".text" "j" "m" pause 3 0 sst)
      (if vpscale
        (princ (strcat "\nActual Vpscale (3 dec places)= 1:" (rtos vpscale 2 3)))
        (princ "\nNothing selected.....")
      )
      (setvar "clayer" clay)
      (princ)
    )
    ;;--------------------------------------------------
    How do you use this lisp?

  3. #3
    AUGI Addict Glenn Pope's Avatar
    Join Date
    2001-05
    Location
    Austin, TX USA
    Posts
    2,201
    Login to Give a bone
    0

    Default Re: Can this be done with reactors?

    It probably can be done. Your routine will have to be modified to remove all the command calls. They're not allowed with reactors.

    What version of AutoCAD are you running? Fields would be a lot easier to use.

  4. #4
    Member kieren's Avatar
    Join Date
    2003-04
    Location
    Stafford, UK
    Posts
    34
    Login to Give a bone
    0

    Default Re: Can this be done with reactors?

    I'm not saying its the best piece of coding(!) but it works ok at present!

    fao BCrouse:
    Viewports in paperspace are selected, then a piece of text (3mm high, mid just) is placed in PS at a chosen point. Text gives VP scale to 0 dec places to appear on plotable (not my preferred way, but who am I to argue with office standards!). Command line shows actual VP scale to 3 dec places.
    If the scale of the viewport changes, I would like the text to "auto update" to new scale value.

    fao gpope:
    Acad ADT 2004. Win NT 2000.
    "Fields would be a lot easier to use"????

    fao Mike Perry:
    Thanks for sorting the code area bit on the post. Still cant work out how to do that!

    Many thanks,
    Last edited by kieren; 2004-10-06 at 02:18 PM.

  5. #5
    AUGI Addict Glenn Pope's Avatar
    Join Date
    2001-05
    Location
    Austin, TX USA
    Posts
    2,201
    Login to Give a bone
    0

    Default Re: Can this be done with reactors?

    Quote Originally Posted by kieren
    fao gpope:
    Acad ADT 2004. Win NT 2000.
    "Fields would be a lot easier to use"????
    Fields are a 2005 feature. Maybe this is the last needed reason to upgrade Fields would just need a short expression to do this. Check out this post by RobertB to get an idea.

  6. #6
    The Silent Type Mike.Perry's Avatar
    Join Date
    2000-11
    Posts
    13,656
    Login to Give a bone
    0

    Default Re: Can this be done with reactors?

    Quote Originally Posted by kieren
    fao Mike Perry:
    Thanks for sorting the code area bit on the post. Still cant work out how to do that!
    Hi Kieren

    Need Help with Mid 2 Point

    Are there any special codes/tags I can use to markup my posts?

    +

    Code Buttons and Clickable Smilies

    +

    Does the attached image file help....

    , Mike
    Attached Images Attached Images

Similar Threads

  1. Can someone help me with reactors?
    By ReachAndre in forum AutoLISP
    Replies: 5
    Last Post: 2014-05-28, 03:02 PM
  2. Reactors???
    By cosmarchy in forum AutoLISP
    Replies: 5
    Last Post: 2012-09-04, 04:28 PM
  3. need some help with reactors
    By darren_lambett in forum AutoLISP
    Replies: 1
    Last Post: 2009-04-20, 12:31 PM
  4. Reactors????
    By LLAW3224 in forum AutoLISP
    Replies: 2
    Last Post: 2005-03-04, 12:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •