Jump to content

osmode is changing on me or the reset is being bypassed


dnovember99

Recommended Posts

So I have my settings a certain way, and I havw a lisp routine that I am able to type a command to set them all back to a certain way. But for some reason when I am in a command it works and then when I exit the command or hit ESC, prior to completing the command, all my settings go wakko! For example my osnap settings turn off, my polar settings go from what I have set (15 degrees) and then it changes it by 2.5 degrees. orthodox sometimes turns off or on.

 

this is happening no matter if i finish the command or if i hit ESC. i have made some modifications to the lisp to try and make it work for me but i cant seem to get this to work.

 

Does anyone know of a fix for this? Or a better work around? It seems to happen almost each time I run any command.

 

 

 

Thanks all

 

(defun c:K ()
 (setvar "POLARMODE" 1)
 (setvar "osmode" 551)
 (setvar "POLARANG" (angtof "15.0"))
)
;;when you type K, it resets your osnaps to your custom setting

;;Custom Routines

(defun c:c0 () (command "_copybase" "0,0") )
(defun c:v0 () (command "_pasteclip" "0,0") )
(defun c:ZZ () (command "layfrz") )

(load "_RC-CLOUDS")
(defun c:KL () (load "_KL") (C:KL))
;;DRAW BACKWARDS 3-POINT LEADER
(defun c:T2MT () (load "T2MT-MT2T") (C:T2MT))
;;TEXT TO MTEXT
(defun c:VB () (load "_VB") (C:VB))
;;VIEWPORT BOX IN MODELSPACE
(defun c:XRR () (load "XRR") (C:XRR))
;;XREF RELOAD
(defun c:XRV () (load "XRV") (C:XRV))
;;XREF RELOAD WITH VISRETAIN
(defun c:XRU () (load "XRU") (C:XRU))
;;XREF DETACH
(defun c:explodable () (load "explodable") (C:explodable))
;;explodable
(defun c:cleanbase () (load "cleanbase") (C:cleanbase))
;;Clean base drawing
(defun c:cleantitle () (load "cleantitle") (C:cleantitle))
;;Clean title drawing

(Defun c:ERD () (load "_ERD") (c:ERD))
(Defun c:ERH () (load "_ERD") (c:ERH))
(Defun c:ERT () (load "_ERD") (c:ERT))

(Defun C:QS () (command ".qsave") (princ))
(defun c:read ()
 (defun c:qs () (alert "NO! NO! NO! NO! NO! NO!"))
)


(defun c:Dave()
 (load "_0Dave.lsp")
 (alert "Dave - list of commands \nK - Your ACAD Defaults \nQS - Quick Save \nERH Erase Hatch \nMA Match Properties\nREAD - removes Quick Save command \nKL - Draw backwards three point leader \nCleantitle - Clean title drawing \nCleanBase - Clean base drawing\nRCC - Rev Cloud Sketch \nRCB - Rev Cloud Block")
)

(print "Dave Lisp Loaded Successfully!")
(princ)

(defun c:MA () (COMMAND "MATCHPROP") )
;;XREF DETACH

 

 

here is a link to my original post.

 

http://www.cadtutor.net/forum/showthread.php?104632-osmode-is-always-changing&p=704537#post704537

Link to comment
Share on other sites

But for some reason when I am in a command it works and then when I exit the command or hit ESC, prior to completing the command, all my settings go wakko! For example my osnap settings turn off, my polar settings go from what I have set (15 degrees) and then it changes it by 2.5 degrees. orthodox sometimes turns off or on.

 

this is happening no matter if i finish the command or if i hit ESC. i have made some modifications to the lisp to try and make it work for me but i cant seem to get this to work.

 

Does anyone know of a fix for this? Or a better work around? It seems to happen almost each time I run any command.

 

Are you saying all your System Variable settings go wakko after running an AutoCAD command or after running a custom command from one of your loaded lisp routines?

 

If after running a custom command from one of your loaded lisp routines post it so we can take a look at it, Can I assume you posted your acaddoc.lsp file?

