Jump to content

'ZOOM Extents' not working properly in 2014


bababarghi
 Share

Recommended Posts

Hi all,

 

I have a small lisp getting loaded every time I open a drawing (located in Startup suite). It was working perfectly fine in AutoCAD 2013. Since upgrading to 2014, the following scenario happens:

 

This is how I last saved my drawing:

1b12b713_l.jpeg

 

 

This is what I get after opening drawing (notice it is not zoomed to extents):

2b7af824_l.jpeg

 

 

This is what I was expecting to see:

51126fd4_l.jpeg

 

Moreover, SECURELOAD is set to "0" and my lisp is like below:

 

(defun C:DoTheseSteps()
(setvar "tilemode" 1)
(setvar "PLINEWID" 0)
(setvar "SNAPUNIT" '(1.25 1.25))
(command "._ZOOM" "Extents")
)

(c:DoTheseSteps)

 

 

snapshot from command prompt:

zvwphf.jpg

Any idea why 'ZOOM EXTENTS' is not working?

Link to comment
Share on other sites

Your acaddoc.lsp is working fine on my A2014... Maybe try with (command-s "_.zoom" "_E") or this acaddoc.lsp :

 

(vl-load-com)
(setvar "tilemode" 1)
(setvar "PLINEWID" 0)
(setvar "SNAPUNIT" '(1.25 1.25))
(vla-zoomextents (vlax-get-acad-object))

Link to comment
Share on other sites

I would suggest using the s::startup postinitialization function to evaluate the zoom extents operation after the drawing has been fully opened.

 

Copy the following to your acaddoc.lsp:

(vl-load-com)
(setvar 'tilemode 1)
(setvar 'plinewid 0.0)
(setvar 'snapunit '(1.25 1.25))

(defun zoomextents ( )
   (vla-zoomextents (vlax-get-acad-object))
   (princ)
)
(if (= 'list (type s::startup))
   (setq s::startup (append s::startup '((zoomextents))))
   (defun-q s::startup ( ) (zoomextents))
)
(princ)

Link to comment
Share on other sites

Your acaddoc.lsp is working fine on my A2014... Maybe try with (command-s "_.zoom" "_E") or this acaddoc.lsp :

 

(vl-load-com)
(setvar "tilemode" 1)
(setvar "PLINEWID" 0)
(setvar "SNAPUNIT" '(1.25 1.25))
(vla-zoomextents (vlax-get-acad-object))

 

Thanks marko_ribar. I came up using Lee's method. But thanks anyway.

 

I would suggest using the s::startup postinitialization function to evaluate the zoom extents operation after the drawing has been fully opened.

 

Copy the following to your acaddoc.lsp:

(vl-load-com)
(setvar 'tilemode 1)
(setvar 'plinewid 0.0)
(setvar 'snapunit '(1.25 1.25))

(defun zoomextents ( )
   (vla-zoomextents (vlax-get-acad-object))
   (princ)
)
(if (= 'list (type s::startup))
   (setq s::startup (append s::startup '((zoomextents))))
   (defun-q s::startup ( ) (zoomextents))
)
(princ)

 

Lee, the guru, your code is charmingly working as expected. But, as a beginner, I am trying to simplify your solution for myself. Based on your post here, I could also use following code:

(defun-q zoomextents ( )
 (vla-zoomextents (vlax-get-acad-object))
 (princ))

(setq S::STARTUP (append S::STARTUP zoomextents))

 

instead of:

(defun zoomextents ( )
   (vla-zoomextents (vlax-get-acad-object))
   (princ)
)

(if (= 'list (type s::startup))
   (setq s::startup (append s::startup '((zoomextents))))
   (defun-q s::startup ( ) (zoomextents))
)
(princ)

 

Couldn't I?

 

Obviously, there is a logic behind your approach and that is what I am trying to understand.

Link to comment
Share on other sites

Lee, the guru, your code is charmingly working as expected.

 

Thank you, I'm glad that the code is working for you.

 

But, as a beginner, I am trying to simplify your solution for myself. Based on your post here, I could also use following code:

(defun-q zoomextents ( )
 (vla-zoomextents (vlax-get-acad-object))
 (princ))

(setq S::STARTUP (append S::STARTUP zoomextents))

instead of:

(defun zoomextents ( )
   (vla-zoomextents (vlax-get-acad-object))
   (princ)
)

(if (= 'list (type s::startup))
   (setq s::startup (append s::startup '((zoomextents))))
   (defun-q s::startup ( ) (zoomextents))
)
(princ)

Couldn't I?

 

Obviously, there is a logic behind your approach and that is what I am trying to understand.

 

The 'simplified' version from that [very old] post assumes that the s::startup symbol is either nil or has previously been defined using defun-q (to yield a list); if the s::startup symbol has inadvertently been defined using defun or has been defined to hold a non-list value elsewhere in another startup file, this approach will error.

 

My more recent code incorporates more error-trapping in that, if the s::startup symbol is not a list, the symbol will be redefined correctly using defun-q.

Link to comment
Share on other sites

Further to my above post, consider the case in which the s::startup function has been correctly defined else using a defun-q expression:

 

_$ (defun-q s::startup ( ) (princ "\nMy startup.") (princ))
S::STARTUP
_$ s::startup
(nil (PRINC "\nMy startup.") (PRINC))

Now we define our own function to be appended to the startup function:

_$ (defun-q zoomextents ( ) (vla-zoomextents (vlax-get-acad-object)) (princ))
ZOOMEXTENTS
_$ zoomextents
(nil (vla-ZoomExtents (vlax-get-acad-object)) (PRINC))

Note that when appended, the arguments/local variable declaration list now appears within the s::startup function definition:

_$ (setq s::startup (append s::startup zoomextents))
(nil (PRINC "\nMy startup.") (PRINC) [color=red]nil[/color] (vla-ZoomExtents (vlax-get-acad-object)) (PRINC))

This is OK if this list is nil, however, if this list were to contain local variables, the resulting function would error as this list would be interpreted as a division expression:

_$ (defun-q mystartup ( / a b c ) (setq a "a" b "b" c "c") (princ))
MYSTARTUP
_$ mystartup
((/ A B C) (SETQ A "a" B "b" C "c") (PRINC))

_$ (defun-q s::startup ( ) (princ "\nMy startup.") (princ))
S::STARTUP
_$ s::startup
(nil (PRINC "\nMy startup.") (PRINC))

_$ (setq s::startup (append s::startup mystartup))
(nil (PRINC "\nMy startup.") (PRINC) [color=red](/ A B C)[/color] (SETQ A "a" B "b" C "c") (PRINC))

Resulting in the following error, since the arguments for the apparent 'division expression' are nil:

_$ (s::startup)

My startup.
; error: bad argument type: numberp: nil

Of course, this list header could be removed using cdr before appending the function definition to the s::startup definition, but this would mean that the symbols defined by the function would be global and no longer declared as local variables.

 

Using my more recent arrangement yields a far cleaner result in my opinion:

_$ (defun mystartup ( / a b c ) (setq a "a" b "b" c "c") (princ))
MYSTARTUP
_$ mystartup
#<USUBR @1a0d7f00 MYSTARTUP>

_$ (defun-q s::startup ( ) (princ "\nMy startup.") (princ))
S::STARTUP
_$ s::startup
(nil (PRINC "\nMy startup.") (PRINC))

_$ (setq s::startup (append s::startup '((mystartup))))
(nil (PRINC "\nMy startup.") (PRINC) (MYSTARTUP))

All variables remain local to the mystartup function, and we have no error during evaluation:

_$ (s::startup)

My startup.

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
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.

 Share

×
×
  • Create New...