Author Topic: Lisp works while zoomed close, but not when zoomed out  (Read 2651 times)

0 Members and 1 Guest are viewing this topic.

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Lisp works while zoomed close, but not when zoomed out
« on: July 16, 2004, 01:01:00 PM »
I combined my ShadowBox.lsp file with the Loud.lsp.  The lisp creates two polylines around MTEXT, with the second being offset from the first to create the shadow.  It works when zoomed close to the text, but not when zoomed out...the top is how it should look, the bottom is what happens when I run the lisp zoomed out a little bit from the text...confused....


HERE is a link to the lisp text file shown below

Code: [Select]
;;***********************************************
;;               ShadowBox2.lsp                 *
;;          Created by Dominic Cesare           *
;;    Revisions to ShadowBox.lsp 04.22.04       *
;;***********************************************

;;**********************
;;*  Start of Routine  *
;;**********************

;informs user how to run lisp
(prompt "\nType ShadowBox2 to run.....")

;define function
(defun C:ShadowBox2 (/ oldlayer oldecho oldosmode oldplwidth SW SW1
    ent fnm tlf wid hig mth brg tlfo brgo PT1 PT2
    PT3 PT4 PT5 PT6 PT7 EN1 EN2)
  (setq temperr *error*)
  (setq *error* trap1)
  ;storing current variables
  (setq oldlayer (getvar "clayer"))
  (setq oldecho (getvar "cmdecho"))
  (setq oldosmode (getvar "osmode"))
  (setq oldplwidth (getvar "plinewid"))
  ;turning off echo
  (setvar "cmdecho" 1)
  ;setting current layer to "DIM" - will be created if not present
  (command "-layer" "m" "DIM" "c" "2" "" "")
  ;changing polyline width to 0
  (setvar "plinewid" 0)
  ;setting distances from main box corners for shadow polyline
  (setq SW 1.5)
  (setq SW1 0.75)
  ;turning off object snaps
  (setvar "osmode" 1)
  (prompt "Select MTEXT.....")
  (setq ent (ssget))
  (setq fnm (ssname ent 0))
  (setq tlf (cdr (assoc 10 (entget fnm))))
  (setq wid (cdr (assoc 42 (entget fnm))))
  (setq hig (cdr (assoc 43 (entget fnm))))
  (setq mth (cdr (assoc 40 (entget fnm))))
  ;formulates bottom right corner and sets as "brg"
  (setq brg (list (+ (car tlf) wid) (- (cadr tlf) hig)))
  ;formulates rectangle top left corner, "tlfo"
  (setq tlfo (list (- (car tlf) mth) (+ (cadr tlf) mth)))
  ;formulates rectangle bot right cor, "brgo"
  (setq brgo (list (+ (car brg) mth) (- (cadr brg) mth)))
  ;calculating points to create shadow box
  (setq PT1 (list (car tlfo) (cadr brgo))
PT2 (list (car brgo) (cadr tlfo))
    PT3 (list (car PT1) (cadr PT2))
PT4 (list (car PT2) (cadr PT1))
PT5 (list (car (polar PT1 (* pi 2) SW))(cadr (polar PT1 (* pi 1.5) SW1)))
PT7 (list (car (polar PT2 (* pi 2) SW1))(cadr (polar PT2 (* pi 1.5) SW)))
PT6 (list (car PT7) (cadr PT5))
)
  ;creating main box
  (command "_.PLINE" PT1 PT3 PT2 PT4 "_C")
  (setq EN1 (entlast))
  ;creating shadow polyline
  (command "_.PLINE" PT5 "w" SW SW PT6 PT7 "")
  (setq EN2 (entlast))
  ;grouping main box and shadow
  (command "-Group" "" "*" "" EN1 EN2 "")
  ;resetting system variables
  (setvar "clayer" oldlayer)
  (setvar "cmdecho" oldecho)
  (setvar "osmode" oldosmode)
  (setvar "plinewid" oldplwidth)
  (setq *error* temperr)
  (princ)
  )
 
(defun trap1 (errmsg)
  (command "u")
  (setvar "clayer" oldlayer)
  (setvar "cmdecho" oldecho)
  (setvar "osmode" oldosmode)
  (setvar "plinewid" oldplwidth)
  (setq *error* temperr)
  (prompt "Resetting System Variables...")
  (princ)
  )

;;**********************
;;*  End of Routine    *
;;**********************

Ron Heigh

  • Guest
Lisp works while zoomed close, but not when zoomed out
« Reply #1 on: July 16, 2004, 01:05:18 PM »
change
Code: [Select]
(setvar "osmode" 1)
to
Code: [Select]
(setvar "osmode" 0)

nice routine by the way.

daron

  • Guest
Lisp works while zoomed close, but not when zoomed out
« Reply #2 on: July 16, 2004, 01:05:25 PM »
My guess without too much study: osnaps. They could be the culprit. Also, check for the use of last in the code. I didn't, but those are the two most common problems I know of with what you describe.

Ron Heigh

  • Guest
Lisp works while zoomed close, but not when zoomed out
« Reply #3 on: July 16, 2004, 01:11:29 PM »
osmode 1 = endpoint.
When you are zoomed out to where you can see any corners of the mtext box, you get a snap to those points.
When you are zoomed in so no mtext corners are visible, no snap occurs.

SPDCad

  • Bull Frog
  • Posts: 453
Lisp works while zoomed close, but not when zoomed out
« Reply #4 on: July 16, 2004, 01:14:29 PM »
Damn,  Ron beat me to it!   :x

Osmode should be equal to 0.

Nice little proggy thou
AutoCAD 2010, w/ OpenDCL

visit: http://reachme.at/spd_designs

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Lisp works while zoomed close, but not when zoomed out
« Reply #5 on: July 16, 2004, 02:48:21 PM »
Aww man...I must have changed that line by accident when I wanted to change the CMDECHO variable for a test run...f00k :evil: *smacks forehead* ...Thanks everyone...

EDIT: Can't take all the credit...the section for finding the corners of the MTEXT are from the LOUD.LSP file...don't think it has any header in it with author info...I then used the corners it figured out to find the points I wanted to use for my shadow box...but the rest is all me...with a lot of all of you in there...wouldn't have gotten as far (even though it's not that far) without all of you...Cheers to everyone here  :dood:

Fuccaro

  • Guest
Lisp works while zoomed close, but not when zoomed out
« Reply #6 on: July 17, 2004, 01:14:08 AM »
Dommy2Hotty

Try to create the shadow polyline -and why not the box too- with ENTMAKE. You will have no more problems with the OSNAP settings.