Link to comment
Share on other sites

Are you saying all your System Variable settings go wakko after running an AutoCAD command or after running a custom command from one of your loaded lisp routines?

 

If after running a custom command from one of your loaded lisp routines post it so we can take a look at it, Can I assume you posted your acaddoc.lsp file?

 

it isn't just with a custom lisp routine that does this. it is even when i am drawing a simple line, doing match properties(above lisp i have it set to MA), mirror or really anything else.

 

and i am still rather new to the whole lisp routine thing so i am sorry if this sounds bad. but the acadoc.lsp? and if that makes you laugh please go ahead lol :D

Link to comment
Share on other sites

Acaddoc.lsp loads each time a drawing opens so any lisp defined in it will always be available in any open drawing, acad.lsp loads only when AutoCAD is opened.

These files are user defined and do not come installed with AutoCAD.

 

I'd guess one of the lisp routines loaded in the code above is causing the issue. Since you haven't been using acaddoc.lsp you must have added the code above with Appload. Try removing the code from there and see if restarting AutoCAD fixes the issue.

 

Then load each of those routines one at a time from the command line testing each one to see which one makes your System Variable settings go wakko. Post the routine that makes your System Variable settings go wakko and we'll be able to fix it for you.

Link to comment
Share on other sites

Acaddoc.lsp loads each time a drawing opens so any lisp defined in it will always be available in any open drawing, acad.lsp loads only when AutoCAD is opened.

These files are user defined and do not come installed with AutoCAD.

 

I'd guess one of the lisp routines loaded in the code above is causing the issue. Since you haven't been using acaddoc.lsp you must have added the code above with Appload. Try removing the code from there and see if restarting AutoCAD fixes the issue.

 

Then load each of those routines one at a time from the command line testing each one to see which one makes your System Variable settings go wakko. Post the routine that makes your System Variable settings go wakko and we'll be able to fix it for you.

 

 

i think that i found a possible problem. would having two lisp routines, in the same folder (but having a slight modification to one) cause that issue? i also have autoloader from lee mac that i use. but within that autoloader it only has one of those files.

 

here is my autoloader file (the ***** is personal information that i blocked out. being that i am on a work computer.)

 

(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/AlignTextV1-4.lsp" '("AT"))
(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/BreakObjects22.LSP" '("BREAKALL" "BREAKOBJECT" "BREAKWOBJECT" "BREAKWLAYER" "BREAKWITH" "BREAKTOUCHING" "BREAKWITHTOUCHING" "BREAKSELECTED" "BREAKREMOVE" "MYBREAK"))
(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/BREAL ALL (BRKALL).lsp" '("BRKALL"))
(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/BubbleOff.lsp" '("BOFF"))
(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/CHANGE TEXT STYLE (CTS).lsp" '("CTS"))
(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/creater.lsp" '("CREATE"))
(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/del-layer.lsp" '("DEL-LAYER" "MDEL-LAYER"))
(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/DynamicTextAlignV1.0.lsp" '("DTA"))
(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/EXISTING TO REMAIN TEXT(ENT).LSP" '("ENT"))
(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/FLIP IT.lsp" '("FLIP"))
(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/GTTR.lsp" '("GTTR" "BTI" "GTTI"))
(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/JTEXT V1.0.LSP" '("JTEXT"))
(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/JTEXT V2.0.LSP" '("JTEXT"))
(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/justify.lsp" '("JL" "JR"))
(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/layer color change (LC).lsp" '("LC"))
(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/Layer No Plot (LNP).LSP" '("LNP"))
(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/Layer plot (LP).LSP" '("LP"))
(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/NO SPACES.LSP" '("NOSPACE"))
(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/pipe-calc.lsp" '("INVERT"))
(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/PLOT NO PLOT.LSP" '("LNP" "LP"))
(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/Scale All Tags(SX).lsp" '("SX"))
(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/Scale Text Height(TH).lsp" '("TH"))
(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/Spin Block(SPB).lsp" '("SPB"))
(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/t2m.lsp" '("T2M"))
(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/TEXT TO LEADER (TXL).LSP" '("TXL" "TEXTLEADER"))
(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/TRIM BETWEEN LINES(TB2).lsp" '("TB2"))
(autoload "C:/Users/dave********/Desktop/LISP ROUTINES/XrefBind.LSP" '("XB"))

 

here is the code to one lisp:

  ;; ENTER COMMAND OF (SX) SELECT ANY TAGS THAT YOU WANT TO CHANGE THE SCALE ON/ 
 ;; 48 = 1/4" SCALE  96 = 1/8" SCALE.
 ;; YOU CAN SELECT MULTI TAGS AT ONCE. AFTER YOU HAVE YOUR NEW SCALE ALL THAT YOU WILL NEED TO DO IS
 ;; REARRANGE BUT THIS ELMINATES YOU HAVING TO SELECT WHAT YOU WANT, GO TO PROPERTIES AND CHANGE EACH
 ;; VALUE OF THE X, Y AND Z AXIS (THIS COMMAND WILL ALSO REMEMBER THE LAST SCALE FACTOR USED).
(defun c:SX (/ i s)
 (or (setq i (getenv "ScaleIt")) (setq i "48."))
 (if (and (not (initget 2))
   (setq i (cond ((getreal (strcat "\nEnter block scale[<" i ">]: ")))
		 ((read i))
	   )
   )
   (setq s (ssget ":L" '((0 . "insert"))))
   (setenv "ScaleIt" (vl-princ-to-string i))
     )
   (foreach b (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))))
     (foreach c '("X" "Y" "Z")
(vl-catch-all-apply 'vlax-put (list b (read (strcat c "ScaleFactor")) i))
     )
   )
 )
 (princ)
)
(vl-load-com)

 

and here is the same code with a slight change to just the wording at the top

  ;; TAG SCALE - 11.28.2017
 ;; ENTER COMMAND OF (SX) SELECT ANY TAGS THAT YOU WANT TO CHANGE THE SCALE ON/ 
 ;; 48 = 1/4" SCALE  96 = 1/8" SCALE.
 ;; YOU CAN SELECT MULTI TAGS AT ONCE. AFTER YOU HAVE YOUR NEW SCALE ALL THAT YOU WILL NEED TO DO IS
 ;; REARRANGE BUT THIS ELMINATES YOU HAVING TO SELECT WHAT YOU WANT, GO TO PROPERTIES AND CHANGE EACH
 ;; VALUE OF THE X, Y AND Z AXIS (THIS COMMAND WILL ALSO REMEMBER THE LAST SCALE FACTOR USED).
(defun c:SX (/ i s)
 (or (setq i (getenv "ScaleIt")) (setq i "48."))
 (if (and (not (initget 2))
   (setq i (cond ((getreal (strcat "\nEnter block scale[<" i ">]: ")))
		 ((read i))
	   )
   )
   (setq s (ssget ":L" '((0 . "insert"))))
   (setenv "ScaleIt" (vl-princ-to-string i))
     )
   (foreach b (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))))
     (foreach c '("X" "Y" "Z")
(vl-catch-all-apply 'vlax-put (list b (read (strcat c "ScaleFactor")) i))
     )
   )
 )
 (princ)
)
(vl-load-com)

 

I am still going to unload all of them and then try and find the one that is causing issues. i also noticed that i have stuff in the autoloader that i am not using much of, so it is time to trim the fat.

Link to comment
Share on other sites

The biggest advantage of using an autoloader is that the full lisp isn't loaded until you run the command the first time. So none of those could cause issues until after you use them.

(load "_RC-CLOUDS")

on the other hand could be causing the issue since you seem to be loading it somehow with the code in your first post.

Link to comment
Share on other sites

The biggest advantage of using an autoloader is that the full lisp isn't loaded until you run the command the first time. So none of those could cause issues until after you use them.

(load "_RC-CLOUDS")

on the other hand could be causing the issue since you seem to be loading it somehow with the code in your first post.

 

so after removing everything that i had in my start up under appload. i found that two of the lisps are causing the issues. but i am also noticing that when i have my polar tracking on and set at the 15 degrees, if i draw a line that isn't at 15 degrees, the next segment of line that is drawn is messed up and off by 2-5 degrees.

 

but here is the two lisp's that i noticed

 

;; THIS WILL ALLOW YOU TO BE ABLE TO CHOOSE IF YOU WANT TO HAVE THIS AT THE BEGINNING OR THE END OF TEXT
;; AFTER SELECTING P OR S YOU CAN PLACE WHAT EVER TEXT YOU WANT. 
;; THIS WILL ADD TO THE BEGINNING RO THE END OF EACH SELECTED TEXT GROUP.
;;
;;
(defun c:ENT (/ PreSuf Str ent Cstr)
 (vl-load-com)
 (initget "P S")
 (setq PreSuf (getkword "\nChoose [Prefix/Suffix]  <Prefix>: "))
 (if (not PreSuf)
   (setq PreSuf "S")
 )
 (while (not str)
   (setq str (getstring T "\nEnter String: "))
   (cond ((and (eq str "")
 (princ "Null Input Try again")
 (setq str nil)
   )
  )
   )
 )
 (while (and (setq ent (car (nentsel "\nSelect Text/Attribute: ")))
      (member (cdr (assoc 0 (entget ent)))
       '("TEXT" "MTEXT" "ATTRIB")
      )
 )
   (setq ent  (vlax-ename->vla-object ent)
  Cstr (vla-get-textstring ent)
   )
   (vla-put-textstring
     ent
     (if (eq PreSuf "S")
(strcat Cstr "" str)
(strcat str "" Cstr)
     )
   )
 )(princ)
)

 

(defun C:FLIP ( / L f )
 (and
   (setq L
     (CycleInputs
       '(
         (SS (progn (princ "\n>>Select objects to mirror: ") (ssget "_:L")))
         (p1 (progn (initget "Exit") (apply 'getpoint (append (if p2 (list p2)) '("First Point [Exit]: ")))) )
         (p2 (progn (initget "Exit") (apply 'getpoint (append (if p1 (list p1)) '("Second Point [Exit]: ")))) )
       )
       (lambda (s v) (= "Exit" v) )
     ); CycleInputs
   ); setq L
   (= 3 (length L)) (setq f (lambda (x) (cdr (assoc x L))))
   (progn 
     (setvar 'cmdecho 0)
     (command "_.MIRROR" (f 'SS) "" "_non" (f 'p1) "_non" (f 'p2) "Y")
     (setvar 'cmdecho 1)
   )
 )
 (princ)
); defun C:flip


(defun CycleInputs ( inpL exitf / tmp )
 (cond  ; (87 114 105 116 116 101 110 32 98 121 32 71 114 114 114)
   ( (not inpL) inpL)
   ( (setq tmp (vl-catch-all-apply (function (lambda (a b) (set a (eval b)))) (car inpL)))
     (cond 
       ( (vl-catch-all-error-p tmp) (prompt (vl-catch-all-error-message tmp)) )
       ( (and exitf (vl-catch-all-apply (function exitf) (list (caar inpL) tmp))) (set (caar inpL) nil) )
       (
         (mapcar (function (lambda (tmp) (set (car tmp) nil) tmp))
           (cons (cons (caar inpL) tmp) (CycleInputs (cdr inpL) exitf))
         )
       )
     )
   )
   ( (CycleInputs (reverse (cons (car inpL) (reverse (cdr inpL)))) exitf) )
 )
)

 

thank you again for all your help/

Link to comment
Share on other sites

i am wondering, if you are to have an error handler lisp routine saved within the same file that all of your lisp routines are at, and you had each of the lisp routines that you run call the error handler at anytime you use a custom lisp? is that something that is even possible?

Link to comment
Share on other sites

ENT is defined as both a function name and a local variable. I'd modify the function name as ENT is one of the most commonly used lisp variable as it's used for an ENTity. FYI: Cadalyst tip 1527A DDAPTXT.LSP Append to Text ©June 1999, Scott A. Matthews has a nice dialog box routine for adding prefixes and suffixes to text.

 

FLIP has global variables that may be conflicting with other code loaded into your drawing.

Change

(defun C:FLIP ( / L f )

to

(defun C:FLIP ( / L SS p1 p2 f )

SS commonly used for Selection Set may be the most used lisp variable.

Link to comment
Share on other sites

i am wondering, if you are to have an error handler lisp routine saved within the same file that all of your lisp routines are at, and you had each of the lisp routines that you run call the error handler at anytime you use a custom lisp? is that something that is even possible?

 

Generally I'll add *ERROR* as a local variable and define an *ERROR* function inside the main function so it resets everything if needed without modifying the default *ERROR* function.

Any function that allows user input or takes long enough to run for someone to hit the Esc key needs to account for someone responding incorrectly. Resetting System Variables at the end of a routine only works if the routine finishes smoothly.

Link to comment
Share on other sites

Generally I'll add *ERROR* as a local variable and define an *ERROR* function inside the main function so it resets everything if needed without modifying the default *ERROR* function.

Any function that allows user input or takes long enough to run for someone to hit the Esc key needs to account for someone responding incorrectly. Resetting System Variables at the end of a routine only works if the routine finishes smoothly.

 

ok so after running this for a while it looks like this didn't fix the issue. i guess i am just stuck with having to dump a few of my commands that i use from time to time

Link to comment
Share on other sites

so it is looking like when i set the polar tracking to the 15 degrees that i want to use, and if i do not stay on a plain of 15 degrees then that is when things are starting to go wakko. i have removed all custom lisp routines and everything still does this.

 

i also realized that even with this doing this to me my polar tracking setting doesn't change, it stays on 15 degrees

polor tracking degrees is off.jpg

result of polar tracking going wakko.jpg

Link to comment
Share on other sites

so it is looking like when i set the polar tracking to the 15 degrees that i want to use, and if i do not stay on a plain of 15 degrees then that is when things are starting to go wakko. i have removed all custom lisp routines and everything still does this.

 

i also realized that even with this doing this to me my polar tracking setting doesn't change, it stays on 15 degrees

 

 

ok i wanted to update to what i found. it looks like for some reason under the polar tracking settings something, or somehow it was changed from absolute to relative to last segment. i am not sure how this happened so now i have to figure out how this can remain the same.

polar angle messurement settings.png

Link to comment
Share on other sites

ok i wanted to update to what i found. it looks like for some reason under the polar tracking settings something, or somehow it was changed from absolute to relative to last segment. i am not sure how this happened so now i have to figure out how this can remain the same.

 

POLARMODE (System Variable) Controls settings for polar and object snap tracking. You want it set to 0.

https://knowledge.autodesk.com/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-Core/files/GUID-D91628CC-9975-4DBF-8D02-10B23A6F3ED5-htm.html

 

You may want to search your lisp files for POLARMODE to see if it's being modified somewhere.

Link to comment
Share on other sites

ok so after running this for a while it looks like this didn't fix the issue. i guess i am just stuck with having to dump a few of my commands that i use from time to time

 

As long as those lisp are not automatically loaded every time a drawing is opened and aren't loaded until they're needed using the AUTOLOAD lisp function you should be able to track down system variable changes easy enough with AutoCAD 2016's System Variable Monitor. It will alert you whenever a system variable you've put on the list is changed.

https://autocadtips1.com/2015/05/23/autocad-2016-system-variable-monitor/ or http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-82BACF96-AC90-446A-8E60-3CC3072F8060

 

Lee Mac describes the advantages of different methods of loading lisp here: http://www.lee-mac.com/autoloading.html Besides the issues you're having there are other reasons for not wanting lisp you use from time to time loaded every time you open a drawing.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...